From 857d548f591b8f3770befd2535985959fd870474 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 22 Aug 2019 21:14:31 -0400 Subject: Begin implementing affix mods --- .../darkknight/jewelrycraft/util/JewelryNBT.java | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java') diff --git a/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java b/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java index 17090ab..d7eff3a 100755 --- a/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java +++ b/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java @@ -70,6 +70,48 @@ public class JewelryNBT { itemStackData.setTag("gem", gemNBT); } } + + /** + * @param item + * The item you want to add the NBT data on + * @param prefix + * The prefix you want to add on the item + */ + public static void addPrefix(ItemStack item, String prefix) { + if (prefix != null) { + NBTTagCompound itemStackData; + + if (item.hasTagCompound()) { + itemStackData = item.getTagCompound(); + } else { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + + itemStackData.setString("prefix", prefix); + } + } + + /** + * @param item + * The item you want to add the NBT data on + * @param suffix + * The suffix you want to add on the item + */ + public static void addSuffix(ItemStack item, String suffix) { + if (suffix != null) { + NBTTagCompound itemStackData; + + if (item.hasTagCompound()) { + itemStackData = item.getTagCompound(); + } else { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + + itemStackData.setString("suffix", suffix); + } + } /** * @param item @@ -276,6 +318,30 @@ public class JewelryNBT { return null; } + + public static String prefix(ItemStack stack) { + if (stack != null) { + if (stack != new ItemStack(Item.getItemById(0), 0, 0)) { + if (stack.hasTagCompound() && stack.getTagCompound().hasKey("prefix")) { + return stack.getTagCompound().getString("prefix"); + } + } + } + + return null; + } + + public static String suffix(ItemStack stack) { + if (stack != null) { + if (stack != new ItemStack(Item.getItemById(0), 0, 0)) { + if (stack.hasTagCompound() && stack.getTagCompound().hasKey("suffix")) { + return stack.getTagCompound().getString("suffix"); + } + } + } + + return null; + } /** * @param stack -- cgit v1.2.3