From 4a3c589ca2a4bb513f6dd639312e566491341d3c Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 30 Apr 2019 10:20:28 +0200 Subject: [PATCH] Improved network usage by force field blocks --- .../warpdrive/block/forcefield/TileEntityForceField.java | 4 +++- .../block/forcefield/TileEntityForceFieldProjector.java | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java index ae74cee7..1d79d2ea 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java @@ -13,6 +13,7 @@ import javax.annotation.Nonnull; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; @@ -78,8 +79,9 @@ public class TileEntityForceField extends TileEntityAbstractBase { if (vProjector != null) { tagCompound.setTag("projector", vProjector.writeToNBT(new NBTTagCompound())); tagCompound.setInteger(IBeamFrequency.BEAM_FREQUENCY_TAG, cache_beamFrequency); - if (cache_blockStateCamouflage != null) { + if (cache_blockStateCamouflage != null && cache_blockStateCamouflage.getBlock() != Blocks.AIR) { final NBTTagCompound nbtCamouflage = new NBTTagCompound(); + assert cache_blockStateCamouflage.getBlock().getRegistryName() != null; nbtCamouflage.setString("block", cache_blockStateCamouflage.getBlock().getRegistryName().toString()); nbtCamouflage.setByte("meta", (byte) cache_blockStateCamouflage.getBlock().getMetaFromState(cache_blockStateCamouflage)); nbtCamouflage.setInteger("color", cache_colorMultiplierCamouflage); diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldProjector.java b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldProjector.java index c1fe47d6..35e6d81d 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldProjector.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceFieldProjector.java @@ -478,7 +478,10 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField // world.setBlockState(vector.getBlockPos(), tileEntityForceField.cache_blockStateCamouflage, 2); } else if (tileEntityForceFieldProjector == this) {// this is ours - if ( !tileEntityForceField.cache_blockStateCamouflage.equals(forceFieldSetup.getCamouflageBlockState()) + if ( ( tileEntityForceField.cache_blockStateCamouflage == null + && forceFieldSetup.getCamouflageBlockState() != null ) + || ( tileEntityForceField.cache_blockStateCamouflage != null + && !tileEntityForceField.cache_blockStateCamouflage.equals(forceFieldSetup.getCamouflageBlockState()) ) || !blockState.equals(blockStateForceField) ) { // camouflage changed while chunk wasn't loaded or de-synchronisation // force field downgraded during explosion