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/core/util | |
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/core/util')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java b/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java index 010016d5f1..64653f7c56 100644 --- a/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java +++ b/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java @@ -46,6 +46,26 @@ public class NBTUtils { } return inventory; } + + public static ItemStack[] readItemsFromNBT(ItemStack itemstack, String customkey){ + NBTTagCompound tNBT = getNBT(itemstack); + final NBTTagList list = tNBT.getTagList(customkey, 10); + ItemStack inventory[] = new ItemStack[list.tagCount()]; + for(int i = 0;i<list.tagCount();i++){ + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if((slot >= 0) && (slot < list.tagCount())){ + if (ItemStack.loadItemStackFromNBT(data) == ItemUtils.getSimpleStack(ZZZ_Empty)){ + inventory[slot] = null; + } + else { + inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + + } + } + return inventory; + } public static ItemStack writeItemsToNBT(ItemStack itemstack, ItemStack[] stored){ NBTTagCompound tNBT = getNBT(itemstack); @@ -70,6 +90,23 @@ public class NBTUtils { itemstack.setTagCompound(tNBT); return itemstack; } + + public static ItemStack writeItemsToNBT(ItemStack itemstack, ItemStack[] stored, String customkey){ + NBTTagCompound tNBT = getNBT(itemstack); + final NBTTagList list = new NBTTagList(); + for(int i = 0;i<stored.length;i++){ + final ItemStack stack = stored[i]; + if(stack != null){ + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + tNBT.setTag(customkey, list); + itemstack.setTagCompound(tNBT); + return itemstack; + } } |