Just about finished inventory management, onto logistics
This commit is contained in:
parent
afb563898a
commit
0bb73d5183
1 changed files with 58 additions and 2 deletions
|
@ -82,6 +82,7 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
//Main inventory
|
||||
NBTTagList tagList = nbtTags.getTagList("Items");
|
||||
structure.inventory = new HashSet<ItemStack>();
|
||||
|
||||
|
@ -91,6 +92,21 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
|
||||
structure.inventory.add(ItemStack.loadItemStackFromNBT(tagCompound));
|
||||
}
|
||||
|
||||
//Visible inventory
|
||||
NBTTagList tagList1 = nbtTags.getTagList("VisibleItems");
|
||||
structure.visibleInventory = new ItemStack[3];
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList1.tagCount(); tagCount++)
|
||||
{
|
||||
NBTTagCompound tagCompound = (NBTTagCompound)tagList1.tagAt(tagCount);
|
||||
byte slotID = tagCompound.getByte("Slot");
|
||||
|
||||
if(slotID >= 0 && slotID < structure.visibleInventory.length)
|
||||
{
|
||||
setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -98,6 +114,7 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
//Inventory
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for(ItemStack itemStack : structure.inventory)
|
||||
|
@ -111,6 +128,22 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
}
|
||||
|
||||
nbtTags.setTag("Items", tagList);
|
||||
|
||||
//Visible inventory
|
||||
NBTTagList tagList1 = new NBTTagList();
|
||||
|
||||
for(int slotCount = 0; slotCount < structure.visibleInventory.length; slotCount++)
|
||||
{
|
||||
if(getStackInSlot(slotCount) != null)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte)slotCount);
|
||||
getStackInSlot(slotCount).writeToNBT(tagCompound);
|
||||
tagList1.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
nbtTags.setTag("VisibleItems", tagList1);
|
||||
}
|
||||
|
||||
public void update()
|
||||
|
@ -246,10 +279,33 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j)
|
||||
public ItemStack decrStackSize(int slotID, int amount)
|
||||
{
|
||||
if(getStackInSlot(slotID) != null)
|
||||
{
|
||||
ItemStack tempStack;
|
||||
|
||||
if(getStackInSlot(slotID).stackSize <= amount)
|
||||
{
|
||||
tempStack = getStackInSlot(slotID);
|
||||
setInventorySlotContents(slotID, null);
|
||||
return tempStack;
|
||||
}
|
||||
else {
|
||||
tempStack = getStackInSlot(slotID).splitStack(amount);
|
||||
|
||||
if(getStackInSlot(slotID).stackSize == 0)
|
||||
{
|
||||
setInventorySlotContents(slotID, null);
|
||||
}
|
||||
|
||||
return tempStack;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i)
|
||||
|
|
Loading…
Reference in a new issue