use of cn.nukkit.blockentity.BlockEntityEnchantTable 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