package crazypants.enderio;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
/**
* Created by CrazyPants on 27/02/14.
*/
public abstract class TileEntityEio extends TileEntity {
@Override
public final void readFromNBT(NBTTagCompound root) {
super.readFromNBT(root);
readCustomNBT(root);
}
@Override
public final void writeToNBT(NBTTagCompound root) {
super.writeToNBT(root);
writeCustomNBT(root);
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
writeCustomNBT(tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
readCustomNBT(pkt.func_148857_g());
}
protected abstract void writeCustomNBT(NBTTagCompound root);
protected abstract void readCustomNBT(NBTTagCompound root);
protected void updateBlock() {
if (worldObj != null) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}