public static int countItemsFromNBT(NBTTagCompound tags, String key) { if (tags == null) { return 0; } NBTTagList items = tags.getTagList(key, tags.getId()); if (items == null) { return 0; } return items.tagCount(); }
@Override public void readSharedNBT(NBTTagCompound cmp) { super.readSharedNBT(cmp); NBTTagList pipeItemList = cmp.getTagList(TAG_PIPE_ITEMS, cmp.getId()); pipeItems.clear(); pipeItemList.forEach(listCmp -> { PipeItem item = PipeItem.readFromNBT((NBTTagCompound) listCmp); pipeItems.add(item); }); }
public static ArrayList<ItemStack> readItemsFromNBT(NBTTagCompound tags, String key) { ArrayList<ItemStack> list = new ArrayList<ItemStack>(); NBTTagList items = tags.getTagList(key, tags.getId()); for (int i = 0; i < items.tagCount(); ++i) { // tagAt(int) has changed to getCompoundTagAt(int) NBTTagCompound item = items.getCompoundTagAt(i); list.add(UtilNBT.itemFromNBT(item)); } return list; }
@Override public void readFromNBT(@Nonnull NBTTagCompound nbtRoot) { signalColors.clear(); NBTTagCompound t = nbtRoot.getCompoundTag("filterType"); type = EnumSignalFilterType.values()[t.getInteger("type")]; NBTTagList tagList = nbtRoot.getTagList("signalColors", nbtRoot.getId()); for (int i = 0; i < tagList.tagCount(); i++) { signalColors.add(DyeColor.fromIndex(tagList.getCompoundTagAt(i).getInteger("color"))); } }
@Override public void readFromNBT(@Nonnull NBTTagCompound nbtRoot) { isBlacklist = NbtValue.FILTER_BLACKLIST.getBoolean(nbtRoot); clear(); NBTTagList tagList = nbtRoot.getTagList("fluids", nbtRoot.getId()); for (int i = 0; i < tagList.tagCount(); i++) { fluids[i] = FluidStack.loadFluidStackFromNBT(tagList.getCompoundTagAt(i)); } }
public void readFromNBT(NBTTagCompound nbttagcompound, String prefix) { NBTTagList nbttaglist = nbttagcompound.getTagList(prefix + "items", nbttagcompound.getId()); for (int j = 0; j < nbttaglist.tagCount(); ++j) { NBTTagCompound nbttagcompound2 = nbttaglist.getCompoundTagAt(j); int index = nbttagcompound2.getInteger("index"); if (index < _contents.length) { _contents[index] = ItemStackLoader.loadAndFixItemStackFromNBT(nbttagcompound2); } else { LogisticsPipes.log.fatal("SimpleInventory: java.lang.ArrayIndexOutOfBoundsException: " + index + " of " + _contents.length); } } }
public static void writeTagsToInventory(IInventory invo, NBTTagCompound tags, String key) { NBTTagList items = tags.getTagList(key, tags.getId()); ItemStack stack; int slot; for (int i = 0; i < items.tagCount(); ++i) { // tagAt(int) has changed to getCompoundTagAt(int) NBTTagCompound item = items.getCompoundTagAt(i); stack = UtilNBT.itemFromNBT(item); slot = item.getInteger("slot"); // list.add(ItemStack.loadItemStackFromNBT(item)); invo.setInventorySlotContents(slot, stack); } }
/** * Loads this inventory from NBT; must be called manually * Fails silently if {@link #getNbtKey} returns null or an empty string */ public void readFromNBT(NBTTagCompound compound) { String key = getNbtKey(); if (key == null || key.equals("")) { return; } NBTTagList items = compound.getTagList(key, compound.getId()); for (int i = 0; i < items.tagCount(); ++i) { NBTTagCompound item = items.getCompoundTagAt(i); byte slot = item.getByte("Slot"); if (slot >= 0 && slot < getSizeInventory()) { inventory[slot] = ItemStack.loadItemStackFromNBT(item); } } } }
protected static @Nullable ICapacitorData getNBTCapacitorDataFromItemStack(@Nonnull ItemStack stack) { final NBTTagCompound nbtRoot = stack.getTagCompound(); if (nbtRoot == null) { return null; } if (!nbtRoot.hasKey("eiocap", (new NBTTagCompound()).getId())) { return null; } final NBTTagCompound nbtTag = nbtRoot.getCompoundTag("eiocap"); if (!nbtTag.hasKey("level", (new NBTTagFloat(0)).getId())) { return null; } final float capLevel = nbtTag.getFloat("level"); if (capLevel < 0 || capLevel >= 10) { return null; } return new NBTCapacitorData(stack.getItem().getUnlocalizedName(stack), capLevel, nbtTag); }
NBTTagList list = nbt.getTagList("MainPipePosList", new NBTTagCompound().getId()); for(int i=0; i< list.tagCount();i++) { DoubleCoordinates pos = DoubleCoordinates.readFromNBT("MainPipePos_", list.getCompoundTagAt(i));
public void readFromNBT(NBTTagCompound cmp) { pieces.clear(); NBTTagList plist = cmp.getTagList(TAG_PIECES, cmp.getId()); for(int i = 0; i < plist.tagCount(); i++) { NBTTagCompound pcmp = plist.getCompoundTagAt(i); int id = pcmp.getInteger(TAG_PIECE_ID); Piece piece = new Piece(); piece.readFromNBT(pcmp); pieces.put(id, piece); } benchedPieces = unpackList(cmp.getIntArray(TAG_BENCHED_PIECES)); placedPieces = unpackList(cmp.getIntArray(TAG_PLACED_PIECES)); count = cmp.getInteger(TAG_COUNT); typeCount = cmp.getInteger(TAG_TYPE_COUNT); computeMatrix(); }
String prefix = data.substring(6); NBTTagCompound module = nbt.getCompoundTag("moduleInformation"); int size = module.getTagList(prefix + "items", module.getId()).tagCount(); if (module.hasKey(prefix + "itemsCount")) { size = module.getInteger(prefix + "itemsCount");
public void readFromNBT(NBTTagCompound nbttagcompound, String prefix) { NBTTagList nbttaglist = nbttagcompound.getTagList(prefix + "items", nbttagcompound.getId()); for (int j = 0; j < nbttaglist.tagCount(); ++j) { NBTTagCompound nbttagcompound2 = nbttaglist.getCompoundTagAt(j); int index = nbttagcompound2.getInteger("index"); if (index < _contents.length) { ItemStack stack = ItemStackLoader.loadAndFixItemStackFromNBT(nbttagcompound2); ItemIdentifierStack itemstack = ItemIdentifierStack.getFromStack(stack); if (isValidStack(itemstack)) { _contents[index] = itemstack; } } else { LogisticsPipes.log.fatal("SimpleInventory: java.lang.ArrayIndexOutOfBoundsException: " + index + " of " + _contents.length); } } updateContents(); }
@Override public void readFromNBT(@Nonnull NBTTagCompound nbtRoot) { isBlacklist = NbtValue.FILTER_BLACKLIST.getBoolean(nbtRoot); matchMeta = NbtValue.FILTER_META.getBoolean(nbtRoot); matchNBT = NbtValue.FILTER_NBT.getBoolean(nbtRoot); useOreDict = NbtValue.FILTER_OREDICT.getBoolean(nbtRoot); sticky = NbtValue.FILTER_STICKY.getBoolean(nbtRoot); isAdvanced = NbtValue.FILTER_ADVANCED.getBoolean(nbtRoot); isLimited = NbtValue.FILTER_LIMITED.getBoolean(nbtRoot); isBig = NbtValue.FILTER_BIG.getBoolean(nbtRoot); damageMode = NullHelper.notnullJ(DamageMode.values()[NbtValue.FILTER_DAMAGE.getInt(nbtRoot) & 255], "Enum.values()"); items.clear(); NBTTagList tagList = nbtRoot.getTagList("items", nbtRoot.getId()); for (int i = 0; i < tagList.tagCount(); i++) { items.add(new ItemStack(tagList.getCompoundTagAt(i))); } int numItems = isBig ? BasicFilterTypes.filterUpgradeBig.getSlots() : (isAdvanced ? BasicFilterTypes.filterUpgradeAdvanced.getSlots() : BasicFilterTypes.filterUpgradeBasic.getSlots()); while (items.size() < numItems) { items.add(Prep.getEmpty()); } oreIds.clear(); for (int i = 0; i < numItems; i++) { oreIds.add(null); } }
return; if (!stack.getTagCompound().hasKey("Inventory", Constants.NBT.TAG_LIST) || stack.getTagCompound().getTagList("Inventory", stack.getTagCompound().getId()).tagCount() <= 0) { list.add(StringHelper.localize("info.cofh.empty")); return; NBTTagList nbtList = stack.getTagCompound().getTagList("Inventory", stack.getTagCompound().getId()); ItemStack curStack; ItemStack curStack2;
NBTTagList sendqueue = nbttagcompound.getTagList("sendqueue", nbttagcompound.getId()); for (int i = 0; i < sendqueue.tagCount(); i++) { NBTTagCompound tagentry = sendqueue.getCompoundTagAt(i);
@Override public void deserializeNBT(NBTBase nbtIn) { if (nbtIn instanceof NBTTagCompound) { NBTTagCompound nbt = (NBTTagCompound) nbtIn; long genIn = nbt.getLong("gen"); if (genIn > getGeneration()) { Log.debug("Reading ServerChannelRegister with gen=" + genIn); reset(); setGeneration(genIn); NBTTagList list = nbt.getTagList("list", nbt.getId()); for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound tag = list.getCompoundTagAt(i); Channel channel = Channel.readFromNBT(tag); if (channel != null) { Log.debug("ServerChannelRegister: Reading channel " + channel.getName()); addChannel(channel); } else { Log.warn("ServerChannelRegister: Invalid channel NBT: " + tag); } } } else { Log.debug("Ignoring ServerChannelRegister with gen=" + genIn); } } }