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
|
@ -4,19 +4,12 @@ import WayofTime.bloodmagic.api.soul.DemonWillHolder;
|
|||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWillConduit;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import WayofTime.bloodmagic.tile.base.TileTicking;
|
||||
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.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileDemonPylon extends TileEntity implements ITickable, IDemonWillConduit
|
||||
public class TileDemonPylon extends TileTicking implements IDemonWillConduit
|
||||
{
|
||||
public DemonWillHolder holder = new DemonWillHolder();
|
||||
public final int maxWill = 100;
|
||||
|
@ -28,7 +21,7 @@ public class TileDemonPylon extends TileEntity implements ITickable, IDemonWillC
|
|||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
public void onUpdate()
|
||||
{
|
||||
if (worldObj.isRemote)
|
||||
{
|
||||
|
@ -54,7 +47,7 @@ public class TileDemonPylon extends TileEntity implements ITickable, IDemonWillC
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
public void deserialize(NBTTagCompound tag)
|
||||
{
|
||||
super.readFromNBT(tag);
|
||||
|
||||
|
@ -62,10 +55,8 @@ public class TileDemonPylon extends TileEntity implements ITickable, IDemonWillC
|
|||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag)
|
||||
public NBTTagCompound serialize(NBTTagCompound tag)
|
||||
{
|
||||
super.writeToNBT(tag);
|
||||
|
||||
holder.writeToNBT(tag, "Will");
|
||||
return tag;
|
||||
}
|
||||
|
@ -134,38 +125,4 @@ public class TileDemonPylon extends TileEntity implements ITickable, IDemonWillC
|
|||
{
|
||||
return holder.getWill(type);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState)
|
||||
{
|
||||
return oldState.getBlock() != newState.getBlock();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue