diff options
author | Alkalus <draknyte1@hotmail.com> | 2017-09-13 09:31:19 +1000 |
---|---|---|
committer | Alkalus <draknyte1@hotmail.com> | 2017-09-13 09:31:19 +1000 |
commit | 53b16ceecf633f0a95f82e047dc78bf581bd440e (patch) | |
tree | 746172df105f569b58b01fa51ed841810c944603 /src/Java/gtPlusPlus/core | |
parent | 4d6b6fad4c86912b72ccbe6b01f8d68b48451c2b (diff) | |
download | GT5-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.java | 29 |
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; + } } |