diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java index d099e6ca9..b558ab98a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java @@ -129,7 +129,6 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ this.readSyncableNBT(compound, true); } - @Override public NBTTagCompound getUpdateTag(){ NBTTagCompound tag = super.getUpdateTag(); @@ -137,6 +136,11 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ return tag; } + @Override + public void handleUpdateTag(NBTTagCompound compound){ + this.receiveSyncCompound(compound); + } + public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ if(!isForSync){ compound.setBoolean("Redstone", this.isRedstonePowered); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java index b6f13a4ed..d4cd71a62 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java @@ -38,19 +38,15 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{ @Override public void receiveSyncCompound(NBTTagCompound compound){ - BlockPos thisPos = this.pos; - if(compound != null){ - LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(thisPos); + LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(this.pos); - NBTTagList list = compound.getTagList("Connections", 10); + NBTTagList list = compound.getTagList("Connections", 10); + if(!list.hasNoTags()){ for(int i = 0; i < list.tagCount(); i++){ LaserRelayConnectionHandler.ConnectionPair pair = LaserRelayConnectionHandler.ConnectionPair.readFromNBT(list.getCompoundTagAt(i)); LaserRelayConnectionHandler.getInstance().addConnection(pair.firstRelay, pair.secondRelay); } } - else{ - LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(thisPos); - } super.receiveSyncCompound(compound); } @@ -59,17 +55,16 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{ @Override public NBTTagCompound getUpdateTag(){ NBTTagCompound compound = super.getUpdateTag(); + NBTTagList list = new NBTTagList(); - BlockPos thisPos = this.pos; - ConcurrentSet connections = LaserRelayConnectionHandler.getInstance().getConnectionsFor(thisPos); - - if(connections != null){ - NBTTagList list = new NBTTagList(); + ConcurrentSet connections = LaserRelayConnectionHandler.getInstance().getConnectionsFor(this.pos); + if(connections != null && !connections.isEmpty()){ for(LaserRelayConnectionHandler.ConnectionPair pair : connections){ list.appendTag(pair.writeToNBT()); } - compound.setTag("Connections", list); } + + compound.setTag("Connections", list); return compound; } diff --git a/update/changelog.md b/update/changelog.md index 70605aac3..96dcef066 100644 --- a/update/changelog.md +++ b/update/changelog.md @@ -8,6 +8,7 @@ * Made shovels make path blocks instead of farmland * Changed world data save system to hopefully make laser relays not disconnect on certain occasions but only on the server and I don't get why this is happening * Made tools be held like tools and not like normal items in third person +* Fixed a syncing bug with tileentities on world join # 1.9.4-r36 * Added a config option to print all of the booklet's text into a file on startup