/**
* This class was created by <Vazkii>. 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 javax.annotation.Nonnull;
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.ITickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class TileMod extends TileEntity implements ITickable {
@Override
public boolean shouldRefresh(World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState) {
return oldState.getBlock() != newState.getBlock();
}
@Nonnull
@Override
public NBTTagCompound writeToNBT(NBTTagCompound par1nbtTagCompound) {
NBTTagCompound ret = super.writeToNBT(par1nbtTagCompound);
writePacketNBT(ret);
return ret;
}
@Nonnull
@Override
public final NBTTagCompound getUpdateTag() {
return writeToNBT(new NBTTagCompound());
}
@Override
public void readFromNBT(NBTTagCompound par1nbtTagCompound) {
super.readFromNBT(par1nbtTagCompound);
readPacketNBT(par1nbtTagCompound);
}
public void writePacketNBT(NBTTagCompound cmp) {}
public void readPacketNBT(NBTTagCompound cmp) {}
@Override
public final SPacketUpdateTileEntity getUpdatePacket() {
NBTTagCompound tag = new NBTTagCompound();
writePacketNBT(tag);
return new SPacketUpdateTileEntity(pos, -999, tag);
}
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
super.onDataPacket(net, packet);
readPacketNBT(packet.getNbtCompound());
}
@Override
public void update() {}
}