Java Code Examples for net.minecraft.nbt.NBTTagList
The following examples show how to use
net.minecraft.nbt.NBTTagList. These examples are extracted from open source projects.
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 Project: litematica Source File: MaterialCache.java License: 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 2
Source Project: PneumaticCraft Source File: TileEntityAssemblyPlatform.java License: GNU General Public License v3.0 | 6 votes |
@Override public void writeToNBT(NBTTagCompound tag){ super.writeToNBT(tag); tag.setBoolean("clawClosing", shouldClawClose); tag.setFloat("clawProgress", clawProgress); tag.setFloat("speed", speed); tag.setBoolean("drilled", hasDrilledStack); tag.setBoolean("lasered", hasLaseredStack); // 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 3
Source Project: NotEnoughItems Source File: ContainerPotionCreator.java License: 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(); Potion effect = Potion.getPotionById(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.getPotion() != effect) { newEffects.appendTag(tag); } } if (add) { newEffects.appendTag(new PotionEffect(effect, packet.readInt(), packet.readUByte()).writeCustomPotionEffectToNBT(new NBTTagCompound())); } potion.getTagCompound().setTag("CustomPotionEffects", newEffects); }
Example 4
Source Project: PneumaticCraft Source File: HackableHandler.java License: 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 Project: Gadomancy Source File: GrowingNodeBehavior.java License: GNU Lesser General Public License v3.0 | 6 votes |
public void writeToNBT(NBTTagCompound nbtTagCompound) { nbtTagCompound.setBoolean("overallSaturated", isSaturated); nbtTagCompound.setDouble("overallHappiness", overallHappiness); if(lastFedAspect != null) { nbtTagCompound.setString("lastFedAspect", lastFedAspect.getTag()); nbtTagCompound.setInteger("lastFedRow", lastFedRow); } NBTTagList list = new NBTTagList(); for(Aspect a : aspectSaturation.keySet()) { double saturation = aspectSaturation.get(a); NBTTagCompound compound = new NBTTagCompound(); compound.setString("aspectName", a.getTag()); compound.setDouble("aspectSaturation", saturation); list.appendTag(compound); } nbtTagCompound.setTag("saturationValues", list); }
Example 6
Source Project: enderutilities Source File: ItemRuler.java License: GNU Lesser General Public License v3.0 | 6 votes |
public void toggleAlwaysRenderSelectedLocation(ItemStack rulerStack) { ItemStack moduleStack = this.getSelectedModuleStack(rulerStack, ModuleType.TYPE_MEMORY_CARD_MISC); if (moduleStack.isEmpty() == false) { int selected = this.getLocationSelection(rulerStack); NBTTagList tagList = NBTUtils.getTagList(moduleStack, TAG_WRAPPER, TAG_LOCATIONS, Constants.NBT.TAG_COMPOUND, true); NBTTagCompound tag = tagList.getCompoundTagAt(selected); NBTUtils.toggleBoolean(tag, TAG_RENDER_WITH_ALL); if (selected >= tagList.tagCount()) { tagList = NBTUtils.insertToTagList(tagList, tag, selected); } else { tagList.set(selected, tag); } NBTUtils.setTagList(moduleStack, TAG_WRAPPER, TAG_LOCATIONS, tagList); this.setSelectedModuleStack(rulerStack, ModuleType.TYPE_MEMORY_CARD_MISC, moduleStack); } }
Example 7
Source Project: PneumaticCraft Source File: TileEntityOmnidirectionalHopper.java License: 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 8
Source Project: Wizardry Source File: PacketSendSpellToBook.java License: 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 9
Source Project: PneumaticCraft Source File: SemiBlockManager.java License: 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 10
Source Project: GardenCollection Source File: TileEntityBloomeryFurnace.java License: MIT License | 6 votes |
@Override public void readFromNBT (NBTTagCompound tag) { super.readFromNBT(tag); NBTTagList list = tag.getTagList("Items", Constants.NBT.TAG_COMPOUND); furnaceItemStacks = new ItemStack[getSizeInventory()]; for (int i = 0, n = list.tagCount(); i < n; i++) { NBTTagCompound itemTag = list.getCompoundTagAt(i); byte slot = itemTag.getByte("Slot"); if (slot >= 0 && slot < furnaceItemStacks.length) furnaceItemStacks[slot] = ItemStack.loadItemStackFromNBT(itemTag); } furnaceBurnTime = tag.getShort("BurnTime"); furnaceCookTime = tag.getShort("CookTime"); currentItemBurnTime = getItemBurnTime(furnaceItemStacks[SLOT_FUEL]); if (tag.hasKey("CustomName", Constants.NBT.TAG_STRING)) customName = tag.getString("CustomName"); }
Example 11
Source Project: OpenPeripheral-Integration Source File: ModuleVanilla.java License: 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 12
Source Project: GregTech Source File: MetaTileEntityPrimitiveBlastFurnace.java License: 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 13
Source Project: PneumaticCraft Source File: TileEntityAirCompressor.java License: 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 14
Source Project: mocreaturesdev Source File: MoCEntityWyvern.java License: 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 15
Source Project: NotEnoughItems Source File: ContainerPotionCreator.java License: 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 16
Source Project: Logistics-Pipes-2 Source File: LPRoutedItem.java License: 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 17
Source Project: PneumaticCraft Source File: TileEntityVacuumPump.java License: 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 18
Source Project: PneumaticCraft Source File: TileEntityAssemblyIOUnit.java License: 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 19
Source Project: AdvancedMod Source File: TileEntityCamoMine.java License: 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 20
Source Project: Minecoprocessors Source File: Processor.java License: 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 21
Source Project: ToroQuest Source File: PlayerCivilization.java License: 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 22
Source Project: NewHorizonsCoreMod Source File: TileEntityBabyChest.java License: 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 23
Source Project: PneumaticCraft Source File: TileEntityElevatorBase.java License: 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 24
Source Project: PneumaticCraft Source File: TileEntityAerialInterface.java License: 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 25
Source Project: archimedes-ships Source File: MsgTileEntities.java License: 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 26
Source Project: PneumaticCraft Source File: DateEventHandler.java License: 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 27
Source Project: Gadomancy Source File: TileArcanePackager.java License: 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 28
Source Project: AgriCraft Source File: TileEntitySeedStorage.java License: 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 29
Source Project: Framez Source File: FrameMovementRegistry.java License: 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 30
Source Project: Kettle Source File: CraftMetaFirework.java License: 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))); } }