Search in sources :

Example 1 with BlockEntitySkull

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

the class BlockSkull method place.

@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    switch(face) {
        case NORTH:
        case SOUTH:
        case EAST:
        case WEST:
        case UP:
            this.setDamage(face.getIndex());
            break;
        case DOWN:
        default:
            return false;
    }
    this.getLevel().setBlock(block, this, true, true);
    CompoundTag nbt = new CompoundTag().putString("id", BlockEntity.SKULL).putByte("SkullType", item.getDamage()).putInt("x", block.getFloorX()).putInt("y", block.getFloorY()).putInt("z", block.getFloorZ()).putByte("Rot", (int) Math.floor((player.yaw * 16 / 360) + 0.5) & 0x0f);
    if (item.hasCustomBlockData()) {
        for (Tag aTag : item.getCustomBlockData().getAllTags()) {
            nbt.put(aTag.getName(), aTag);
        }
    }
    new BlockEntitySkull(getLevel().getChunk((int) block.x >> 4, (int) block.z >> 4), nbt);
    return true;
}
Also used : CompoundTag(cn.nukkit.nbt.tag.CompoundTag) Tag(cn.nukkit.nbt.tag.Tag) CompoundTag(cn.nukkit.nbt.tag.CompoundTag) BlockEntitySkull(cn.nukkit.blockentity.BlockEntitySkull)

Aggregations

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