/** * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 21, 2014, 9:18:28 PM (GMT)] */ package vazkii.botania.common.block.tile; import net.minecraft.block.state.IBlockState; 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; import net.minecraft.util.BlockPos; import net.minecraft.world.World; public class TileMod extends TileEntity { @Override public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) { // todo: review all subclasses. this could potentially leave stragglers hanging. // todo: example: open crate and crafty crate should refresh when variants change return oldState.getBlock() != newState.getBlock(); } @Override public void writeToNBT(NBTTagCompound par1nbtTagCompound) { super.writeToNBT(par1nbtTagCompound); writeCustomNBT(par1nbtTagCompound); } @Override public void readFromNBT(NBTTagCompound par1nbtTagCompound) { super.readFromNBT(par1nbtTagCompound); readCustomNBT(par1nbtTagCompound); } public void writeCustomNBT(NBTTagCompound cmp) { // NO-OP } public void readCustomNBT(NBTTagCompound cmp) { // NO-OP } @Override public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); writeCustomNBT(nbttagcompound); return new S35PacketUpdateTileEntity(pos, -999, nbttagcompound); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { super.onDataPacket(net, packet); readCustomNBT(packet.getNbtCompound()); } }