Java Code Examples for cn.nukkit.nbt.tag.CompoundTag#getShort()
The following examples show how to use
cn.nukkit.nbt.tag.CompoundTag#getShort() .
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: Item.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public Enchantment getEnchantment(short id) { if (!this.hasEnchantments()) { return null; } for (CompoundTag entry : this.getNamedTag().getList("ench", CompoundTag.class).getAll()) { if (entry.getShort("id") == id) { Enchantment e = Enchantment.getEnchantment(entry.getShort("id")); if (e != null) { e.setLevel(entry.getShort("lvl")); return e; } } } return null; }
Example 2
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 3
Source File: Item.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public Enchantment getEnchantment(short id) { if (!this.hasEnchantments()) { return null; } for (CompoundTag entry : this.getNamedTag().getList("ench", CompoundTag.class).getAll()) { if (entry.getShort("id") == id) { Enchantment e = Enchantment.getEnchantment(entry.getShort("id")); if (e != null) { e.setLevel(entry.getShort("lvl"), false); return e; } } } return null; }
Example 4
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 5
Source File: Item.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public Enchantment getEnchantment(short id) { if (!this.hasEnchantments()) { return null; } for (CompoundTag entry : this.getNamedTag().getList("ench", CompoundTag.class).getAll()) { if (entry.getShort("id") == id) { Enchantment e = Enchantment.getEnchantment(entry.getShort("id")); if (e != null) { e.setLevel(entry.getShort("lvl")); return e; } } } return null; }
Example 6
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()); }