A whole lot of formatting cleanup
Also changes NBTHolder to a standard Constants class with subclasses for each category
This commit is contained in:
parent
f9802900db
commit
34dee6447b
74 changed files with 861 additions and 662 deletions
|
@ -19,12 +19,11 @@ import net.minecraft.world.World;
|
|||
|
||||
public class TileInventory extends TileEntity implements IInventory {
|
||||
|
||||
protected int[] syncedSlots = new int[0];
|
||||
private ItemStack[] inventory;
|
||||
private int size;
|
||||
private String name;
|
||||
|
||||
protected int[] syncedSlots = new int[0];
|
||||
|
||||
public TileInventory(int size, String name) {
|
||||
this.inventory = new ItemStack[size];
|
||||
this.size = size;
|
||||
|
@ -49,7 +48,7 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
if (!isSyncedSlot(i)) {
|
||||
NBTTagCompound data = tags.getCompoundTagAt(i);
|
||||
byte j = data.getByte("Slot") ;
|
||||
byte j = data.getByte("Slot");
|
||||
|
||||
if (j >= 0 && j < inventory.length) {
|
||||
inventory[j] = ItemStack.loadItemStackFromNBT(data);
|
||||
|
@ -75,6 +74,24 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
tagCompound.setTag("Items", tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return new S35PacketUpdateTileEntity(getPos(), -999, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
super.onDataPacket(net, pkt);
|
||||
readFromNBT(pkt.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) {
|
||||
return oldState.getBlock() != newState.getBlock();
|
||||
}
|
||||
|
||||
public void dropItems() {
|
||||
InventoryHelper.dropInventoryItems(getWorld(), getPos(), this);
|
||||
}
|
||||
|
@ -196,25 +213,4 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
public IChatComponent getDisplayName() {
|
||||
return new ChatComponentTranslation("tile.BloodMagic." + name + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return new S35PacketUpdateTileEntity(getPos(), -999, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
|
||||
{
|
||||
super.onDataPacket(net, pkt);
|
||||
readFromNBT(pkt.getNbtCompound());
|
||||
}
|
||||
|
||||
@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