diff --git a/src/main/java/vazkii/botania/common/block/BlockAnimatedTorch.java b/src/main/java/vazkii/botania/common/block/BlockAnimatedTorch.java index 3d78de21e..8c4851770 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAnimatedTorch.java +++ b/src/main/java/vazkii/botania/common/block/BlockAnimatedTorch.java @@ -150,6 +150,15 @@ public class BlockAnimatedTorch extends BlockMod implements IWandable, IManaTrig return BlockFaceShape.UNDEFINED; } + @Override + public void onBlockDestroyedByPlayer(World world, BlockPos pos, IBlockState state) { + // TE is already gone so best we can do is just notify everyone + for(EnumFacing side : EnumFacing.VALUES) { + world.notifyNeighborsOfStateChange(pos.offset(side), this, false); + } + super.onBlockDestroyedByPlayer(world, pos, state); + } + @Override public LexiconEntry getEntry(World world, BlockPos pos, EntityPlayer player, ItemStack lexicon) { return LexiconData.animatedTorch; diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAnimatedTorch.java b/src/main/java/vazkii/botania/common/block/tile/TileAnimatedTorch.java index 374fab214..d04232f8a 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAnimatedTorch.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAnimatedTorch.java @@ -69,6 +69,7 @@ public class TileAnimatedTorch extends TileMod { if(entity != null) { side = Arrays.asList(SIDES).indexOf(entity.getHorizontalFacing().getOpposite()); } + world.notifyNeighborsOfStateChange(getPos().offset(SIDES[side].getOpposite()), getBlockType(), false); } public void toggle() { @@ -112,7 +113,11 @@ public class TileAnimatedTorch extends TileMod { this.side = side; rotating = true; + // tell neighbors that signal is off because we are rotating world.notifyNeighborsOfStateChange(getPos(), getBlockType(), false); + for(EnumFacing e : EnumFacing.VALUES) { + world.notifyNeighborsOfStateChange(getPos().offset(e), getBlockType(), false); + } } @SideOnly(Side.CLIENT) @@ -133,18 +138,24 @@ public class TileAnimatedTorch extends TileMod { if(rotationTicks <= 0) { rotating = false; + // done rotating, tell neighbors world.notifyNeighborsOfStateChange(getPos(), getBlockType(), false); + for(EnumFacing e : EnumFacing.VALUES) { + world.notifyNeighborsOfStateChange(getPos().offset(e), getBlockType(), false); + } } } else rotation = side * 90; - int amt = rotating ? 3 : Math.random() < 0.1 ? 1 : 0; - double x = getPos().getX() + 0.5 + Math.cos((rotation + 90) / 180.0 * Math.PI) * 0.35; - double y = getPos().getY() + 0.2; - double z = getPos().getZ() + 0.5 + Math.sin((rotation + 90) / 180.0 * Math.PI) * 0.35; + if(world.isRemote) { + int amt = rotating ? 3 : Math.random() < 0.1 ? 1 : 0; + double x = getPos().getX() + 0.5 + Math.cos((rotation + 90) / 180.0 * Math.PI) * 0.35; + double y = getPos().getY() + 0.2; + double z = getPos().getZ() + 0.5 + Math.sin((rotation + 90) / 180.0 * Math.PI) * 0.35; - for(int i = 0; i < amt; i++) - world.spawnParticle(EnumParticleTypes.REDSTONE, x, y, z, 0.0D, 0.0D, 0.0D, new int[0]); + for(int i = 0; i < amt; i++) + world.spawnParticle(EnumParticleTypes.REDSTONE, x, y, z, 0.0D, 0.0D, 0.0D); + } } @Override @@ -171,18 +182,18 @@ public class TileAnimatedTorch extends TileMod { torchMode = modes[modeOrdinal % modes.length]; } - public static enum TorchMode { + public enum TorchMode { TOGGLE((t, i) -> (i + 2) % 4), ROTATE((t, i) -> (i + 1) % 4), RANDOM((t, i) -> t.currentRandomRotation); - private TorchMode(RotationHandler modeSwitcher) { + TorchMode(RotationHandler modeSwitcher) { this.modeSwitcher = modeSwitcher; } public final RotationHandler modeSwitcher; - private static interface RotationHandler { + private interface RotationHandler { int rotate(TileAnimatedTorch tile, int curr); } }