diff options
author | Alkalus <draknyte1@hotmail.com> | 2017-11-14 06:45:39 +1000 |
---|---|---|
committer | Alkalus <draknyte1@hotmail.com> | 2017-11-14 06:45:39 +1000 |
commit | a854011984ad05238dccf1d42925686257a4116b (patch) | |
tree | d22487eadd4c346f92233ae3aabf4b0db218b4bb /src/Java/gtPlusPlus/core/util/nbt | |
parent | 26a516093424c7f2fd637681ae190bc00335a668 (diff) | |
download | GT5-Unofficial-a854011984ad05238dccf1d42925686257a4116b.tar.gz GT5-Unofficial-a854011984ad05238dccf1d42925686257a4116b.tar.bz2 GT5-Unofficial-a854011984ad05238dccf1d42925686257a4116b.zip |
% More book changes.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/nbt')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java b/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java index 3005c53f1b..c5f3942997 100644 --- a/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java +++ b/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java @@ -259,5 +259,76 @@ public class NBTUtils { } return false; } + + public static boolean createIntegerTagCompound(ItemStack rStack, String tagName, String keyName, int keyValue){ + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setInteger(keyName, keyValue); + tagMain.setTag(tagName, tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static boolean createLongTagCompound(ItemStack rStack, String tagName, String keyName, long keyValue){ + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong(keyName, keyValue); + tagMain.setTag(tagName, tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static boolean createStringTagCompound(ItemStack rStack, String tagName, String keyName, String keyValue){ + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setString(keyName, keyValue); + tagMain.setTag(tagName, tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static int getIntegerTagCompound(ItemStack aStack, String tagName, String keyName){ + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag(tagName); + if (aNBT != null) { + return aNBT.getInteger(keyName); + } + } + return 0; + } + + public static long getLongTagCompound(ItemStack aStack, String tagName, String keyName){ + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag(tagName); + if (aNBT != null) { + return aNBT.getLong(keyName); + } + } + return 0L; + } + + public static String getStringTagCompound(ItemStack aStack, String tagName, String keyName){ + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag(tagName); + if (aNBT != null) { + return aNBT.getString(keyName); + } + } + return null; + } + + public static boolean hasKeyInTagCompound(ItemStack stack, String tag, String key){ + NBTTagCompound aNBT = stack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag(tag); + if (aNBT.hasKey(key)) { + return true; + } + } + return false; + } } |