Search in sources :

Example 1 with BlockEntitySign

use of cn.nukkit.blockentity.BlockEntitySign in project Nukkit by Nukkit.

the class BlockSignPost method place.

@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    if (face != BlockFace.DOWN) {
        CompoundTag nbt = new CompoundTag().putString("id", BlockEntity.SIGN).putInt("x", (int) block.x).putInt("y", (int) block.y).putInt("z", (int) block.z).putString("Text1", "").putString("Text2", "").putString("Text3", "").putString("Text4", "");
        if (face == BlockFace.UP) {
            setDamage((int) Math.floor(((player.yaw + 180) * 16 / 360) + 0.5) & 0x0f);
            getLevel().setBlock(block, new BlockSignPost(getDamage()), true);
        } else {
            setDamage(face.getIndex());
            getLevel().setBlock(block, new BlockWallSign(getDamage()), true);
        }
        if (player != null) {
            nbt.putString("Creator", player.getUniqueId().toString());
        }
        if (item.hasCustomBlockData()) {
            for (Tag aTag : item.getCustomBlockData().getAllTags()) {
                nbt.put(aTag.getName(), aTag);
            }
        }
        new BlockEntitySign(getLevel().getChunk((int) block.x >> 4, (int) block.z >> 4), nbt);
        return true;
    }
    return false;
}
Also used : BlockEntitySign(cn.nukkit.blockentity.BlockEntitySign) CompoundTag(cn.nukkit.nbt.tag.CompoundTag) Tag(cn.nukkit.nbt.tag.Tag) CompoundTag(cn.nukkit.nbt.tag.CompoundTag)

Aggregations

BlockEntitySign (cn.nukkit.blockentity.BlockEntitySign)1 CompoundTag (cn.nukkit.nbt.tag.CompoundTag)1 Tag (cn.nukkit.nbt.tag.Tag)1