Fixed a syncing bug with tileentities on world join

This commit is contained in:
Ellpeck 2016-06-04 00:26:33 +02:00
parent 6c94c08ba4
commit 7e682af51d
3 changed files with 14 additions and 14 deletions

View file

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

View file

@ -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);
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();
BlockPos thisPos = this.pos;
ConcurrentSet<LaserRelayConnectionHandler.ConnectionPair> connections = LaserRelayConnectionHandler.getInstance().getConnectionsFor(thisPos);
if(connections != null){
NBTTagList list = new NBTTagList();
ConcurrentSet<LaserRelayConnectionHandler.ConnectionPair> 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;
}

View file

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