Java Code Examples for cn.nukkit.blockentity.BlockEntity#getDefaultCompound()
The following examples show how to use
cn.nukkit.blockentity.BlockEntity#getDefaultCompound() .
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: BlockUndyedShulkerBox.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public boolean onActivate(Item item, Player player) { if (player != null) { BlockEntity t = this.getLevel().getBlockEntity(this); BlockEntityShulkerBox box; if (t instanceof BlockEntityShulkerBox) { box = (BlockEntityShulkerBox) t; } else { CompoundTag nbt = BlockEntity.getDefaultCompound(this, BlockEntity.SHULKER_BOX); box = (BlockEntityShulkerBox) BlockEntity.createBlockEntity(BlockEntity.SHULKER_BOX, this.getLevel().getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4), nbt); if (box == null) { return false; } } Block block = this.getSide(BlockFace.fromIndex(box.namedTag.getByte("facing"))); if (!(block instanceof BlockAir) && !(block instanceof BlockLiquid) && !(block instanceof BlockFlowable)) { return true; } player.addWindow(box.getInventory()); } return true; }
Example 2
Source File: BlockBed.java From Jupiter with GNU General Public License v3.0 | 4 votes |
private void createBlockEntity(Vector3 pos, int color) { CompoundTag nbt = BlockEntity.getDefaultCompound(pos, BlockEntity.BED); nbt.putByte("color", color); new BlockEntityBed(this.level.getChunk(pos.getFloorX() >> 4, pos.getFloorZ() >> 4), nbt); }
Example 3
Source File: BlockBed.java From Nukkit with GNU General Public License v3.0 | 4 votes |
private void createBlockEntity(Vector3 pos, int color) { CompoundTag nbt = BlockEntity.getDefaultCompound(pos, BlockEntity.BED); nbt.putByte("color", color); BlockEntity.createBlockEntity(BlockEntity.BED, this.level.getChunk(pos.getFloorX() >> 4, pos.getFloorZ() >> 4), nbt); }
Example 4
Source File: BlockBed.java From Nukkit with GNU General Public License v3.0 | 4 votes |
private void createBlockEntity(Vector3 pos, int color) { CompoundTag nbt = BlockEntity.getDefaultCompound(pos, BlockEntity.BED); nbt.putByte("color", color); BlockEntity.createBlockEntity(BlockEntity.BED, this.level.getChunk(pos.getFloorX() >> 4, pos.getFloorZ() >> 4), nbt); }