diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingBase.java b/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingBase.java index 9a62a23..f7960eb 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingBase.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingBase.java @@ -113,8 +113,10 @@ public void readFromNBT(NBTTagCompound tag) { @Nonnull public NBTTagCompound writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); - tag.setTag("BlockTag", block); - tag.setTag("DescTag", desc); + if (block != null) + tag.setTag("BlockTag", block); + if (desc != null) + tag.setTag("DescTag", desc); tag.setInteger("Time", time); tag.setInteger("MaxTime", maxTime); tag.setByte("Dir", (byte) dir); diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingServer.java b/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingServer.java index 2fc65e4..d280cbb 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingServer.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingServer.java @@ -1,5 +1,7 @@ package com.rwtema.funkylocomotion.blocks; +import java.lang.ref.WeakReference; +import javax.annotation.Nonnull; import com.rwtema.funkylocomotion.movers.MoverEventHandler; import com.rwtema.funkylocomotion.movers.MovingTileRegistry; import net.minecraft.entity.player.EntityPlayer; @@ -8,9 +10,6 @@ import net.minecraft.util.EnumHand; import net.minecraftforge.fml.relauncher.Side; -import javax.annotation.Nonnull; -import java.lang.ref.WeakReference; - public class TileMovingServer extends TileMovingBase { public WeakReference activatingPlayer = null; @@ -26,25 +25,23 @@ public TileMovingServer() { @Override @Nonnull public NBTTagCompound getUpdateTag() { - if (desc == null) + if (this.desc == null) return super.getUpdateTag(); - super.writeToNBT(desc); - - desc.setInteger("Time", time); - desc.setInteger("MaxTime", maxTime); - desc.setByte("Dir", (byte) dir); + this.desc.setInteger("Time", this.time); + this.desc.setInteger("MaxTime", this.maxTime); + this.desc.setByte("Dir", (byte) this.dir); - if (lightLevel > 0) - desc.setByte("Light", (byte) lightLevel); - if (lightOpacity > 0) - desc.setShort("Opacity", (short) lightOpacity); - - if (collisions.length > 0) { - desc.setTag("Collisions", TagsAxis(collisions)); - } + if (this.block != null) + this.desc.setTag("BlockTag", this.block); + if (this.collisions.length > 0) + this.desc.setTag("Collisions", TagsAxis(this.collisions)); + if (this.lightLevel != 0) + this.desc.setByte("Light", (byte) this.lightLevel); + if (this.lightOpacity != 0) + this.desc.setShort("Opacity", (short) this.lightOpacity); - return desc; + return this.desc; } @Override