Java Code Examples for net.minecraft.nbt.NBTTagCompound#setCompoundTag()
The following examples show how to use
net.minecraft.nbt.NBTTagCompound#setCompoundTag() .
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: FluidStorageInventoryHandler.java From ExtraCells1 with MIT License | 6 votes |
private void writeFluidStackToSlot(int slotID, FluidStack input) { cachedInventory.set(slotID, input); if (storage.stackTagCompound == null) storage.stackTagCompound = new NBTTagCompound(); NBTTagCompound nbt = storage.stackTagCompound; if (input != null) { NBTTagCompound fluidTag = new NBTTagCompound(); input.writeToNBT(fluidTag); nbt.setCompoundTag("Fluid#" + slotID, fluidTag); } else { nbt.removeTag("Fluid#" + slotID); } }
Example 2
Source File: TileEntityInterfaceFluid.java From ExtraCells1 with MIT License | 6 votes |
@Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setTag("Items", inventory.writeToNBT()); if (getInventory().isInvNameLocalized()) { nbt.setString("CustomName", this.customName); } for (int i = 0; i < tanks.length; i++) { NBTTagCompound tankNBT = new NBTTagCompound(); tanks[i].writeToNBT(tankNBT); nbt.setCompoundTag("tank#" + i, tankNBT); } }
Example 3
Source File: TileEntityTerminalFluid.java From ExtraCells1 with MIT License | 5 votes |
public Packet getDescriptionPacket() { NBTTagCompound nbtTag = getColorDataForPacket(); writeToNBT(nbtTag); NBTTagCompound fluids = new NBTTagCompound(); int[] fluidIDs = new int[fluidsInNetwork.size()]; for (int i = 0; i < fluidsInNetwork.size(); i++) { fluidIDs[i] = fluidsInNetwork.get(i).getID(); fluids.setLong("FluidAmount#" + i, fluidsInNetwork.get(i).getAmount()); } fluids.setIntArray("FluidIDs", fluidIDs); nbtTag.setCompoundTag("fluids", fluids); NBTTagCompound craftableFluids = new NBTTagCompound(); int[] craftableFluidIDs = new int[craftableFluidsInNetwork.size()]; for (int i = 0; i < craftableFluidsInNetwork.size(); i++) { craftableFluidIDs[i] = craftableFluidsInNetwork.get(i).getID(); } craftableFluids.setIntArray("FluidIDs", craftableFluidIDs); nbtTag.setCompoundTag("craftablefluids", craftableFluids); nbtTag.setInteger("currentFluid", currentFluid != null ? currentFluid.getID() : -1); nbtTag.setBoolean("powered", isPowered()); nbtTag.setBoolean("ready", networkReady); return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag); }
Example 4
Source File: TileEntityMEDropper.java From ExtraCells1 with MIT License | 5 votes |
@Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); if (todispense != null) { if (todispense.itemID != 0) nbt.setInteger("ID", todispense.itemID); if (todispense.getItemDamage() != 0) nbt.setInteger("DMG", todispense.getItemDamage()); if (todispense.stackTagCompound != null) nbt.setCompoundTag("NBT", todispense.stackTagCompound); } nbt.setBoolean("LOCKED", locked); }
Example 5
Source File: MoCTools.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
/** * Reduces the counter on the offline player * * @param playername */ public static void reduceTamedByOfflinePlayer(String playername) { NBTTagCompound compound = ((SaveHandler) ((WorldServer) MinecraftServer.getServer().worldServerForDimension(0)).getSaveHandler()).getPlayerData(playername); if (compound != null && compound.hasKey("ForgeData")) { NBTTagCompound nbtt = compound.getCompoundTag("ForgeData"); int count = nbtt.getInteger("NumberTamed"); //System.out.println("tamed entities for player " + playername + " =" + count); count--; if (count < 0) { count = 0; } nbtt.setInteger("NumberTamed", count); compound.setCompoundTag("ForgeData", nbtt); try { SaveHandler saveHandler = ((SaveHandler) ((WorldServer) MinecraftServer.getServer().worldServerForDimension(0)).getSaveHandler()); // as long as we know the world folder name we can generate the path to players directory // still need to test how other worlds will work String playersDirectory = ".\\" + saveHandler.getWorldDirectoryName() + "\\players\\"; File playerFile = new File(playersDirectory + playername + ".dat"); File playerFileNew = new File(playersDirectory, playername + ".tmp"); //System.out.println("playerFile = " + playerFile + ", playerFileNew = " + playerFileNew + ", playerFile parent = " + playerFile.getParent()); CompressedStreamTools.writeCompressed(compound, new FileOutputStream(playerFileNew)); if (playerFile.exists()) { playerFile.delete(); } playerFileNew.renameTo(playerFile); // test to see if changes took effect compound = ((SaveHandler) ((WorldServer) MinecraftServer.getServer().worldServerForDimension(0)).getSaveHandler()).getPlayerData(playername); if (compound.hasKey("ForgeData")) { NBTTagCompound nbttest = compound.getCompoundTag("ForgeData"); //System.out.println("tamed entities for player " + playername + " is now " + nbttest.getInteger("NumberTamed")); } } catch (Exception e) { e.printStackTrace(); } } }