Java Code Examples for net.minecraft.nbt.NBTTagCompound#setTag()
The following examples show how to use
net.minecraft.nbt.NBTTagCompound#setTag() .
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: TileEntityHelm.java From archimedes-ships with MIT License | 6 votes |
@Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("meta", blockMetadata); compound.setString("name", info.shipName); if (activeShip != null && !activeShip.isDead) { compound.setInteger("ship", activeShip.getEntityId()); } if (assembleResult != null) { NBTTagCompound comp = new NBTTagCompound(); assembleResult.writeNBTFully(comp); compound.setTag("res", comp); } }
Example 2
Source File: TileEntityEnderUtilities.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
/** * Get the data used for syncing the TileEntity to the client. * The data returned from this method doesn't have the position, * the position will be added in getUpdateTag() which calls this method. */ public NBTTagCompound getUpdatePacketTag(NBTTagCompound nbt) { nbt.setByte("r", (byte)(this.facing.getIndex() & 0x07)); if (this.camoState != null) { nbt.setInteger("Camo", Block.getStateId(this.camoState)); if (this.camoData != null) { nbt.setTag("CD", this.camoData); } } if (this.ownerData != null) { nbt.setString("o", this.ownerData.getOwnerName()); nbt.setBoolean("pu", this.ownerData.getIsPublic()); } return nbt; }
Example 3
Source File: TileEntitySword.java From Artifacts with MIT License | 6 votes |
@Override public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.contents.length; ++i) { if (this.contents[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); this.contents [i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } par1NBTTagCompound.setTag("Items", nbttaglist); par1NBTTagCompound.setInteger("Meta", metadata); }
Example 4
Source File: TileExtendedNode.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void writeCustomNBT(NBTTagCompound nbttagcompound) { super.writeCustomNBT(nbttagcompound); NBTTagCompound compound = new NBTTagCompound(); if(extendedNodeType != null) { compound.setString("exNodeType", extendedNodeType.name()); if(extendedNodeType == ExtendedNodeType.GROWING) { NBTTagCompound behaviorCompound = new NBTTagCompound(); behavior.writeToNBT(behaviorCompound); compound.setTag("NodeBehavior", behaviorCompound); } } nbttagcompound.setTag("Gadomancy", compound); }
Example 5
Source File: TileEntitySurgery.java From Cyberware with MIT License | 6 votes |
@Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound = super.writeToNBT(compound); compound.setInteger("essence", essence); compound.setInteger("maxEssence", maxEssence); compound.setInteger("lastEntity", lastEntity); compound.setBoolean("missingPower", missingPower); compound.setTag("inv", this.slots.serializeNBT()); compound.setTag("inv2", this.slotsPlayer.serializeNBT()); NBTTagList list = new NBTTagList(); for (int i = 0; i < this.discardSlots.length; i++) { list.appendTag(new NBTTagByte((byte) (this.discardSlots[i] ? 1 : 0))); } compound.setTag("discard", list); return compound; }
Example 6
Source File: BCRecipes.java From SimplyJetpacks with MIT License | 5 votes |
public static void addAssemblyRecipe(String recipeId, int energy, ItemStack[] inputs, ItemStack output) { SimplyJetpacks.logger.info("Registering BC Assembly Table recipe"); NBTTagCompound toSend = new NBTTagCompound(); toSend.setString("id", "simplyjetpacks:" + recipeId); toSend.setInteger("energy", energy); NBTTagList inputsList = new NBTTagList(); for (ItemStack stack : inputs) { inputsList.appendTag(stack.writeToNBT(new NBTTagCompound())); } toSend.setTag("input", inputsList); toSend.setTag("output", output.writeToNBT(new NBTTagCompound())); FMLInterModComms.sendMessage("BuildCraft|Core", "add-assembly-recipe", toSend); }
Example 7
Source File: FWTile.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setString("novaID", blockID); if (block != null) { if (block instanceof Storable) { Data data = new Data(); ((Storable) block).save(data); nbt.setTag("nova", DataConverter.instance().toNative(data)); } } }
Example 8
Source File: ItemPanelDumper.java From NotEnoughItems with MIT License | 5 votes |
public void dumpNBT(File file) throws IOException { NBTTagList list = new NBTTagList(); for (ItemStack stack : ItemPanel.items) list.appendTag(stack.writeToNBT(new NBTTagCompound())); NBTTagCompound tag = new NBTTagCompound(); tag.setTag("list", list); CompressedStreamTools.writeCompressed(tag, new FileOutputStream(file)); }
Example 9
Source File: DataConverter.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
/** * Saves an unknown object to NBT * @param tag - NBTTagCompound to queueSave the tag too * @param key - name to queueSave the object as * @param value - the actual object * @return the tag when done saving too i */ public NBTTagCompound save(NBTTagCompound tag, String key, Object value) { if (value instanceof Boolean) { tag.setBoolean(key + "::nova.isBoolean", true); tag.setBoolean(key, (boolean) value); } else if (value instanceof Byte) { tag.setBoolean(key + "::nova.isBoolean", false); tag.setByte(key, (byte) value); } else if (value instanceof Short) { tag.setShort(key, (short) value); } else if (value instanceof Integer) { tag.setInteger(key, (int) value); } else if (value instanceof Long) { tag.setLong(key, (long) value); } else if (value instanceof Character) { tag.setInteger(key, (Character) value); } else if (value instanceof Float) { tag.setFloat(key, (float) value); } else if (value instanceof Double) { tag.setDouble(key, (double) value); } else if (value instanceof BigInteger) { tag.setBoolean(key + "::nova.isBigInteger", true); tag.setString(key, ((BigInteger) value).toString()); } else if (value instanceof BigDecimal) { tag.setBoolean(key + "::nova.isBigDecimal", true); tag.setString(key, ((BigDecimal) value).toString()); } else if (value instanceof String) { tag.setString(key, (String) value); } else if (value instanceof Data) { NBTTagCompound innerTag = new NBTTagCompound(); toNative(innerTag, (Data) value); tag.setTag(key, innerTag); } return tag; }
Example 10
Source File: ItemFocusBasic.java From GardenCollection with MIT License | 5 votes |
private void setFocusUpgradeTagList(ItemStack focusstack, short[] upgrades) { if (!focusstack.hasTagCompound()) focusstack.setTagCompound(new NBTTagCompound()); NBTTagCompound nbttagcompound = focusstack.getTagCompound(); NBTTagList tlist = new NBTTagList(); nbttagcompound.setTag("upgrade", tlist); for (short id : upgrades) { NBTTagCompound f = new NBTTagCompound(); f.setShort("id", id); tlist.appendTag(f); } }
Example 11
Source File: SpongeSchematic.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
protected void writeBlocksToTag(NBTTagCompound tag) { NBTTagCompound paletteTag = this.writePaletteToTag(this.blockContainer.getPalette().getMapping()); byte[] blockData = ((LitematicaBlockStateContainerFull) this.blockContainer).getBackingArrayAsByteArray(); tag.setTag("Palette", paletteTag); tag.setByteArray("BlockData", blockData); }
Example 12
Source File: CraftOfflinePlayer.java From Thermos with GNU General Public License v3.0 | 5 votes |
private NBTTagCompound getBukkitData() { NBTTagCompound result = getData(); if (result != null) { if (!result.hasKey("bukkit")) { result.setTag("bukkit", new net.minecraft.nbt.NBTTagCompound()); } result = result.getCompoundTag("bukkit"); } return result; }
Example 13
Source File: GuidanceComputer.java From AdvancedRocketry with MIT License | 5 votes |
public void writeToNBT(NBTTagCompound nbt) { if(inv != null) { NBTTagCompound itemNbt = new NBTTagCompound(); inv.writeToNBT(itemNbt); nbt.setTag(destinationSlot, itemNbt); } }
Example 14
Source File: EntityItemAbducted.java From AdvancedRocketry with MIT License | 5 votes |
/** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound p_70014_1_) { p_70014_1_.setShort("Age", (short)this.age); p_70014_1_.setInteger("Lifespan", lifespan); if (this.getEntityItem() != null) { p_70014_1_.setTag("Item", this.getEntityItem().writeToNBT(new NBTTagCompound())); } }
Example 15
Source File: TileSlot.java From Production-Line with MIT License | 5 votes |
public NBTTagCompound writeToNBT(NBTTagCompound nbt) { NBTTagCompound nbtTagCompound = new NBTTagCompound(); if (this.item != null) { this.item.writeToNBT(nbtTagCompound); } nbt.setTag("TileSlot", nbtTagCompound); return nbt; }
Example 16
Source File: TileEntityTofuBattery.java From TofuCraftReload with MIT License | 5 votes |
@Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { NBTTagCompound input = inputTank.writeToNBT(new NBTTagCompound()); NBTTagCompound output = outputTank.writeToNBT(new NBTTagCompound()); compound.setTag(TAG_INPUT_TANK, input); compound.setTag(TAG_OUTPUT_TANK, output); return super.writeToNBT(compound); }
Example 17
Source File: SchematicBlock.java From Framez with GNU General Public License v3.0 | 5 votes |
protected void writeRequirementsToNBT(NBTTagCompound nbt, MappingRegistry registry) { if (storedRequirements.length > 0) { NBTTagList rq = new NBTTagList(); for (ItemStack stack : storedRequirements) { NBTTagCompound sub = new NBTTagCompound(); stack.writeToNBT(sub); registry.stackToRegistry(sub); rq.appendTag(sub); } nbt.setTag("rq", rq); } }
Example 18
Source File: TileEntityBusFluidExport.java From ExtraCells1 with MIT License | 5 votes |
@Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setTag("Items", inventory.writeToNBT()); if (getInventory().isInvNameLocalized()) { nbt.setString("CustomName", this.customName); } nbt.setInteger("RedstoneMode", getRedstoneMode().ordinal()); nbt.setInteger("FluidMode", getFluidMode().ordinal()); nbt.setBoolean("RedstoneState", redstoneStatus); }
Example 19
Source File: PlacementProperties.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private NBTTagCompound writeToNBT(NBTTagCompound nbt) { NBTTagList tagListPlayers = new NBTTagList(); for (Map.Entry<UUID, Map<ItemType, NBTTagCompound>> playerEntry : this.properties.entrySet()) { tagListPlayers.appendTag(this.writeDataForPlayerToNBT(playerEntry.getKey(), playerEntry.getValue())); } nbt.setTag("PlacementProperties", tagListPlayers); return nbt; }
Example 20
Source File: ItemRuler.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
/** * Writes the given block position to the selected module, to the selected position. * If the given position is null, or is equal to the stored position, then the position is removed. */ public void setOrRemovePosition(ItemStack rulerStack, BlockPosEU pos, boolean isPos1, boolean adjustPosition) { ItemStack moduleStack = this.getSelectedModuleStack(rulerStack, ModuleType.TYPE_MEMORY_CARD_MISC); if (moduleStack.isEmpty() == false) { if (adjustPosition) { pos = pos.offset(pos.getFacing()); } int selected = this.getLocationSelection(rulerStack); NBTTagList tagList = NBTUtils.getTagList(moduleStack, TAG_WRAPPER, TAG_LOCATIONS, Constants.NBT.TAG_COMPOUND, true); if (selected >= tagList.tagCount()) { tagList.appendTag(new NBTTagCompound()); } NBTTagCompound tag = tagList.getCompoundTagAt(selected); String tagName = isPos1 ? "Pos1" : "Pos2"; BlockPosEU oldPos = BlockPosEU.readFromTag(tag.getCompoundTag(tagName)); if (pos == null || pos.equals(oldPos)) { tag.removeTag(tagName); } else { tag.setTag(tagName, pos.writeToTag(new NBTTagCompound())); } 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); } }