aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlkalus <draknyte1@hotmail.com>2017-09-13 09:31:19 +1000
committerAlkalus <draknyte1@hotmail.com>2017-09-13 09:31:19 +1000
commit53b16ceecf633f0a95f82e047dc78bf581bd440e (patch)
tree746172df105f569b58b01fa51ed841810c944603 /src
parent4d6b6fad4c86912b72ccbe6b01f8d68b48451c2b (diff)
downloadGT5-Unofficial-53b16ceecf633f0a95f82e047dc78bf581bd440e.tar.gz
GT5-Unofficial-53b16ceecf633f0a95f82e047dc78bf581bd440e.tar.bz2
GT5-Unofficial-53b16ceecf633f0a95f82e047dc78bf581bd440e.zip
+ Made the Auto-Crafter use power in Crafting mode.
+ Added writeItemsToGtCraftingComponents to add disassembler info to itemstacks in NBTUtils.java
Diffstat (limited to 'src')
-rw-r--r--src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java29
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GT4Entity_AutoCrafter.java158
2 files changed, 116 insertions, 71 deletions
diff --git a/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java b/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java
index 64653f7c56..2d76742e38 100644
--- a/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java
+++ b/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java
@@ -2,6 +2,8 @@ package gtPlusPlus.core.util.nbt;
import static gtPlusPlus.core.item.ModItems.ZZZ_Empty;
+import gregtech.api.items.GT_MetaGenerated_Tool;
+import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.item.ModItems;
import gtPlusPlus.core.util.item.ItemUtils;
@@ -107,6 +109,33 @@ public class NBTUtils {
itemstack.setTagCompound(tNBT);
return itemstack;
}
+
+ public static ItemStack writeItemsToGtCraftingComponents(ItemStack rStack, ItemStack[] stored, boolean copyTags){
+
+ if (copyTags){
+ for (int i = 0; i < stored.length; i++) {
+ if (stored[i] != null && stored[i].hasTagCompound()) {
+ rStack.setTagCompound((NBTTagCompound) stored[i].getTagCompound().copy());
+ break;
+ }
+ }
+ }
+
+ NBTTagCompound rNBT = rStack.getTagCompound(), tNBT = new NBTTagCompound();
+ if (rNBT == null) rNBT = new NBTTagCompound();
+ for (int i = 0; i < 9; i++) {
+ ItemStack tStack = stored[i];
+ if (tStack != null && GT_Utility.getContainerItem(tStack, true) == null && !(tStack.getItem() instanceof GT_MetaGenerated_Tool)) {
+ tStack = GT_Utility.copyAmount(1, tStack);
+ if(GT_Utility.isStackValid(tStack)){
+ GT_ModHandler.dischargeElectricItem(tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true);
+ tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound()));}
+ }
+ }
+ rNBT.setTag("GT.CraftingComponents", tNBT);
+ rStack.setTagCompound(rNBT);
+ return rStack;
+ }
}
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 54c350ba36..8ea0db5e82 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
@@ -402,101 +402,117 @@ extends GT_MetaTileEntity_MultiBlockBase
//Read stored data from encrypter data stick.
ItemStack storedData_Output[] = NBTUtils.readItemsFromNBT(aStack, "Output");
ItemStack storedData_Input[] = NBTUtils.readItemsFromNBT(aStack);
- ItemStack loadedData[] = new ItemStack[9];
- if (storedData_Input.length >= 1){
- int number = 0;
- 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;
- //ContainerWorkbench.craftMatrix.setInventorySlotContents(number, null);
- //ContainerWorkbench.craftMatrix.markDirty();
- }
- else {
- Utils.LOG_INFO("Downloading "+a.getDisplayName()+" into crafting manager slot "+number+".");
- loadedData[number] = a;
- //ContainerWorkbench.craftMatrix.setInventorySlotContents(number, a);
- //ContainerWorkbench.craftMatrix.markDirty();
+ if (storedData_Output != null && storedData_Input != null){
+ this.mEUt = 16 * (1 << this.mTier - 1) * (1 << this.mTier - 1);
+ this.mMaxProgresstime = (100-(8*this.mTier));
+
+
+
+
+ ItemStack loadedData[] = new ItemStack[9];
+ if (storedData_Input.length >= 1){
+ int number = 0;
+ 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;
+ //ContainerWorkbench.craftMatrix.setInventorySlotContents(number, null);
+ //ContainerWorkbench.craftMatrix.markDirty();
+ }
+ else {
+ Utils.LOG_INFO("Downloading "+a.getDisplayName()+" into crafting manager slot "+number+".");
+ loadedData[number] = a;
+ //ContainerWorkbench.craftMatrix.setInventorySlotContents(number, a);
+ //ContainerWorkbench.craftMatrix.markDirty();
+ }
+ number++;
}
- 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+".");
+ 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+".");
- //ContainerWorkbench.craftMatrix.setInventorySlotContents(number, null);
- //ContainerWorkbench.craftMatrix.markDirty();
- }
- else {
- Utils.LOG_INFO("Downloading "+a.getDisplayName()+" into crafting manager Output slot "+number+".");
+ //ContainerWorkbench.craftMatrix.setInventorySlotContents(number, null);
+ //ContainerWorkbench.craftMatrix.markDirty();
+ }
+ else {
+ Utils.LOG_INFO("Downloading "+a.getDisplayName()+" into crafting manager Output slot "+number+".");
- //ContainerWorkbench.craftMatrix.setInventorySlotContents(number, a);
- //ContainerWorkbench.craftMatrix.markDirty();
+ //ContainerWorkbench.craftMatrix.setInventorySlotContents(number, a);
+ //ContainerWorkbench.craftMatrix.markDirty();
+ }
+ number++;
}
- number++;
}
- }
- boolean areInputsCorrect[] = new boolean[9];
- int counter=0;
- for (ItemStack inputItem : loadedData){
- Utils.LOG_INFO("Required Input Iteration. Size: "+loadedData.length);
- if (inputItem == null){
- Utils.LOG_INFO("Require Input was null setting to true. ["+counter+"]");
- areInputsCorrect[counter] = true;
- }
- else if (inputItem != null){
- //Check input busses for recipe components
- for (GT_MetaTileEntity_Hatch_InputBus x : this.mInputBusses){
- Utils.LOG_INFO("Input Bus Iteration. Looking for "+inputItem.getDisplayName());
- if (x.mInventory.length > 0){
- for (ItemStack r : x.mInventory){
- if (r != null){
- Utils.LOG_INFO("Input Bus Inventory Iteration - Found:" +r.getDisplayName());
- if (GT_Utility.areStacksEqual(r, inputItem)){
- this.depleteInput(inputItem);
- areInputsCorrect[counter] = true;
- Utils.LOG_INFO("Require Input was found setting to true. ["+counter+"]");
+ boolean areInputsCorrect[] = new boolean[9];
+ int counter=0;
+ for (ItemStack inputItem : loadedData){
+ Utils.LOG_INFO("Required Input Iteration. Size: "+loadedData.length);
+ if (inputItem == null){
+ Utils.LOG_INFO("Require Input was null setting to true. ["+counter+"]");
+ areInputsCorrect[counter] = true;
+ }
+ else if (inputItem != null){
+ //Check input busses for recipe components
+ for (GT_MetaTileEntity_Hatch_InputBus x : this.mInputBusses){
+ Utils.LOG_INFO("Input Bus Iteration. Looking for "+inputItem.getDisplayName());
+ if (x.mInventory.length > 0){
+ for (ItemStack r : x.mInventory){
+ if (r != null){
+ Utils.LOG_INFO("Input Bus Inventory Iteration - Found:" +r.getDisplayName());
+ if (GT_Utility.areStacksEqual(r, inputItem)){
+ this.depleteInput(inputItem);
+ areInputsCorrect[counter] = true;
+ Utils.LOG_INFO("Require Input was found setting to true. ["+counter+"]");
+ }
}
}
}
}
- }
- }
- counter++;
- }
- int mCorrectInputs=0;
- for (boolean isValid : areInputsCorrect){
- if (isValid){
- mCorrectInputs++;
+ }
+ counter++;
}
- else {
- Utils.LOG_INFO("Input in Slot "+mCorrectInputs+" was not valid.");
+ if (this.mTier > 5) {
+ this.mMaxProgresstime >>= this.mTier - 5;
}
- }
- if (mCorrectInputs == 9){
- this.addOutput(storedData_Output[0]);
- }
+ int mCorrectInputs=0;
+ for (boolean isValid : areInputsCorrect){
+ if (isValid){
+ mCorrectInputs++;
+ }
+ else {
+ //Utils.LOG_INFO("Input in Slot "+mCorrectInputs+" was not valid.");
+ }
+ }
+ if (mCorrectInputs == 9){
+ ItemStack mOutputItem = storedData_Output[0];
+ NBTUtils.writeItemsToGtCraftingComponents(mOutputItem, loadedData, true);
+ this.addOutput(mOutputItem);
+ }
+ else {
+ this.mMaxProgresstime = 0;
+ }
- //if the are all found remove inputs
- //if they are all found produce output
+ //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());
- //Utils.LOG_INFO("Crafting Grid Result: "+ContainerWorkbench.craftResult.getStackInSlot(0));
+ //Do Crafting
+ //Utils.LOG_INFO("Crafting Grid Size: "+ContainerWorkbench.craftMatrix.getSizeInventory());
+ //Utils.LOG_INFO("Crafting Grid Result: "+ContainerWorkbench.craftResult.getSizeInventory());
+ //Utils.LOG_INFO("Crafting Grid Result: "+ContainerWorkbench.craftResult.getStackInSlot(0));
+ }
}