diff options
author | Alkalus <draknyte1@hotmail.com> | 2017-09-12 17:04:35 +1000 |
---|---|---|
committer | Alkalus <draknyte1@hotmail.com> | 2017-09-12 17:04:35 +1000 |
commit | cdc728c5b606d6d3d49dce77c18f875a1f8379c6 (patch) | |
tree | 8e48d0e8fe2aa88547b9a00b56bce51a3022ea3f /src/Java/gtPlusPlus/xmod/gregtech | |
parent | 72905a7d18b0c5fca8a8edf3ed38b17d7f11f415 (diff) | |
download | GT5-Unofficial-cdc728c5b606d6d3d49dce77c18f875a1f8379c6.tar.gz GT5-Unofficial-cdc728c5b606d6d3d49dce77c18f875a1f8379c6.tar.bz2 GT5-Unofficial-cdc728c5b606d6d3d49dce77c18f875a1f8379c6.zip |
+ Auto Crafter now consumes items when found for a recipe.
+ Auto Crafter now outputs item when all 9 inputs are valid.
+ Added Read & Write to NBT functions to NBTUtils class.
% Project Table now stores inputs and output to a Data Stick.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech')
-rw-r--r-- | src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GT4Entity_AutoCrafter.java | 68 |
1 files changed, 61 insertions, 7 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GT4Entity_AutoCrafter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GT4Entity_AutoCrafter.java index 2902e6fc93..b1310db0bd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GT4Entity_AutoCrafter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GT4Entity_AutoCrafter.java @@ -210,7 +210,7 @@ extends GT_MetaTileEntity_MultiBlockBase return false; } - mInventoryCrafter = new CraftingHelper(this); + //mInventoryCrafter = new CraftingHelper(this); return tAmount >= 16; } @@ -267,11 +267,12 @@ extends GT_MetaTileEntity_MultiBlockBase } //Read stored data from encrypter data stick. - ItemStack storedData[] = NBTUtils.readItemsFromNBT(aStack); + ItemStack storedData_Output[] = NBTUtils.readItemsFromNBT(aStack, "Output"); + ItemStack storedData_Input[] = NBTUtils.readItemsFromNBT(aStack); ItemStack loadedData[] = new ItemStack[9]; - if (storedData.length >= 1){ + if (storedData_Input.length >= 1){ int number = 0; - for (ItemStack a : storedData){ + for (ItemStack a : storedData_Input){ if (a.getItem() == ModItems.ZZZ_Empty){ Utils.LOG_INFO("Allocating free memory into crafting manager slot "+number+"."); loadedData[number] = null; @@ -287,12 +288,65 @@ extends GT_MetaTileEntity_MultiBlockBase number++; } } + + if (storedData_Output.length >= 1){ + int number = 0; + for (ItemStack a : storedData_Output){ + if (a.getItem() == ModItems.ZZZ_Empty){ + Utils.LOG_INFO("Allocating free memory into crafting manager Output slot "+number+"."); + loadedData[number] = null; + //ContainerWorkbench.craftMatrix.setInventorySlotContents(number, null); + //ContainerWorkbench.craftMatrix.markDirty(); + } + else { + Utils.LOG_INFO("Downloading "+a.getDisplayName()+" into crafting manager Output slot "+number+"."); + loadedData[number] = a; + //ContainerWorkbench.craftMatrix.setInventorySlotContents(number, a); + //ContainerWorkbench.craftMatrix.markDirty(); + } + number++; + } + } + + boolean areInputsCorrect[] = new boolean[9]; + int counter=0; + for (ItemStack inputItem : loadedData){ + + if (inputItem == null){ + areInputsCorrect[counter] = true; + } + + //Check input busses for recipe components + for (GT_MetaTileEntity_Hatch_InputBus x : this.mInputBusses){ + if (x.mInventory.length > 0){ + for (ItemStack r : x.mInventory){ + if (r == inputItem){ + this.depleteInput(inputItem); + areInputsCorrect[counter] = true; + } + } + } + } + counter++; + } + + int mCorrectInputs=0; + for (boolean isValid : areInputsCorrect){ + if (isValid){ + mCorrectInputs++; + } + } - if (mInventoryCrafter != null){ - Utils.LOG_INFO("Now crafting with "+mInventoryCrafter.mInventoryName); - this.mInventoryCrafter.inventory.putItemsIntoGrid(loadedData); + if (mCorrectInputs == 9){ + this.addOutput(storedData_Output[0]); } + + //if the are all found remove inputs + + //if they are all found produce output + + //Do Crafting //Utils.LOG_INFO("Crafting Grid Size: "+ContainerWorkbench.craftMatrix.getSizeInventory()); //Utils.LOG_INFO("Crafting Grid Result: "+ContainerWorkbench.craftResult.getSizeInventory()); |