Clean up TE implementations
Offload some work to base classes that provide some helpers TODO: Implementations for Inventories (using caps) and ticking tiles with inventories.
This commit is contained in:
parent
4d331aa758
commit
798bad5583
23 changed files with 280 additions and 493 deletions
|
@ -1,15 +1,11 @@
|
|||
package WayofTime.bloodmagic.tile;
|
||||
|
||||
import WayofTime.bloodmagic.tile.base.TileBase;
|
||||
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.EnumFacing;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileBloodTank extends TileEntity implements IFluidHandler
|
||||
public class TileBloodTank extends TileBase implements IFluidHandler
|
||||
{
|
||||
public static int capacity;
|
||||
public FluidTank tank;
|
||||
|
@ -57,7 +53,7 @@ public class TileBloodTank extends TileEntity implements IFluidHandler
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
public void deserialize(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
tank.readFromNBT(tagCompound.getCompoundTag("tank"));
|
||||
|
@ -65,40 +61,11 @@ public class TileBloodTank extends TileEntity implements IFluidHandler
|
|||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
public NBTTagCompound serialize(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeToNBT(tagCompound);
|
||||
if (tank.getFluidAmount() != 0)
|
||||
tagCompound.setTag("tank", tank.writeToNBT(new NBTTagCompound()));
|
||||
tagCompound.setInteger("capacity", capacity);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SPacketUpdateTileEntity getUpdatePacket()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return new SPacketUpdateTileEntity(getPos(), -999, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
|
||||
{
|
||||
super.onDataPacket(net, pkt);
|
||||
readFromNBT(pkt.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getUpdateTag()
|
||||
{
|
||||
return writeToNBT(new NBTTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUpdateTag(NBTTagCompound tag)
|
||||
{
|
||||
readFromNBT(tag);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue