Improved network usage by force field blocks

This commit is contained in:
Unknown 2019-04-30 10:20:28 +02:00 committed by unknown
parent 7df1fb97a4
commit 4a3c589ca2
2 changed files with 7 additions and 2 deletions

View file

@ -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);

View file

@ -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