diff options
Diffstat (limited to 'src/Java/gtPlusPlus/api/objects')
-rw-r--r-- | src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java b/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java index 25968f1908..43a325f190 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java @@ -3,6 +3,7 @@ package gtPlusPlus.api.objects.minecraft; import java.util.ArrayList; import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.tileentities.base.TileEntityBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; @@ -160,5 +161,47 @@ public class BTF_Inventory implements ISidedInventory{ return this.mTile != null ? mTile.getInventoryName() : ""; } + public boolean isFull() { + for (int s=0;s<this.getSizeInventory();s++) { + ItemStack slot = mInventory[s]; + if (slot == null || slot.stackSize != slot.getMaxStackSize()) { + return false; + } + } + return true; + } + + public boolean isEmpty() { + for (int s=0;s<this.getSizeInventory();s++) { + ItemStack slot = mInventory[s]; + if (slot == null) { + continue; + } + else { + return false; + } + } + return true; + } + + public boolean addItemStack(ItemStack aInput) { + if (isEmpty() || !isFull()) { + for (int s = 0; s < this.getSizeInventory(); s++) { + ItemStack slot = mInventory[s]; + if (slot == null + || (GT_Utility.areStacksEqual(aInput, slot) && slot.stackSize != slot.getMaxStackSize())) { + if (slot == null) { + slot = aInput.copy(); + } else { + slot.stackSize++; + } + this.setInventorySlotContents(s, slot); + return true; + } + } + } + return false; + } + } |