cn.nukkit.blockentity.BlockEntitySkull Java Examples

The following examples show how to use cn.nukkit.blockentity.BlockEntitySkull. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Server.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
private void registerBlockEntities() {
    BlockEntity.registerBlockEntity(BlockEntity.FURNACE, BlockEntityFurnace.class);
    BlockEntity.registerBlockEntity(BlockEntity.CHEST, BlockEntityChest.class);
    BlockEntity.registerBlockEntity(BlockEntity.SIGN, BlockEntitySign.class);
    BlockEntity.registerBlockEntity(BlockEntity.ENCHANT_TABLE, BlockEntityEnchantTable.class);
    BlockEntity.registerBlockEntity(BlockEntity.SKULL, BlockEntitySkull.class);
    BlockEntity.registerBlockEntity(BlockEntity.FLOWER_POT, BlockEntityFlowerPot.class);
    BlockEntity.registerBlockEntity(BlockEntity.BREWING_STAND, BlockEntityBrewingStand.class);
    BlockEntity.registerBlockEntity(BlockEntity.ITEM_FRAME, BlockEntityItemFrame.class);
    BlockEntity.registerBlockEntity(BlockEntity.CAULDRON, BlockEntityCauldron.class);
    BlockEntity.registerBlockEntity(BlockEntity.ENDER_CHEST, BlockEntityEnderChest.class);
    BlockEntity.registerBlockEntity(BlockEntity.BEACON, BlockEntityBeacon.class);
    BlockEntity.registerBlockEntity(BlockEntity.SHULKER_BOX, BlockEntityShulkerBox.class);
    BlockEntity.registerBlockEntity(BlockEntity.MOB_SPAWNER, BlockEntityMobSpawner.class);
    BlockEntity.registerBlockEntity(BlockEntity.DISPENSER, BlockEntityDispenser.class);
    BlockEntity.registerBlockEntity(BlockEntity.DROPPER, BlockEntityDropper.class);
    BlockEntity.registerBlockEntity(BlockEntity.COMMAND_BLOCK, BlockEntityCommandBlock.class);
    BlockEntity.registerBlockEntity(BlockEntity.BANNER, BlockEntityBanner.class);
}
 
Example #2
Source File: BlockSkull.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@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.meta = 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;
}
 
Example #3
Source File: BlockSkull.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@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);
        }
    }
    BlockEntitySkull skull = (BlockEntitySkull) BlockEntity.createBlockEntity(BlockEntity.SKULL, getLevel().getChunk((int) block.x >> 4, (int) block.z >> 4), nbt);
    if (skull == null) {
        return false;
    }

    // TODO: 2016/2/3 SPAWN WITHER

    return true;
}
 
Example #4
Source File: BlockSkull.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@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);

    // TODO: 2016/2/3 SPAWN WITHER

    return true;
}