Java Code Examples for cn.nukkit.nbt.tag.CompoundTag#setName()
The following examples show how to use
cn.nukkit.nbt.tag.CompoundTag#setName() .
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: BlockEntityItemFrame.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public CompoundTag getSpawnCompound() { if (!this.namedTag.contains("Item")) { this.setItem(new ItemBlock(new BlockAir()), false); } CompoundTag NBTItem = namedTag.getCompound("Item").copy(); NBTItem.setName("Item"); boolean item = NBTItem.getShort("id") == Item.AIR; return new CompoundTag() .putString("id", BlockEntity.ITEM_FRAME) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z) .putCompound("Item", item ? NBTIO.putItemHelper(new ItemBlock(new BlockAir())) : NBTItem) .putByte("ItemRotation", item ? 0 : this.getItemRotation()); // TODO: This crashes the client, why? // .putFloat("ItemDropChance", this.getItemDropChance()); }
Example 2
Source File: BlockEntityItemFrame.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public CompoundTag getSpawnCompound() { if (!this.namedTag.contains("Item")) { this.setItem(new ItemBlock(Block.get(BlockID.AIR)), false); } CompoundTag item = namedTag.getCompound("Item").copy(); item.setName("Item"); CompoundTag tag = new CompoundTag() .putString("id", BlockEntity.ITEM_FRAME) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z); if (item.getShort("id") != Item.AIR) { tag.putCompound("Item", item) .putByte("ItemRotation", this.getItemRotation()); } return tag; }
Example 3
Source File: BlockEntityItemFrame.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public CompoundTag getSpawnCompound() { if (!this.namedTag.contains("Item")) { this.setItem(new ItemBlock(new BlockAir()), false); } CompoundTag NBTItem = namedTag.getCompound("Item").copy(); NBTItem.setName("Item"); boolean item = NBTItem.getShort("id") == Item.AIR; return new CompoundTag() .putString("id", BlockEntity.ITEM_FRAME) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z) .putCompound("Item", item ? NBTIO.putItemHelper(new ItemBlock(new BlockAir())) : NBTItem) .putByte("ItemRotation", item ? 0 : this.getItemRotation()); // TODO: This crashes the client, why? // .putFloat("ItemDropChance", this.getItemDropChance()); }
Example 4
Source File: NBTIO.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public static Item getItemHelper(CompoundTag tag) { if (!tag.contains("id") || !tag.contains("Count")) { return Item.get(0); } Item item = Item.get(tag.getShort("id"), !tag.contains("Damage") ? 0 : tag.getShort("Damage"), tag.getByte("Count")); if (tag.contains("tag") && tag.get("tag") instanceof CompoundTag) { CompoundTag nbt = tag.getCompound("tag").clone(); nbt.setName(""); item.setNamedTag(nbt); } return item; }
Example 5
Source File: Item.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public byte[] writeCompoundTag(CompoundTag tag) { try { tag.setName(""); return NBTIO.write(tag, ByteOrder.LITTLE_ENDIAN); } catch (IOException e) { throw new RuntimeException(e); } }
Example 6
Source File: Item.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public Item setNamedTag(CompoundTag tag) { if (tag.isEmpty()) { return this.clearNamedTag(); } tag.setName(null); this.cachedNBT = tag; this.tags = writeCompoundTag(tag); return this; }
Example 7
Source File: Item.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public Item setNamedTag(CompoundTag tag) { if (tag.isEmpty()) { return this.clearNamedTag(); } tag.setName(null); this.cachedNBT = tag; this.tags = writeCompoundTag(tag); return this; }
Example 8
Source File: Item.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public byte[] writeCompoundTag(CompoundTag tag) { try { tag.setName(""); return NBTIO.write(tag, ByteOrder.LITTLE_ENDIAN); } catch (IOException e) { throw new RuntimeException(e); } }
Example 9
Source File: Item.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public Item setNamedTag(CompoundTag tag) { if (tag.isEmpty()) { return this.clearNamedTag(); } tag.setName(null); this.cachedNBT = tag; this.tags = writeCompoundTag(tag); return this; }
Example 10
Source File: Item.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public byte[] writeCompoundTag(CompoundTag tag) { try { tag.setName(""); return NBTIO.write(tag, ByteOrder.LITTLE_ENDIAN); } catch (IOException e) { throw new RuntimeException(e); } }