public static long getFixedFromNBT(NBTTagCompound nbt, String key) { // See net.minecraft.nbt.NBTBase.NBT_TYPES[] for meaning of type ids. byte dataType = nbt.getTagId(key); if( dataType == 5 || dataType == 6 ) return FixedPointUtils.doubleToFixed(nbt.getDouble(key)); // NOTE: For legacy case else if( dataType == 1 || dataType == 2 || dataType == 3 || dataType == 4 ) return nbt.getLong(key); return 0; }
public static double getDoubleFromNBT(NBTTagCompound nbt, String key) { // See net.minecraft.nbt.NBTBase.NBT_TYPES[] for meaning of type ids. byte dataType = nbt.getTagId(key); if( dataType == 5 || dataType == 6 ) return nbt.getDouble(key); // NOTE: For legacy case else if( dataType == 1 || dataType == 2 || dataType == 3 || dataType == 4 ) return FixedPointUtils.fixedToDouble(nbt.getLong(key)); return 0; }
@Override public ITextComponent[] getData(ItemStack stack) { LinkedList<ITextComponent> ret = new LinkedList<>(); ret.add(null); if (stack.hasTagCompound() && stack.getTagCompound().hasKey("display", 10)) { NBTTagCompound nbttagcompound = stack.getTagCompound().getCompoundTag("display"); if (nbttagcompound.getTagId("Lore") == 9) { NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); if (nbttaglist1.tagCount() > 0) { for (int j = 0; j < nbttaglist1.tagCount(); ++j) { ret.add(new TextComponentString(StringHelper.PURPLE + " " + StringHelper.ITALIC + nbttaglist1.getStringTagAt(j))); } } } } else { ret.set(0, new TextComponentString("none")); } return ret.toArray(new ITextComponent[ret.size()]); } }, Enchants("enchant", "ench") {
@Override public boolean isBlacklisted(@Nonnull ItemStack stack) { for (ItemPair pair : itemBlacklist) if (pair.getItem() == stack.getItem()) if (pair.getMeta() == stack.getItemDamage() || pair.getMeta() == OreDictionary.WILDCARD_VALUE) return true; NBTTagCompound tag = stack.getTagCompound(); if (tag == null || tag.hasNoTags()) return false; for (String key : nbtBlacklist) { if (tag.hasKey(key)) return true; // Short circuit if main tag has key String[] subTags = key.split("\\."); // Allow sub tags defined as `foo.bar` to look for a for (String subTag : subTags) { if (tag.hasNoTags() || tag.getTagId(subTag) != 10) return tag.hasKey(subTag); tag = tag.getCompoundTag(subTag); } } return false; }
if(jObj.getTagId("preRequisites") == 11) // Native NBT