cn.nukkit.blockentity.BlockEntityEnderChest Java Examples

The following examples show how to use cn.nukkit.blockentity.BlockEntityEnderChest. 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: BlockEnderChest.java    From Jupiter with GNU General Public License v3.0 6 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) {
    int[] faces = {4, 2, 5, 3};
    this.meta = faces[player != null ? player.getDirection().getHorizontalIndex() : 0];

    this.getLevel().setBlock(block, this, true, true);
    CompoundTag nbt = new CompoundTag("")
            .putString("id", BlockEntity.ENDER_CHEST)
            .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 BlockEntityEnderChest(this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt);
    return true;
}
 
Example #3
Source File: BlockEnderChest.java    From Nukkit with GNU General Public License v3.0 6 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) {
    int[] faces = {2, 5, 3, 4};
    this.setDamage(faces[player != null ? player.getDirection().getHorizontalIndex() : 0]);

    this.getLevel().setBlock(block, this, true, true);
    CompoundTag nbt = new CompoundTag("")
            .putString("id", BlockEntity.ENDER_CHEST)
            .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());
        }
    }

    BlockEntityEnderChest ender = (BlockEntityEnderChest) BlockEntity.createBlockEntity(BlockEntity.ENDER_CHEST, this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt);
    return ender != null;
}
 
Example #4
Source File: BlockEnderChest.java    From Nukkit with GNU General Public License v3.0 6 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) {
    int[] faces = {2, 5, 3, 4};
    this.setDamage(faces[player != null ? player.getDirection().getHorizontalIndex() : 0]);

    this.getLevel().setBlock(block, this, true, true);
    CompoundTag nbt = new CompoundTag("")
            .putString("id", BlockEntity.ENDER_CHEST)
            .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 BlockEntityEnderChest(this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt);
    return true;
}