use of cn.nukkit.nbt.tag.StringTag in project Nukkit by Nukkit.
the class BlockEnderChest method onActivate.
@Override
public boolean onActivate(Item item, Player player) {
if (player != null) {
Block top = this.up();
if (!top.isTransparent()) {
return true;
}
BlockEntity t = this.getLevel().getBlockEntity(this);
BlockEntityEnderChest chest;
if (t instanceof BlockEntityEnderChest) {
chest = (BlockEntityEnderChest) t;
} else {
CompoundTag nbt = new CompoundTag("").putString("id", BlockEntity.ENDER_CHEST).putInt("x", (int) this.x).putInt("y", (int) this.y).putInt("z", (int) this.z);
chest = new BlockEntityEnderChest(this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt);
}
if (chest.namedTag.contains("Lock") && chest.namedTag.get("Lock") instanceof StringTag) {
if (!chest.namedTag.getString("Lock").equals(item.getCustomName())) {
return true;
}
}
player.setViewingEnderChest(this);
player.addWindow(player.getEnderChestInventory());
}
return true;
}
use of cn.nukkit.nbt.tag.StringTag in project Nukkit by Nukkit.
the class BlockEnchantingTable method onActivate.
@Override
public boolean onActivate(Item item, Player player) {
if (player != null) {
BlockEntity t = this.getLevel().getBlockEntity(this);
BlockEntityEnchantTable enchantTable;
if (t instanceof BlockEntityEnchantTable) {
enchantTable = (BlockEntityEnchantTable) t;
} else {
CompoundTag nbt = new CompoundTag().putList(new ListTag<>("Items")).putString("id", BlockEntity.ENCHANT_TABLE).putInt("x", (int) this.x).putInt("y", (int) this.y).putInt("z", (int) this.z);
enchantTable = new BlockEntityEnchantTable(this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt);
}
if (enchantTable.namedTag.contains("Lock") && enchantTable.namedTag.get("Lock") instanceof StringTag) {
if (!enchantTable.namedTag.getString("Lock").equals(item.getCustomName())) {
return true;
}
}
player.addWindow(new EnchantInventory(this.getLocation()), Player.ENCHANT_WINDOW_ID);
}
return true;
}
Aggregations