Java Code Examples for net.minecraft.nbt.CompoundTag#putString()
The following examples show how to use
net.minecraft.nbt.CompoundTag#putString() .
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: ConfigurableElectricMachineBlockEntity.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public CompoundTag toTag(CompoundTag tag) { super.toTag(tag); tag.putString("Redstone", redstoneState.asString()); this.capacitorComponent.toTag(tag); this.inventory.toTag(tag); this.security.toTag(tag); return tag; }
Example 2
Source File: ConfigurableElectricMachineBlockEntity.java From Galacticraft-Rewoven with MIT License | 5 votes |
public CompoundTag toTag(CompoundTag tag) { CompoundTag compoundTag = new CompoundTag(); if (this.hasOwner()) { compoundTag.putUuid("owner", this.owner); } compoundTag.putString("username", this.username); compoundTag.putString("publicity", this.publicity.asString()); if (this.hasTeam()) { compoundTag.putString("team", team.toString()); } tag.put("security", compoundTag); return tag; }
Example 3
Source File: InfusionAltarBlockEntity.java From the-hallow with MIT License | 5 votes |
@Override public CompoundTag toTag(CompoundTag entityTag) { super.toTag(entityTag); if (!storedStack.isEmpty()) { entityTag.putString("stored_item", Registry.ITEM.getId(storedStack.getItem()).toString()); } return entityTag; }
Example 4
Source File: InfusionPillarBlockEntity.java From the-hallow with MIT License | 5 votes |
@Override public CompoundTag toTag(CompoundTag entityTag) { super.toTag(entityTag); if (!storedStack.isEmpty()) { entityTag.putString("stored_item", Registry.ITEM.getId(storedStack.getItem()).toString()); } return entityTag; }
Example 5
Source File: Items_1_12_2.java From multiconnect with MIT License | 5 votes |
private static void oldEnchantmentListToNew(ListTag enchantments) { for (int i = 0; i < enchantments.size(); i++) { CompoundTag ench = enchantments.getCompound(i); int id = ench.getInt("id"); Identifier name = Registry.ENCHANTMENT.getId(Registry.ENCHANTMENT.get(id)); if (name == null) { enchantments.remove(i); i--; } else { ench.putString("id", name.toString()); } } }
Example 6
Source File: CmdEnchant.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public void enchant(ItemStack item, Enchantment e, int level) { if (item.getTag() == null) item.setTag(new CompoundTag()); if (!item.getTag().containsKey("Enchantments", 9)) { item.getTag().put("Enchantments", new ListTag()); } ListTag listnbt = item.getTag().getList("Enchantments", 10); CompoundTag compoundnbt = new CompoundTag(); compoundnbt.putString("id", String.valueOf(Registry.ENCHANTMENT.getId(e))); compoundnbt.putInt("lvl", level); listnbt.add(compoundnbt); }
Example 7
Source File: CmdEnchant.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public void enchant(ItemStack item, Enchantment e, int level) { if (item.getTag() == null) item.setTag(new CompoundTag()); if (!item.getTag().contains("Enchantments", 9)) { item.getTag().put("Enchantments", new ListTag()); } ListTag listnbt = item.getTag().getList("Enchantments", 10); CompoundTag compoundnbt = new CompoundTag(); compoundnbt.putString("id", String.valueOf(Registry.ENCHANTMENT.getId(e))); compoundnbt.putInt("lvl", level); listnbt.add(compoundnbt); }
Example 8
Source File: CmdEnchant.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
public void enchant(ItemStack item, Enchantment e, int level) { if (item.getTag() == null) item.setTag(new CompoundTag()); if (!item.getTag().contains("Enchantments", 9)) { item.getTag().put("Enchantments", new ListTag()); } ListTag listnbt = item.getTag().getList("Enchantments", 10); CompoundTag compoundnbt = new CompoundTag(); compoundnbt.putString("id", String.valueOf(Registry.ENCHANTMENT.getId(e))); compoundnbt.putInt("lvl", level); listnbt.add(compoundnbt); }
Example 9
Source File: ClientNetworkHandler.java From fabric-carpet with MIT License | 5 votes |
public static void clientCommand(String command) { CompoundTag tag = new CompoundTag(); tag.putString("id", command); tag.putString("command", command); CompoundTag outer = new CompoundTag(); outer.put("clientCommand", tag); CarpetClient.getPlayer().networkHandler.sendPacket(new CustomPayloadC2SPacket( CarpetClient.CARPET_CHANNEL, (new PacketByteBuf(Unpooled.buffer())).writeVarInt(CarpetClient.DATA).writeCompoundTag(outer) )); }