net.minecraft.nbt.NBTTagList Java Examples
The following examples show how to use
net.minecraft.nbt.NBTTagList.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlayerCivilization.java From ToroQuest with GNU General Public License v3.0 | 6 votes |
private Set<QuestData> readQuests(NBTBase tag) { Set<QuestData> quests = new HashSet<QuestData>(); if (tag == null || !(tag instanceof NBTTagList)) { return quests; } NBTTagList list = (NBTTagList) tag; for (int i = 0; i < list.tagCount(); i++) { QuestData d = new QuestData(); d.readNBT(list.getCompoundTagAt(i), getPlayer()); if (!d.isValid()) { continue; } quests.add(d); } return quests; }
Example #2
Source File: TileEntityOmnidirectionalHopper.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); inputDir = ForgeDirection.getOrientation(tag.getInteger("inputDir")); redstoneMode = tag.getInteger("redstoneMode"); leaveMaterial = tag.getBoolean("leaveMaterial"); NBTTagList tagList = tag.getTagList("Inventory", 10); inventory = new ItemStack[inventory.length]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } }
Example #3
Source File: SemiBlockManager.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@SubscribeEvent public void onChunkSave(ChunkDataEvent.Save event){ Map<ChunkPosition, ISemiBlock> map = semiBlocks.get(event.getChunk()); if(map != null && map.size() > 0) { NBTTagList tagList = new NBTTagList(); for(Map.Entry<ChunkPosition, ISemiBlock> entry : map.entrySet()) { NBTTagCompound t = new NBTTagCompound(); entry.getValue().writeToNBT(t); t.setInteger("x", entry.getKey().chunkPosX); t.setInteger("y", entry.getKey().chunkPosY); t.setInteger("z", entry.getKey().chunkPosZ); t.setString("type", getKeyForSemiBlock(entry.getValue())); tagList.appendTag(t); } event.getData().setTag("SemiBlocks", tagList); } }
Example #4
Source File: HackableHandler.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void loadNBTData(NBTTagCompound compound){ hackables = null; NBTTagList tagList = compound.getTagList("hackables", 10); for(int i = 0; i < tagList.tagCount(); i++) { String hackableId = tagList.getCompoundTagAt(i).getString("id"); Class<? extends IHackableEntity> hackableClass = PneumaticCraftAPIHandler.getInstance().stringToEntityHackables.get(hackableId); if(hackableClass != null) { try { if(hackables == null) hackables = new ArrayList<IHackableEntity>(); hackables.add(hackableClass.newInstance()); } catch(Exception e) { e.printStackTrace(); } } else { Log.warning("hackable \"" + hackableId + "\" not found when constructing from nbt. Was it deleted?"); } } }
Example #5
Source File: PacketSendSpellToBook.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
public PacketSendSpellToBook(List<List<ModuleInstance>> compiledSpell, Set<CommonWorktableModule> commonModules) { if (compiledSpell == null || commonModules == null) return; NBTTagList compiledList = new NBTTagList(); for (List<ModuleInstance> moduleList : compiledSpell) { for (ModuleInstance module : moduleList) compiledList.appendTag(module.serialize()); } moduleList = compiledList; NBTTagList commonList = new NBTTagList(); for (CommonWorktableModule commonModule : commonModules) { commonList.appendTag(commonModule.serializeNBT()); } this.commonModules = commonList; }
Example #6
Source File: ModuleVanilla.java From OpenPeripheral-Integration with MIT License | 6 votes |
public static Object listEnchantments(NBTTagList ench) { List<Map<String, Object>> response = Lists.newArrayList(); for (int i = 0; i < ench.tagCount(); ++i) { NBTTagCompound enchTag = ench.getCompoundTagAt(i); short id = enchTag.getShort("id"); short lvl = enchTag.getShort("lvl"); final Enchantment enchantment = Enchantment.enchantmentsList[id]; if (enchantment != null) { Map<String, Object> entry = Maps.newHashMap(); entry.put("name", enchantment.getName()); entry.put("level", lvl); entry.put("fullName", enchantment.getTranslatedName(lvl)); response.add(entry); } } return response; }
Example #7
Source File: MetaTileEntityPrimitiveBlastFurnace.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public NBTTagCompound writeToNBT(NBTTagCompound data) { super.writeToNBT(data); data.setBoolean("Active", isActive); data.setBoolean("WasActive", wasActiveAndNeedUpdate); data.setFloat("FuelUnitsLeft", fuelUnitsLeft); data.setInteger("MaxProgress", maxProgressDuration); if (maxProgressDuration > 0) { data.setInteger("Progress", currentProgress); NBTTagList itemOutputs = new NBTTagList(); for (ItemStack itemStack : outputsList) { itemOutputs.appendTag(itemStack.writeToNBT(new NBTTagCompound())); } data.setTag("Outputs", itemOutputs); } return data; }
Example #8
Source File: TileEntityAirCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void writeToNBT(NBTTagCompound nbtTagCompound){ super.writeToNBT(nbtTagCompound); nbtTagCompound.setInteger("burnTime", burnTime); nbtTagCompound.setInteger("maxBurn", maxBurnTime); nbtTagCompound.setInteger("redstoneMode", redstoneMode); // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); for(int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) { if(inventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte)currentIndex); inventory[currentIndex].writeToNBT(tagCompound); tagList.appendTag(tagCompound); } } nbtTagCompound.setTag("Items", tagList); }
Example #9
Source File: MoCEntityWyvern.java From mocreaturesdev with GNU General Public License v3.0 | 6 votes |
@Override public void writeEntityToNBT(NBTTagCompound nbttagcompound) { super.writeEntityToNBT(nbttagcompound); nbttagcompound.setBoolean("Saddle", getIsRideable()); nbttagcompound.setBoolean("Chested", getIsChested()); nbttagcompound.setByte("ArmorType", getArmorType()); nbttagcompound.setBoolean("isSitting", getIsSitting()); if (getIsChested() && localchest != null) { NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < localchest.getSizeInventory(); i++) { localstack = localchest.getStackInSlot(i); if (localstack != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); localstack.writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } nbttagcompound.setTag("Items", nbttaglist); } }
Example #10
Source File: ContainerPotionCreator.java From NotEnoughItems with MIT License | 6 votes |
@SuppressWarnings("unchecked") @Override public void handleInputPacket(PacketCustom packet) { ItemStack potion = potionInv.getStackInSlot(0); if (potion == null) return; boolean add = packet.readBoolean(); int effectID = packet.readUByte(); NBTTagList effects = potion.getTagCompound().getTagList("CustomPotionEffects", 10); NBTTagList newEffects = new NBTTagList(); for(int i = 0; i < effects.tagCount(); i++) { NBTTagCompound tag = effects.getCompoundTagAt(i); PotionEffect e = PotionEffect.readCustomPotionEffectFromNBT(tag); if(e.getPotionID() != effectID) newEffects.appendTag(tag); } if(add) newEffects.appendTag(new PotionEffect(effectID, packet.readInt(), packet.readUByte()).writeCustomPotionEffectToNBT(new NBTTagCompound())); potion.getTagCompound().setTag("CustomPotionEffects", newEffects); }
Example #11
Source File: LPRoutedItem.java From Logistics-Pipes-2 with MIT License | 6 votes |
public static LPRoutedItem readFromNBT(NBTTagCompound compound, TileGenericPipe holder) { double x = compound.getDouble("posX"); double y = compound.getDouble("posY"); double z = compound.getDouble("posZ"); UUID id = compound.getUniqueId("UID"); ItemStack content = new ItemStack(compound.getCompoundTag("inventory")); int ticks = compound.getInteger("ticks"); Deque<EnumFacing> routingInfo = new ArrayDeque<>(); NBTTagList routeList = (NBTTagList) compound.getTag("route"); for(Iterator<NBTBase> i = routeList.iterator(); i.hasNext();) { NBTTagCompound node = (NBTTagCompound) i.next(); EnumFacing nodeTuple = EnumFacing.values()[node.getInteger("heading")]; routingInfo.add(nodeTuple); } LPRoutedItem item = new LPRoutedItem(x, y, z, content, ticks, id); item.setHeading(EnumFacing.VALUES[compound.getInteger("heading")]); item.setHolding(holder); item.route = routingInfo; return item; }
Example #12
Source File: TileEntityVacuumPump.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void writeToNBT(NBTTagCompound tag){ super.writeToNBT(tag); NBTTagCompound vacuum = new NBTTagCompound(); vacuumHandler.writeToNBTI(vacuum); tag.setTag("vacuum", vacuum); tag.setBoolean("turning", turning); tag.setInteger("redstoneMode", redstoneMode); // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); for(int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) { if(inventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte)currentIndex); inventory[currentIndex].writeToNBT(tagCompound); tagList.appendTag(tagCompound); } } tag.setTag("Items", tagList); }
Example #13
Source File: TileEntityAssemblyIOUnit.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void writeToNBT(NBTTagCompound tag){ super.writeToNBT(tag); tag.setFloat("clawProgress", clawProgress); tag.setBoolean("clawClosing", shouldClawClose); tag.setByte("state", state); // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); for(int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) { if(inventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte)currentIndex); inventory[currentIndex].writeToNBT(tagCompound); tagList.appendTag(tagCompound); } } tag.setTag("Items", tagList); }
Example #14
Source File: TileEntityCamoMine.java From AdvancedMod with GNU General Public License v3.0 | 6 votes |
@Override public void writeToNBT(NBTTagCompound tag){ super.writeToNBT(tag); tag.setInteger("timer", timer); tag.setString("target", target); NBTTagList camoStackTag = new NBTTagList(); for(int i = 0; i < camoStacks.length; i++) { ItemStack stack = camoStacks[i]; if(stack != null) { NBTTagCompound t = new NBTTagCompound(); stack.writeToNBT(t); t.setByte("index", (byte)i); camoStackTag.appendTag(t); } } tag.setTag("camoStacks", camoStackTag); }
Example #15
Source File: Processor.java From Minecoprocessors with GNU General Public License v3.0 | 6 votes |
@Override public NBTTagCompound writeToNBT() { NBTTagCompound c = new NBTTagCompound(); c.setByteArray(NBT_STACK, stack); c.setByteArray(NBT_REGISTERS, registers); c.setByte(NBT_FAULTCODE, faultCode); c.setLong(NBT_FLAGS, packFlags()); if (error != null) { c.setString(NBT_ERROR, error); } NBTTagList programTag = new NBTTagList(); for (byte[] b : program) { programTag.appendTag(new NBTTagByteArray(b)); } c.setTag(NBT_PROGRAM, programTag); NBTTagList labelTag = new NBTTagList(); for (Label label : labels) { labelTag.appendTag(label.toNbt()); } c.setTag(NBT_LABELS, labelTag); return c; }
Example #16
Source File: MaterialCache.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
protected void readMapFromNBT(NBTTagCompound nbt, String tagName, IdentityHashMap<IBlockState, ItemStack> map) { if (nbt.hasKey(tagName, Constants.NBT.TAG_LIST)) { NBTTagList list = nbt.getTagList(tagName, Constants.NBT.TAG_COMPOUND); final int count = list.tagCount(); for (int i = 0; i < count; ++i) { NBTTagCompound tag = list.getCompoundTagAt(i); if (tag.hasKey("Block", Constants.NBT.TAG_COMPOUND) && tag.hasKey("Item", Constants.NBT.TAG_COMPOUND)) { IBlockState state = NBTUtil.readBlockState(tag.getCompoundTag("Block")); if (state != null) { ItemStack stack = new ItemStack(tag.getCompoundTag("Item")); this.buildItemsForStates.put(state, stack); } } } } }
Example #17
Source File: TileEntityBabyChest.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 6 votes |
@Override public void writeToNBT(NBTTagCompound pNBTTagCompound) { super.writeToNBT(pNBTTagCompound); NBTTagList tNBTTaglist = new NBTTagList(); for (int i = 0; i < _mInventory.length; i++) { if (_mInventory[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); _mInventory[i].writeToNBT(nbttagcompound1); tNBTTaglist.appendTag(nbttagcompound1); } } pNBTTagCompound.setTag("Items", tNBTTaglist); pNBTTagCompound.setByte("facing", (byte)_mOrientation.ordinal() ); }
Example #18
Source File: TileEntityElevatorBase.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); extension = tag.getFloat("extension"); targetExtension = tag.getFloat("targetExtension"); redstoneMode = tag.getInteger("redstoneMode"); if(!tag.hasKey("maxFloorHeight")) {//backwards compatibility implementation. updateMaxElevatorHeight(); } else { maxFloorHeight = tag.getInteger("maxFloorHeight"); } for(int i = 0; i < 6; i++) { sidesConnected[i] = tag.getBoolean("sideConnected" + i); } // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = tag.getTagList("Items", 10); inventory = new ItemStack[inventory.length]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } }
Example #19
Source File: TileEntityAerialInterface.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); // Read in the ItemStacks in the inventory from NBT redstoneMode = tag.getInteger("redstoneMode"); feedMode = tag.getInteger("feedMode"); setPlayer(tag.getString("playerName"), tag.getString("playerUUID")); isConnectedToPlayer = tag.getBoolean("connected"); if(tag.hasKey("curXpFluid")) curXpFluid = FluidRegistry.getFluid(tag.getString("curXpFluid")); if(energyRF != null) readRF(tag); NBTTagList tagList = tag.getTagList("Items", 10); inventory = new ItemStack[4]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } dispenserUpgradeInserted = getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE) > 0; }
Example #20
Source File: MsgTileEntities.java From archimedes-ships with MIT License | 6 votes |
@Override @SideOnly(Side.CLIENT) public void handleClientSide(EntityPlayer player) { if (ship != null && tagCompound != null) { NBTTagList list = tagCompound.getTagList("list", 10); for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound nbt = list.getCompoundTagAt(i); if (nbt == null) continue; int x = nbt.getInteger("x"); int y = nbt.getInteger("y"); int z = nbt.getInteger("z"); try { TileEntity te = ship.getShipChunk().getTileEntity(x, y, z); te.readFromNBT(nbt); } catch (Exception e) { e.printStackTrace(); } } ((MobileChunkClient) ship.getShipChunk()).getRenderer().markDirty(); } }
Example #21
Source File: DateEventHandler.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public static void spawnFirework(World world, double x, double y, double z){ ItemStack rocket = new ItemStack(Items.fireworks); ItemStack itemstack1 = getFireworkCharge(); NBTTagCompound nbttagcompound = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagList nbttaglist = new NBTTagList(); if(itemstack1 != null && itemstack1.getItem() == Items.firework_charge && itemstack1.hasTagCompound() && itemstack1.getTagCompound().hasKey("Explosion")) { nbttaglist.appendTag(itemstack1.getTagCompound().getCompoundTag("Explosion")); } nbttagcompound1.setTag("Explosions", nbttaglist); nbttagcompound1.setByte("Flight", (byte)2); nbttagcompound.setTag("Fireworks", nbttagcompound1); rocket.setTagCompound(nbttagcompound); EntityFireworkRocket entity = new EntityFireworkRocket(world, x, y, z, rocket); world.spawnEntityInWorld(entity); }
Example #22
Source File: TileArcanePackager.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); contents = new ItemStack[getSizeInventory()]; NBTTagList list = compound.getTagList("Items", 10); for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound slot = list.getCompoundTagAt(i); int j = slot.getByte("Slot") & 255; if (j >= 0 && j < contents.length) { contents[j] = ItemStack.loadItemStackFromNBT(slot); } } }
Example #23
Source File: TileEntitySeedStorage.java From AgriCraft with MIT License | 6 votes |
@Override protected void writeNBT(NBTTagCompound tag) { if (this.lockedSeed != null) { //add the locked SEED tag.setTag(AgriNBT.SEED, this.lockedSeed.toStack().writeToNBT(new NBTTagCompound())); if (this.slots != null) { //add the slots NBTTagList tagList = new NBTTagList(); for (Map.Entry<Integer, SeedStorageSlot> entry : slots.entrySet()) { if (entry != null && entry.getValue() != null) { NBTTagCompound slotTag = new NBTTagCompound(); entry.getValue().writeToNbt(slotTag); tagList.appendTag(slotTag); } } tag.setTag(AgriNBT.INVENTORY, tagList); } } if (this.hasController()) { NBTHelper.addCoordsToNBT(this.controller.getCoordinates(), tag); } }
Example #24
Source File: FrameMovementRegistry.java From Framez with GNU General Public License v3.0 | 6 votes |
public void readInfo(IMovingBlock block, NBTTagCompound tag) { if (!tag.hasKey("info")) return; NBTTagList l = tag.getTagList("info", new NBTTagCompound().getId()); for (int i = 0; i < l.tagCount(); i++) { NBTTagCompound t = l.getCompoundTagAt(i); for (IMovementDataProvider p : dataProviders) { if (p.getID().equals(t.getString("___id"))) { p.readMovementInfo(block, t); break; } } } }
Example #25
Source File: CraftMetaFirework.java From Kettle with GNU General Public License v3.0 | 6 votes |
CraftMetaFirework(NBTTagCompound tag) { super(tag); if (!tag.hasKey(FIREWORKS.NBT)) { return; } NBTTagCompound fireworks = tag.getCompoundTag(FIREWORKS.NBT); power = 0xff & fireworks.getByte(FLIGHT.NBT); if (!fireworks.hasKey(EXPLOSIONS.NBT)) { return; } NBTTagList fireworkEffects = fireworks.getTagList(EXPLOSIONS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); List<FireworkEffect> effects = this.effects = new ArrayList<FireworkEffect>(fireworkEffects.tagCount()); for (int i = 0; i < fireworkEffects.tagCount(); i++) { effects.add(getEffect((NBTTagCompound) fireworkEffects.get(i))); } }
Example #26
Source File: CraftMetaFirework.java From Kettle with GNU General Public License v3.0 | 6 votes |
@Override void applyToItem(NBTTagCompound itemTag) { super.applyToItem(itemTag); if (isFireworkEmpty()) { return; } NBTTagCompound fireworks = itemTag.getCompoundTag(FIREWORKS.NBT); itemTag.setTag(FIREWORKS.NBT, fireworks); if (hasEffects()) { NBTTagList effects = new NBTTagList(); for (FireworkEffect effect : this.effects) { effects.appendTag(getExplosion(effect)); } if (effects.tagCount() > 0) { fireworks.setTag(EXPLOSIONS.NBT, effects); } } if (hasPower()) { fireworks.setByte(FLIGHT.NBT, (byte) power); } }
Example #27
Source File: BookBot.java From ForgeHax with MIT License | 6 votes |
private void sendBook(ItemStack stack) { NBTTagList pages = new NBTTagList(); // page tag list // copy pages into NBT for (int i = 0; i < MAX_PAGES && parser.hasNext(); i++) { pages.appendTag(new NBTTagString(parser.next().trim())); page++; } // set our client side book if (stack.hasTagCompound()) { stack.getTagCompound().setTag("pages", pages); } else { stack.setTagInfo("pages", pages); } // publish the book stack.setTagInfo("author", new NBTTagString(getLocalPlayer().getName())); stack.setTagInfo( "title", new NBTTagString(parent.name.get().replaceAll(NUMBER_TOKEN, "" + getBook()).trim())); PacketBuffer buff = new PacketBuffer(Unpooled.buffer()); buff.writeItemStack(stack); MC.getConnection().sendPacket(new CPacketCustomPayload("MC|BSign", buff)); }
Example #28
Source File: MoCEntityWyvern.java From mocreaturesdev with GNU General Public License v3.0 | 6 votes |
@Override public void readEntityFromNBT(NBTTagCompound nbttagcompound) { super.readEntityFromNBT(nbttagcompound); setRideable(nbttagcompound.getBoolean("Saddle")); setIsChested(nbttagcompound.getBoolean("Chested")); setArmorType(nbttagcompound.getByte("ArmorType")); setSitting(nbttagcompound.getBoolean("isSitting")); if (getIsChested()) { NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); localchest = new MoCAnimalChest("WyvernChest", 14); for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i); int j = nbttagcompound1.getByte("Slot") & 0xff; if ((j >= 0) && j < localchest.getSizeInventory()) { localchest.setInventorySlotContents(j, ItemStack.loadItemStackFromNBT(nbttagcompound1)); } } } }
Example #29
Source File: TileEntityPneumaticGenerator.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void writeToNBT(NBTTagCompound nbtTagCompound){ super.writeToNBT(nbtTagCompound); nbtTagCompound.setInteger("redstoneMode", redstoneMode); nbtTagCompound.setBoolean("outputting", outputting); nbtTagCompound.setInteger("energyProduction", curEnergyProduction); // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); for(int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) { if(inventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte)currentIndex); inventory[currentIndex].writeToNBT(tagCompound); tagList.appendTag(tagCompound); } } nbtTagCompound.setTag("Items", tagList); }
Example #30
Source File: TileEntityHardMEDrive.java From ExtraCells1 with MIT License | 6 votes |
@Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.slots.length; ++i) { if (this.slots[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); this.slots[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } nbt.setTag("Items", nbttaglist); if (this.isInvNameLocalized()) { nbt.setString("CustomName", this.customName); } }