Java Code Examples for net.minecraft.nbt.NBTTagCompound#getTagList()
The following examples show how to use
net.minecraft.nbt.NBTTagCompound#getTagList() .
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: ItemPneumaticArmor.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
/** * Retrieves the upgrades currently installed on the given armor stack. */ public static ItemStack[] getUpgradeStacks(ItemStack iStack){ NBTTagCompound tag = NBTUtil.getCompoundTag(iStack, "UpgradeInventory"); ItemStack[] inventoryStacks = new ItemStack[9]; if(tag != null) { NBTTagList itemList = tag.getTagList("Items", 10); if(itemList != null) { for(int i = 0; i < itemList.tagCount(); i++) { NBTTagCompound slotEntry = itemList.getCompoundTagAt(i); int j = slotEntry.getByte("Slot"); if(j >= 0 && j < 9) { inventoryStacks[j] = ItemStack.loadItemStackFromNBT(slotEntry); } } } } return inventoryStacks; }
Example 2
Source File: EntityAuraCore.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void readEntityFromNBT(NBTTagCompound compound) { super.readEntityFromNBT(compound); this.internalAuraList = new PrimalAspectList(); ticksExisted = compound.getInteger("ticksExisted"); NBTTagList list = compound.getTagList("auraList", compound.getId()); for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound cmp = list.getCompoundTagAt(i); if(cmp.hasKey("tag") && cmp.hasKey("amt")) { internalAuraList.add(Aspect.getAspect(cmp.getString("tag")), cmp.getInteger("amt")); } } if(compound.hasKey("activationVecX") && compound.hasKey("activationVecY") && compound.hasKey("activationVecZ")) { int x = compound.getInteger("activationVecX"); int y = compound.getInteger("activationVecY"); int z = compound.getInteger("activationVecZ"); activationLocation = new ChunkCoordinates(x, y, z); } sendAspectData(electParliament()); initGathering(); blockCount = compound.getInteger("blockCount"); }
Example 3
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 4
Source File: TileEntityProgrammer.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); redstoneMode = tag.getInteger("redstoneMode"); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = tag.getTagList("Items", 10); inventory = new ItemStack[getSizeInventory()]; 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); } } history = tag.getTagList("history", 10); if(history.tagCount() == 0) saveToHistory(); }
Example 5
Source File: TileContainer.java From Production-Line with MIT License | 6 votes |
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList nbttaglist = nbt.getTagList("Items", 10); for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound tag = nbttaglist.getCompoundTagAt(i); byte slot = tag.getByte("Slot"); if (slot >= 0 && slot < this.getSizeInventory()) { this.tileSlots.get(i).readFromNBT(tag); } } if (nbt.hasKey("CustomName", 8)) { this.name = nbt.getString("CustomName"); } }
Example 6
Source File: TileEntityPressureChamberInterface.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 NBTTagList tagList = tag.getTagList("Items", 10); inventory = new ItemStack[getSizeInventory()]; 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); } } outputProgress = tag.getInteger("outputProgress"); inputProgress = tag.getInteger("inputProgress"); interfaceMode = EnumInterfaceMode.values()[tag.getInteger("interfaceMode")]; filterMode = EnumFilterMode.values()[tag.getInteger("filterMode")]; creativeTabID = tag.getInteger("creativeTabID"); itemNameFilter = tag.getString("itemNameFilter"); redstoneMode = tag.getInteger("redstoneMode"); }
Example 7
Source File: TileEntityInventory.java From BigReactors with MIT License | 6 votes |
@Override public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); // Inventories _inventories = new ItemStack[getSizeInventory()]; if(tag.hasKey("Items")) { NBTTagList tagList = tag.getTagList("Items", 10); for(int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound itemTag = (NBTTagCompound)tagList.getCompoundTagAt(i); int slot = itemTag.getByte("Slot") & 0xff; if(slot >= 0 && slot <= _inventories.length) { ItemStack itemStack = new ItemStack((Block)null,0,0); itemStack.readFromNBT(itemTag); _inventories[slot] = itemStack; } } } }
Example 8
Source File: TileGuidanceComputer.java From AdvancedRocketry with MIT License | 6 votes |
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); destinationId = nbt.getInteger("destDimId"); landingPos.x = nbt.getFloat("landingx"); landingPos.y = nbt.getFloat("landingy"); landingPos.z = nbt.getFloat("landingz"); NBTTagList stationList = nbt.getTagList("stationMapping", NBT.TAG_COMPOUND); for(int i = 0; i < stationList.tagCount(); i++) { NBTTagCompound tag = stationList.getCompoundTagAt(i); int pos[]; pos = tag.getIntArray("pos"); int id = tag.getInteger("id"); landingLoc.put(id, new HashedBlockPosition(pos[0], pos[1], pos[2])); } }
Example 9
Source File: MCNetworkState.java From Signals with GNU General Public License v3.0 | 6 votes |
public static MCNetworkState fromNBT(RailNetworkManager railNetworkManager, NBTTagCompound tag){ NBTTagList trainList = tag.getTagList("trains", Constants.NBT.TAG_COMPOUND); List<MCTrain> trains = new ArrayList<>(); for(int i = 0; i < trainList.tagCount(); i++) { trains.add(MCTrain.fromNBT(railNetworkManager, trainList.getCompoundTagAt(i))); } Map<MCPos, EnumForceMode> forcedSignalMap = new HashMap<>(); NBTTagList forcedSignals = tag.getTagList("forcedSignals", Constants.NBT.TAG_COMPOUND); for(int i = 0; i < forcedSignals.tagCount(); i++) { NBTTagCompound t = forcedSignals.getCompoundTagAt(i); forcedSignalMap.put(new MCPos(t), EnumForceMode.values()[t.getByte("f")]); } MCNetworkState state = new MCNetworkState(railNetworkManager); state.signalForces = forcedSignalMap; state.setTrains(trains); return state; }
Example 10
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 11
Source File: TileEntityProgrammer.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public static void getWidgetsFromNBT(NBTTagCompound tag, List<IProgWidget> progWidgets){ NBTTagList widgetTags = tag.getTagList("widgets", 10); for(int i = 0; i < widgetTags.tagCount(); i++) { NBTTagCompound widgetTag = widgetTags.getCompoundTagAt(i); String widgetName = widgetTag.getString("name"); for(IProgWidget widget : WidgetRegistrator.registeredWidgets) { if(widgetName.equals(widget.getWidgetString())) {//create the right progWidget for the given id tag. IProgWidget addedWidget = widget.copy(); addedWidget.readFromNBT(widgetTag); progWidgets.add(addedWidget); break; } } } updatePuzzleConnections(progWidgets); }
Example 12
Source File: TileChipStorage.java From AdvancedRocketry with MIT License | 5 votes |
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList list = nbt.getTagList("outputItems", 10); for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound tag = (NBTTagCompound) list.getCompoundTagAt(i); byte slot = tag.getByte("Slot"); if (slot >= 0 && slot < inventory.length) { inventory[slot] = new ItemStack(tag); } } }
Example 13
Source File: PlacementProperties.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private void readFromNBT(NBTTagCompound nbt) { if (nbt == null || nbt.hasKey("PlacementProperties", Constants.NBT.TAG_LIST) == false) { return; } NBTTagList tagListPlayers = nbt.getTagList("PlacementProperties", Constants.NBT.TAG_COMPOUND); int countPlayers = tagListPlayers.tagCount(); for (int playerIndex = 0; playerIndex < countPlayers; playerIndex++) { this.readAllDataForPlayerFromNBT(tagListPlayers.getCompoundTagAt(playerIndex)); } }
Example 14
Source File: AspectList.java From AdvancedMod with GNU General Public License v3.0 | 5 votes |
public void readFromNBT(NBTTagCompound nbttagcompound, String label) { aspects.clear(); NBTTagList tlist = nbttagcompound.getTagList(label,(byte)10); for (int j = 0; j < tlist.tagCount(); j++) { NBTTagCompound rs = (NBTTagCompound) tlist.getCompoundTagAt(j); if (rs.hasKey("key")) { add( Aspect.getAspect(rs.getString("key")), rs.getInteger("amount")); } } }
Example 15
Source File: PipeCoverableImplementation.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public void readFromNBT(NBTTagCompound data) { NBTTagList coversList = data.getTagList("Covers", NBT.TAG_COMPOUND); for (int index = 0; index < coversList.tagCount(); index++) { NBTTagCompound tagCompound = coversList.getCompoundTagAt(index); if (tagCompound.hasKey("CoverId", NBT.TAG_STRING)) { EnumFacing coverSide = EnumFacing.VALUES[tagCompound.getByte("Side")]; ResourceLocation coverId = new ResourceLocation(tagCompound.getString("CoverId")); CoverDefinition coverDefinition = CoverDefinition.getCoverById(coverId); CoverBehavior coverBehavior = coverDefinition.createCoverBehavior(this, coverSide); coverBehavior.readFromNBT(tagCompound); this.coverBehaviors[coverSide.getIndex()] = coverBehavior; } } }
Example 16
Source File: SpellRing.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void deserializeNBT(NBTTagCompound nbt) { // NOTE: Don't store nbt argument to serializedNBT. This one must be generated only by serializeNBT() if (nbt.hasKey("module")) this.module = ModuleInstance.deserialize(nbt.getString("module")); if (nbt.hasKey("extra")) informationTag = sortInformationTag(nbt.getCompoundTag("extra")); if (nbt.hasKey("primary_color")) primaryColor = Color.decode(nbt.getString("primary_color")); if (nbt.hasKey("secondary_color")) secondaryColor = Color.decode(nbt.getString("secondary_color")); if (nbt.hasKey("modifiers")) { compileTimeModifiers.clear(); for (NBTBase base : nbt.getTagList("modifiers", Constants.NBT.TAG_COMPOUND)) { if (base instanceof NBTTagCompound) { NBTTagCompound modifierCompound = (NBTTagCompound) base; if (modifierCompound.hasKey("operation") && modifierCompound.hasKey("attribute") && modifierCompound.hasKey("modifier")) { Operation operation = Operation.values()[modifierCompound.getInteger("operation") % Operation.values().length]; Attribute attribute = AttributeRegistry.getAttributeFromName(modifierCompound.getString("attribute")); float modifierFixed = FixedPointUtils.getFixedFromNBT(modifierCompound, "modifier"); compileTimeModifiers.put(operation, new AttributeModifierSpellRing(attribute, modifierFixed, operation)); } } } } if (nbt.hasKey("child_ring")) { SpellRing childRing = deserializeRing(nbt.getCompoundTag("child_ring")); childRing.setParentRing(this); setChildRing(childRing); } if (nbt.hasKey("uuid")) uniqueID = UUID.fromString(nbt.getString("uuid")); }
Example 17
Source File: AbstractPair.java From NEI-Integration with MIT License | 5 votes |
protected void loadNBT(NBTTagCompound data) { NBTTagList list = data.getTagList("pairings", 10); for (byte entry = 0; entry < list.tagCount(); entry++) { NBTTagCompound tag = list.getCompoundTagAt(entry); int[] c = tag.getIntArray("coords"); pairings.add(new WorldCoordinate(c[0], c[1], c[2], c[3])); } }
Example 18
Source File: TofuVillage.java From TofuCraftReload with MIT License | 5 votes |
/** * Read this village's data from NBT. */ public void readTofuVillageDataFromNBT(NBTTagCompound compound) { this.numTofuVillagers = compound.getInteger("PopSize"); this.villageRadius = compound.getInteger("Radius"); this.numIronGolems = compound.getInteger("Golems"); this.lastAddDoorTimestamp = compound.getInteger("Stable"); this.tickCounter = compound.getInteger("Tick"); this.noBreedTicks = compound.getInteger("MTick"); this.center = new BlockPos(compound.getInteger("CX"), compound.getInteger("CY"), compound.getInteger("CZ")); this.centerHelper = new BlockPos(compound.getInteger("ACX"), compound.getInteger("ACY"), compound.getInteger("ACZ")); NBTTagList nbttaglist = compound.getTagList("Doors", 10); for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); VillageDoorInfo villagedoorinfo = new VillageDoorInfo(new BlockPos(nbttagcompound.getInteger("X"), nbttagcompound.getInteger("Y"), nbttagcompound.getInteger("Z")), nbttagcompound.getInteger("IDX"), nbttagcompound.getInteger("IDZ"), nbttagcompound.getInteger("TS")); this.villageDoorInfoList.add(villagedoorinfo); } NBTTagList nbttaglist1 = compound.getTagList("Players", 10); for (int j = 0; j < nbttaglist1.tagCount(); ++j) { NBTTagCompound nbttagcompound1 = nbttaglist1.getCompoundTagAt(j); if (nbttagcompound1.hasKey("UUID")) { this.playerReputation.put(UUID.fromString(nbttagcompound1.getString("UUID")), Integer.valueOf(nbttagcompound1.getInteger("S"))); } else { //World is never set here, so this will always be offline UUIDs, sadly there is no way to convert this. this.playerReputation.put(findUUID(nbttagcompound1.getString("Name")), Integer.valueOf(nbttagcompound1.getInteger("S"))); } } if (this.capabilities != null && compound.hasKey("ForgeCaps")) this.capabilities.deserializeNBT(compound.getCompoundTag("ForgeCaps")); }
Example 19
Source File: AspectList.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public void readFromNBT(NBTTagCompound nbttagcompound, String label) { aspects.clear(); NBTTagList tlist = nbttagcompound.getTagList(label,(byte)10); for (int j = 0; j < tlist.tagCount(); j++) { NBTTagCompound rs = (NBTTagCompound) tlist.getCompoundTagAt(j); if (rs.hasKey("key")) { add( Aspect.getAspect(rs.getString("key")), rs.getInteger("amount")); } } }
Example 20
Source File: VanillaStructure.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected boolean readBlocksFromTag(NBTTagCompound tag) { if (tag.hasKey("palette", Constants.NBT.TAG_LIST) && tag.hasKey("blocks", Constants.NBT.TAG_LIST) && isSizeValid(this.getSize())) { NBTTagList paletteTag = tag.getTagList("palette", Constants.NBT.TAG_COMPOUND); LitematicaBlockStateContainerSparse container = (LitematicaBlockStateContainerSparse) this.blockContainer; ILitematicaBlockStatePalette palette = container.getPalette(); if (this.readPaletteFromLitematicaFormatTag(paletteTag, palette) == false) { InfoUtils.printErrorMessage("litematica.message.error.schematic_read.vanilla.failed_to_read_palette"); return false; } if (tag.hasKey("author", Constants.NBT.TAG_STRING)) { this.getMetadata().setAuthor(tag.getString("author")); } NBTTagList blockList = tag.getTagList("blocks", Constants.NBT.TAG_COMPOUND); final int count = blockList.tagCount(); for (int i = 0; i < count; ++i) { NBTTagCompound blockTag = blockList.getCompoundTagAt(i); BlockPos pos = NBTUtils.readBlockPosFromListTag(blockTag, "pos"); if (pos == null) { InfoUtils.printErrorMessage("litematica.message.error.schematic_read.vanilla.failed_to_read_block_pos"); return false; } int id = blockTag.getInteger("state"); IBlockState state = palette.getBlockState(id); if (state == null) { state = Blocks.AIR.getDefaultState(); } container.setBlockState(pos.getX(), pos.getY(), pos.getZ(), state); if (blockTag.hasKey("nbt", Constants.NBT.TAG_COMPOUND)) { this.blockEntities.put(pos, blockTag.getCompoundTag("nbt")); } } return true; } return false; }