diff --git a/src/main/java/cr0s/warpdrive/Commons.java b/src/main/java/cr0s/warpdrive/Commons.java index da44a4b7..77fb7b53 100644 --- a/src/main/java/cr0s/warpdrive/Commons.java +++ b/src/main/java/cr0s/warpdrive/Commons.java @@ -465,7 +465,9 @@ public class Commons { while(!toIterate.isEmpty() && range < maxRange) { toIterateNext = new HashSet<>(); for (final BlockPos current : toIterate) { - if (whitelist.contains(new VectorI(current).getBlockState_noChunkLoading(world).getBlock())) { + final IBlockState blockStateCurrent = VectorI.getBlockState_noChunkLoading(world, current); + if ( blockStateCurrent != null + && whitelist.contains(blockStateCurrent.getBlock()) ) { iterated.add(current); } @@ -474,7 +476,9 @@ public class Commons { current.getY() + direction.y, current.getZ() + direction.z ); if (!iterated.contains(next) && !toIgnore.contains(next) && !toIterate.contains(next) && !toIterateNext.contains(next)) { - if (whitelist.contains(new VectorI(next).getBlockState_noChunkLoading(world).getBlock())) { + final IBlockState blockStateNext = VectorI.getBlockState_noChunkLoading(world, next); + if ( blockStateNext != null + && whitelist.contains(blockStateNext.getBlock())) { toIterateNext.add(next); } } diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java index bdd75841..31fe0154 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java @@ -127,6 +127,9 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc blockState.getBlock(), this, blockState_in, property, value)); return; } + if (blockState.getValue(property) == value) { + return; + } blockState = blockState.withProperty(property, value); } if (getBlockMetadata() != blockState.getBlock().getMetaFromState(blockState)) { diff --git a/src/main/java/cr0s/warpdrive/data/AcceleratorSetup.java b/src/main/java/cr0s/warpdrive/data/AcceleratorSetup.java index 08ddfbca..093fa2f1 100644 --- a/src/main/java/cr0s/warpdrive/data/AcceleratorSetup.java +++ b/src/main/java/cr0s/warpdrive/data/AcceleratorSetup.java @@ -25,6 +25,7 @@ import java.util.Set; import java.util.TreeMap; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -202,8 +203,12 @@ public class AcceleratorSetup extends GlobalPosition { WarpDrive.blockVoidShellGlass); TrajectoryPoint trajectoryPoint = null; for (final EnumFacing direction : EnumFacing.HORIZONTALS) { - final VectorI next = firstVoidShell.clone(direction); - if (whitelist.contains(next.getBlockState_noChunkLoading(world).getBlock())) { + final BlockPos next = new BlockPos(firstVoidShell.x + direction.getXOffset(), + firstVoidShell.y + direction.getYOffset(), + firstVoidShell.z + direction.getZOffset() ); + final IBlockState blockStateNext = VectorI.getBlockState_noChunkLoading(world, next); + if ( blockStateNext != null + && whitelist.contains(blockStateNext.getBlock()) ) { trajectoryPoint = new TrajectoryPoint(world, firstVoidShell.translate(direction), direction); break; } diff --git a/src/main/java/cr0s/warpdrive/data/VectorI.java b/src/main/java/cr0s/warpdrive/data/VectorI.java index ac946550..35379304 100644 --- a/src/main/java/cr0s/warpdrive/data/VectorI.java +++ b/src/main/java/cr0s/warpdrive/data/VectorI.java @@ -93,14 +93,10 @@ public class VectorI implements Cloneable { return blockAccess.getBlockState(new BlockPos(x, y, z)).getBlock(); } - public IBlockState getBlockState(IBlockAccess blockAccess) { + public IBlockState getBlockState(final IBlockAccess blockAccess) { return blockAccess.getBlockState(new BlockPos(x, y, z)); } - public boolean isChunkLoaded(final IBlockAccess blockAccess) { - return isChunkLoaded(blockAccess, x, z); - } - static public boolean isChunkLoaded(final IBlockAccess blockAccess, final int x, final int z) { if (blockAccess instanceof WorldServer) { return ChunkHandler.isLoaded((WorldServer) blockAccess, x, 64, z); @@ -121,24 +117,16 @@ public class VectorI implements Cloneable { return true; } - public IBlockState getBlockState_noChunkLoading(final IBlockAccess blockAccess, final EnumFacing side) { - return getBlockState_noChunkLoading(blockAccess, x + side.getXOffset(), y + side.getYOffset(), z + side.getZOffset()); - } - - public IBlockState getBlockState_noChunkLoading(final IBlockAccess blockAccess) { - return getBlockState_noChunkLoading(blockAccess, x, y, z); - } - - static public IBlockState getBlockState_noChunkLoading(final IBlockAccess blockAccess, final int x, final int y, final int z) { + static public IBlockState getBlockState_noChunkLoading(final IBlockAccess blockAccess, final BlockPos blockPos) { // skip unloaded worlds if (blockAccess == null) { return null; } // skip unloaded chunks - if (!isChunkLoaded(blockAccess, x, z)) { + if (!isChunkLoaded(blockAccess, blockPos.getX(), blockPos.getZ())) { return null; } - return blockAccess.getBlockState(new BlockPos(x, y, z)); + return blockAccess.getBlockState(blockPos); } public TileEntity getTileEntity(final IBlockAccess blockAccess) {