use of cn.nukkit.blockentity.BlockEntityBrewingStand in project Nukkit by Nukkit.
the class BlockBrewingStand method place.
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
if (!block.down().isTransparent()) {
getLevel().setBlock(block, this, true, true);
CompoundTag nbt = new CompoundTag().putList(new ListTag<>("Items")).putString("id", BlockEntity.BREWING_STAND).putInt("x", (int) this.x).putInt("y", (int) this.y).putInt("z", (int) this.z);
if (item.hasCustomName()) {
nbt.putString("CustomName", item.getCustomName());
}
if (item.hasCustomBlockData()) {
Map<String, Tag> customData = item.getCustomBlockData().getTags();
for (Map.Entry<String, Tag> tag : customData.entrySet()) {
nbt.put(tag.getKey(), tag.getValue());
}
}
new BlockEntityBrewingStand(getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt);
return true;
}
return false;
}
use of cn.nukkit.blockentity.BlockEntityBrewingStand in project Nukkit by Nukkit.
the class BlockBrewingStand method onActivate.
@Override
public boolean onActivate(Item item, Player player) {
if (player != null) {
BlockEntity t = getLevel().getBlockEntity(this);
BlockEntityBrewingStand brewing;
if (t instanceof BlockEntityBrewingStand) {
brewing = (BlockEntityBrewingStand) t;
} else {
CompoundTag nbt = new CompoundTag().putList(new ListTag<>("Items")).putString("id", BlockEntity.BREWING_STAND).putInt("x", (int) this.x).putInt("y", (int) this.y).putInt("z", (int) this.z);
brewing = new BlockEntityBrewingStand(this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt);
}
if (brewing.namedTag.contains("Lock") && brewing.namedTag.get("Lock") instanceof StringTag) {
if (!brewing.namedTag.getString("Lock").equals(item.getCustomName())) {
return false;
}
}
player.addWindow(brewing.getInventory());
}
return true;
}
Aggregations