diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-04-19 03:30:08 +0100 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-04-19 03:30:08 +0100 |
| commit | 2a7e0a624f482a28af1c770dbcf2a20f52f94f78 (patch) | |
| tree | 39b7652b939dd20763e242fbd49eb6d2ad6924da /src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java | |
| parent | 9dc6f69f701e42b30adf7d1b01488f425eaec265 (diff) | |
Added Midas Touch
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java')
| -rw-r--r-- | src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java b/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java index f16c074..295a776 100644 --- a/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java +++ b/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java @@ -16,6 +16,21 @@ import net.minecraft.world.World; public class JewelryNBT { // TODO NBT Tag Adding + public static void addItem(ItemStack item, ItemStack target) + { + if (target != null){ + NBTTagCompound itemStackData; + if (item.hasTagCompound()) itemStackData = item.getTagCompound(); + else{ + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound targetNBT = new NBTTagCompound(); + target.writeToNBT(targetNBT); + itemStackData.setTag("target", targetNBT); + } + } + /** * @param item The item you want to add the NBT data on * @param metal The metal you want to add on the item @@ -448,6 +463,17 @@ public class JewelryNBT } // TODO Return components based on NBT + public static ItemStack item(ItemStack stack) + { + if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("target")){ + NBTTagCompound itemNBT = (NBTTagCompound)stack.getTagCompound().getTag("target"); + ItemStack target = new ItemStack(Item.getItemById(0), 0, 0); + target.readFromNBT(itemNBT); + return target; + } + return null; + } + /** * @param stack * @return |
