Minecraft update packets are stupid.

Closes #203.
Again.
This commit is contained in:
Ellpeck 2016-08-14 11:43:59 +02:00
parent ba4f4252e0
commit 3c727542ac

View file

@ -132,13 +132,11 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
@Override @Override
public void readFromNBT(NBTTagCompound compound){ public void readFromNBT(NBTTagCompound compound){
super.readFromNBT(compound);
this.readSyncableNBT(compound, NBTType.SAVE_TILE); this.readSyncableNBT(compound, NBTType.SAVE_TILE);
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound compound){ public NBTTagCompound writeToNBT(NBTTagCompound compound){
compound = super.writeToNBT(compound);
this.writeSyncableNBT(compound, NBTType.SAVE_TILE); this.writeSyncableNBT(compound, NBTType.SAVE_TILE);
return compound; return compound;
} }
@ -155,10 +153,9 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
} }
@Override @Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt){ public final void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt){
if(pkt != null){ if(pkt != null){
NBTTagCompound compound = pkt.getNbtCompound(); NBTTagCompound compound = pkt.getNbtCompound();
this.readFromNBT(compound);
this.receiveSyncCompound(compound); this.receiveSyncCompound(compound);
} }
} }
@ -169,14 +166,13 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
@Override @Override
public NBTTagCompound getUpdateTag(){ public NBTTagCompound getUpdateTag(){
NBTTagCompound tag = super.getUpdateTag(); NBTTagCompound compound = new NBTTagCompound();
this.writeSyncableNBT(tag, NBTType.SYNC); this.writeSyncableNBT(compound, NBTType.SYNC);
return tag; return compound;
} }
@Override @Override
public void handleUpdateTag(NBTTagCompound compound){ public final void handleUpdateTag(NBTTagCompound compound){
super.handleUpdateTag(compound);
this.receiveSyncCompound(compound); this.receiveSyncCompound(compound);
} }
@ -186,6 +182,8 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
} }
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
super.writeToNBT(compound);
if(type == NBTType.SAVE_TILE){ if(type == NBTType.SAVE_TILE){
compound.setBoolean("Redstone", this.isRedstonePowered); compound.setBoolean("Redstone", this.isRedstonePowered);
compound.setInteger("TicksElapsed", this.ticksElapsed); compound.setInteger("TicksElapsed", this.ticksElapsed);
@ -201,6 +199,8 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
} }
public void readSyncableNBT(NBTTagCompound compound, NBTType type){ public void readSyncableNBT(NBTTagCompound compound, NBTType type){
super.readFromNBT(compound);
if(type == NBTType.SAVE_TILE){ if(type == NBTType.SAVE_TILE){
this.isRedstonePowered = compound.getBoolean("Redstone"); this.isRedstonePowered = compound.getBoolean("Redstone");
this.ticksElapsed = compound.getInteger("TicksElapsed"); this.ticksElapsed = compound.getInteger("TicksElapsed");