2019-07-11 19:55:11 +02:00
|
|
|
package com.simibubi.create.utility;
|
|
|
|
|
|
|
|
import net.minecraft.nbt.CompoundNBT;
|
|
|
|
import net.minecraft.network.NetworkManager;
|
|
|
|
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.tileentity.TileEntityType;
|
|
|
|
|
|
|
|
public abstract class TileEntitySynced extends TileEntity {
|
|
|
|
|
|
|
|
public TileEntitySynced(TileEntityType<?> tileEntityTypeIn) {
|
|
|
|
super(tileEntityTypeIn);
|
|
|
|
}
|
|
|
|
|
2019-07-16 16:01:51 +02:00
|
|
|
@Override
|
|
|
|
public CompoundNBT getTileData() {
|
|
|
|
return super.getTileData();
|
|
|
|
}
|
|
|
|
|
2019-07-11 19:55:11 +02:00
|
|
|
@Override
|
|
|
|
public CompoundNBT getUpdateTag() {
|
|
|
|
return write(new CompoundNBT());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void handleUpdateTag(CompoundNBT tag) {
|
|
|
|
read(tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public SUpdateTileEntityPacket getUpdatePacket(){
|
2019-07-16 16:01:51 +02:00
|
|
|
return new SUpdateTileEntityPacket(getPos(), 1, writeToClient(new CompoundNBT()));
|
2019-07-11 19:55:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt){
|
2019-07-16 16:01:51 +02:00
|
|
|
readClientUpdate(pkt.getNbtCompound());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Special handling for client update packets
|
|
|
|
public void readClientUpdate(CompoundNBT tag) {
|
|
|
|
read(tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Special handling for client update packets
|
|
|
|
public CompoundNBT writeToClient(CompoundNBT tag) {
|
|
|
|
return write(tag);
|
2019-07-11 19:55:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|