diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-10-03 18:08:43 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-10-03 18:08:43 +1000 |
commit | bdb6fc4a5410d68cf517dbe90fa49cec45bbda5a (patch) | |
tree | d345344fe061e07bca20357b18457c0b9fdf475b /src/Java/gtPlusPlus/core/inventories | |
parent | e56e3fa33d84ca19a3fb0c5e72a60212f30660a7 (diff) | |
download | GT5-Unofficial-bdb6fc4a5410d68cf517dbe90fa49cec45bbda5a.tar.gz GT5-Unofficial-bdb6fc4a5410d68cf517dbe90fa49cec45bbda5a.tar.bz2 GT5-Unofficial-bdb6fc4a5410d68cf517dbe90fa49cec45bbda5a.zip |
% Gotta Re-merge these Changes with those made on my laptop.
Diffstat (limited to 'src/Java/gtPlusPlus/core/inventories')
3 files changed, 39 insertions, 12 deletions
diff --git a/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchChest.java b/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchChest.java index 569f99b078..8d147ad21c 100644 --- a/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchChest.java +++ b/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchChest.java @@ -146,7 +146,12 @@ public class InventoryWorkbenchChest implements IInventory{ { for (int i = 0; i < getSizeInventory(); ++i) { - if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) { + ItemStack temp = getStackInSlot(i); + if (temp != null){ + //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if (temp != null && temp.stackSize == 0) { inventory[i] = null; } } diff --git a/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchCrafting.java b/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchCrafting.java index 72454d75ed..333bb5c847 100644 --- a/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchCrafting.java +++ b/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchCrafting.java @@ -1,7 +1,9 @@ package gtPlusPlus.core.inventories; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -15,13 +17,30 @@ public class InventoryWorkbenchCrafting implements IInventory{ /** Inventory's size must be same as number of slots you add to the Container class */ private ItemStack[] inventory = new ItemStack[INV_SIZE]; + public final InventoryCrafting craftMatrix; + public final Container parentContainer; + + public InventoryCrafting getCrafting(){ + return craftMatrix; + } /** * @param itemstack - the ItemStack to which this inventory belongs */ - public InventoryWorkbenchCrafting() + public InventoryWorkbenchCrafting(Container containerR) { - + this.parentContainer = containerR; + this.craftMatrix = new InventoryCrafting(parentContainer, 3, 3); + } + + private ItemStack[] getArrayOfCraftingItems(){ + ItemStack[] array = new ItemStack[9]; + for (int i=0; i<craftMatrix.getSizeInventory();i++){ + if(craftMatrix.getStackInSlot(i) != null){ + array[i] = craftMatrix.getStackInSlot(i); + } + } + return array; } public void readFromNBT(NBTTagCompound nbt) @@ -34,7 +53,7 @@ public class InventoryWorkbenchCrafting implements IInventory{ int slot = data.getInteger("Slot"); if(slot >= 0 && slot < INV_SIZE) { - inventory[slot] = ItemStack.loadItemStackFromNBT(data); + getInventory()[slot] = ItemStack.loadItemStackFromNBT(data); } } } @@ -44,7 +63,7 @@ public class InventoryWorkbenchCrafting implements IInventory{ NBTTagList list = new NBTTagList(); for(int i = 0;i<INV_SIZE;i++) { - ItemStack stack = inventory[i]; + ItemStack stack = getInventory()[i]; if(stack != null) { NBTTagCompound data = new NBTTagCompound(); @@ -59,17 +78,17 @@ public class InventoryWorkbenchCrafting implements IInventory{ @Override public int getSizeInventory() { - return inventory.length; + return getInventory().length; } public ItemStack[] getInventory(){ - return inventory; + return getArrayOfCraftingItems(); } @Override public ItemStack getStackInSlot(int slot) { - return inventory[slot]; + return getInventory()[slot]; } @Override @@ -104,7 +123,7 @@ public class InventoryWorkbenchCrafting implements IInventory{ @Override public void setInventorySlotContents(int slot, ItemStack stack) { - inventory[slot] = stack; + getInventory()[slot] = stack; if (stack != null && stack.stackSize > getInventoryStackLimit()) { @@ -147,7 +166,7 @@ public class InventoryWorkbenchCrafting implements IInventory{ for (int i = 0; i < getSizeInventory(); ++i) { if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) { - inventory[i] = null; + getInventory()[i] = null; } } } diff --git a/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchTools.java b/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchTools.java index 00ecd94574..7e3e7c3aef 100644 --- a/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchTools.java +++ b/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchTools.java @@ -1,6 +1,6 @@ package gtPlusPlus.core.inventories; -import gregtech.api.interfaces.IToolStats; +import gregtech.api.items.GT_MetaGenerated_Tool; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -178,7 +178,10 @@ public class InventoryWorkbenchTools implements IInventory{ // Don't want to be able to store the inventory item within itself // Bad things will happen, like losing your inventory // Actually, this needs a custom Slot to work - return (itemstack.getItem() instanceof IToolStats); + if (itemstack.getItem() instanceof GT_MetaGenerated_Tool){ + return true; + } + return false; } }
\ No newline at end of file |