Fix mana prism automation changes not causing spreaders to recalculate, closes #2837

This commit is contained in:
Vincent Lee committed 2019-02-01 16:28:15 -06:00
1 parent cff5edcd21
commit 25cfc07349
2 files changed
+11 -5

No files matched your search

@@ -122,13 +122,9 @@ public class BlockPrism extends BlockMod implements IManaTrigger, ILexiconable,
player.setHeldItem(hand, ItemStack.EMPTY);
prism.getItemHandler().setStackInSlot(0, heldItem.copy());
prism.markDirty();
world.setBlockState(pos, state.withProperty(BotaniaStateProps.HAS_LENS, true), 1 | 2);
} else if(!lens.isEmpty()) {
ItemHandlerHelper.giveItemToPlayer(player, lens);
prism.getItemHandler().setStackInSlot(0, ItemStack.EMPTY);
prism.markDirty();
world.setBlockState(pos, state.withProperty(BotaniaStateProps.HAS_LENS, false), 1 | 2);
}
return true;
@@ -170,7 +166,7 @@ public class BlockPrism extends BlockMod implements IManaTrigger, ILexiconable,
@Override
public void onBurstCollision(IManaBurst burst, World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if(tile != null && tile instanceof TilePrism)
if(tile instanceof TilePrism)
((TilePrism) tile).onBurstCollision(burst);
}
@@ -10,6 +10,7 @@
*/
package vazkii.botania.common.block.tile.mana;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.internal.IManaBurst;
@@ -18,6 +19,7 @@ import vazkii.botania.api.mana.BurstProperties;
import vazkii.botania.api.mana.ILens;
import vazkii.botania.api.mana.ITinyPlanetExcempt;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.TileSimpleInventory;
import javax.annotation.Nonnull;
@@ -72,6 +74,14 @@ public class TilePrism extends TileSimpleInventory {
public void markDirty() {
super.markDirty();
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
if(world != null && !world.isRemote) {
IBlockState state = world.getBlockState(pos);
boolean hasLens = !itemHandler.getStackInSlot(0).isEmpty();
if (state.getBlock() != ModBlocks.prism || state.getValue(BotaniaStateProps.HAS_LENS) != hasLens) {
IBlockState base = state.getBlock() == ModBlocks.prism ? state : ModBlocks.prism.getDefaultState();
world.setBlockState(pos, base.withProperty(BotaniaStateProps.HAS_LENS, hasLens));
}
}
}
}