Java Code Examples for net.minecraft.nbt.CompoundNBT#putInt()
The following examples show how to use
net.minecraft.nbt.CompoundNBT#putInt() .
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: RenderBlockTileEntity.java From MiningGadgets with MIT License | 6 votes |
@Override public CompoundNBT write(CompoundNBT tag) { if (renderBlock!= null) tag.put("renderBlock", NBTUtil.writeBlockState(renderBlock)); tag.putInt("originalDurability", originalDurability); tag.putInt("priorDurability", priorDurability); tag.putInt("durability", durability); tag.putInt("ticksSinceMine", ticksSinceMine); if (!playerUUID.equals(null)) tag.putUniqueId("playerUUID", playerUUID); tag.put("upgrades", UpgradeTools.setUpgradesNBT(gadgetUpgrades).getList("upgrades", Constants.NBT.TAG_COMPOUND)); tag.putByte("breakType", (byte) breakType.ordinal()); tag.put("gadgetFilters", MiningProperties.serializeItemStackList(getGadgetFilters())); tag.putBoolean("gadgetIsWhitelist", isGadgetIsWhitelist()); tag.putBoolean("blockAllowed", blockAllowed); return super.write(tag); }
Example 2
Source File: InventoryUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 6 votes |
/** * NBT item saving function with support for stack sizes > 32K */ public static ListNBT writeItemStacksToTag(ItemStack[] items, int maxQuantity) { ListNBT tagList = new ListNBT(); for (int i = 0; i < items.length; i++) { CompoundNBT tag = new CompoundNBT(); tag.putShort("Slot", (short) i); items[i].write(tag); if (maxQuantity > Short.MAX_VALUE) { tag.putInt("Quantity", items[i].getCount()); } else if (maxQuantity > Byte.MAX_VALUE) { tag.putShort("Quantity", (short) items[i].getCount()); } tagList.add(tag); } return tagList; }
Example 3
Source File: CmdEnchant.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") public void enchant(ItemStack item, Enchantment e, int level) { if (item.getTag() == null) item.setTag(new CompoundNBT()); if (!item.getTag().contains("Enchantments", 9)) { item.getTag().put("Enchantments", new ListNBT()); } ListNBT listnbt = item.getTag().getList("Enchantments", 10); CompoundNBT compoundnbt = new CompoundNBT(); compoundnbt.putString("id", String.valueOf(Registry.ENCHANTMENT.getKey(e))); compoundnbt.putInt("lvl", level); listnbt.add(compoundnbt); }
Example 4
Source File: PacketDurabilitySync.java From MiningGadgets with MIT License | 5 votes |
public static void encode(PacketDurabilitySync msg, PacketBuffer buffer) { List<Tuple<BlockPos, Integer>> thisList = msg.updateList; CompoundNBT tag = new CompoundNBT(); ListNBT nbtList = new ListNBT(); for (int i = 0; i < thisList.size(); i++) { CompoundNBT nbt = new CompoundNBT(); nbt.put("pos", NBTUtil.writeBlockPos(thisList.get(i).getA())); nbt.putInt("dur", thisList.get(i).getB()); nbtList.add(i, nbt); } tag.put("list", nbtList); buffer.writeCompoundTag(tag); }
Example 5
Source File: Frequency.java From EnderStorage with MIT License | 5 votes |
protected CompoundNBT write_internal(CompoundNBT tagCompound) { tagCompound.putInt("left", left.getWoolMeta()); tagCompound.putInt("middle", middle.getWoolMeta()); tagCompound.putInt("right", right.getWoolMeta()); if (owner != null) { tagCompound.putUniqueId("owner", owner); } if (ownerName != null) { tagCompound.putString("owner_name", ITextComponent.Serializer.toJson(ownerName)); } return tagCompound; }
Example 6
Source File: SawmillTileEntity.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public CompoundNBT write(CompoundNBT compound) { compound = super.write(compound); compound.put("Items", ITEMS_CAP.writeNBT(inventory, null)); compound.putInt("BurnTime", (short) this.remainingBurnTime); compound.putInt("CookTime", (short) this.cookTime); return compound; }