mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 19:05:16 +00:00
Fix animated torches not causing block updates in some situations, closes #2510
This commit is contained in:
1 parent
44738451ef
commit
446bd04b3d
2 files changed
+29
-9
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user