package lumaceon.mods.clockworkphase2.tile.generic; import net.minecraft.block.state.IBlockState; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public abstract class TileMod extends TileEntity { public void writeCustomNBT(NBTTagCompound nbt) { writeToNBT(nbt); } public void readCustomNBT(NBTTagCompound nbt) { readFromNBT(nbt); } @Override public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) { return (oldState.getBlock() != newSate.getBlock()); } @Override public SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); writeCustomNBT(nbttagcompound); return new SPacketUpdateTileEntity(this.getPos(), -999, nbttagcompound); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); readCustomNBT(pkt.getNbtCompound()); } }