aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core
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/Java/gtPlusPlus/core
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/Java/gtPlusPlus/core')
-rw-r--r--src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java29
1 files changed, 29 insertions, 0 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;
+ }
}