cn.nukkit.blockentity.BlockEntityChest Java Examples
The following examples show how to use
cn.nukkit.blockentity.BlockEntityChest.
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: NukkitWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public boolean clearContainerBlockContents(Vector pt) { BlockEntity block = getLevel().getBlockEntity(setMutable(pt)); if (block == null) { return false; } if (block instanceof InventoryHolder) { if (block instanceof BlockEntityChest) { ((BlockEntityChest) block).getRealInventory().clearAll(); } else { ((InventoryHolder) block).getInventory().clearAll(); } return true; } return false; }
Example #2
Source File: Server.java From Jupiter with GNU General Public License v3.0 | 6 votes |
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 #3
Source File: DoubleChestInventory.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public DoubleChestInventory(BlockEntityChest left, BlockEntityChest right) { super(null, InventoryType.DOUBLE_CHEST); this.holder = this; this.left = left.getRealInventory(); this.right = right.getRealInventory(); Map<Integer, Item> items = new HashMap<>(); // First we add the items from the left chest for (int idx = 0; idx < this.left.getSize(); idx++) { if (this.left.getContents().containsKey(idx)) { // Don't forget to skip empty slots! items.put(idx, this.left.getContents().get(idx)); } } // And them the items from the right chest for (int idx = 0; idx < this.right.getSize(); idx++) { if (this.right.getContents().containsKey(idx)) { // Don't forget to skip empty slots! items.put(idx + this.left.getSize(), this.right.getContents().get(idx)); // idx + this.left.getSize() so we don't overlap left chest items } } this.setContents(items); }
Example #4
Source File: DoubleChestInventory.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public DoubleChestInventory(BlockEntityChest left, BlockEntityChest right) { super(null, InventoryType.DOUBLE_CHEST); this.holder = this; this.left = left.getRealInventory(); this.right = right.getRealInventory(); Map<Integer, Item> items = new HashMap<>(); // First we add the items from the left chest for (int idx = 0; idx < this.left.getSize(); idx++) { if (this.left.getContents().containsKey(idx)) { // Don't forget to skip empty slots! items.put(idx, this.left.getContents().get(idx)); } } // And them the items from the right chest for (int idx = 0; idx < this.right.getSize(); idx++) { if (this.right.getContents().containsKey(idx)) { // Don't forget to skip empty slots! items.put(idx + this.left.getSize(), this.right.getContents().get(idx)); // idx + this.left.getSize() so we don't overlap left chest items } } this.setContents(items); }
Example #5
Source File: DoubleChestInventory.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public DoubleChestInventory(BlockEntityChest left, BlockEntityChest right) { super(null, InventoryType.DOUBLE_CHEST); this.holder = this; this.left = left.getRealInventory(); this.left.setDoubleInventory(this); this.right = right.getRealInventory(); this.right.setDoubleInventory(this); Map<Integer, Item> items = new HashMap<>(); // First we add the items from the left chest for (int idx = 0; idx < this.left.getSize(); idx++) { if (this.left.getContents().containsKey(idx)) { // Don't forget to skip empty slots! items.put(idx, this.left.getContents().get(idx)); } } // And them the items from the right chest for (int idx = 0; idx < this.right.getSize(); idx++) { if (this.right.getContents().containsKey(idx)) { // Don't forget to skip empty slots! items.put(idx + this.left.getSize(), this.right.getContents().get(idx)); // idx + this.left.getSize() so we don't overlap left chest items } } this.setContents(items); }
Example #6
Source File: BlockTrappedChest.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public int getWeakPower(BlockFace face) { int playerCount = 0; BlockEntity blockEntity = this.level.getBlockEntity(this); if (blockEntity instanceof BlockEntityChest) { playerCount = ((BlockEntityChest) blockEntity).getInventory().getViewers().size(); } return playerCount < 0 ? 0 : playerCount > 15 ? 15 : playerCount; }
Example #7
Source File: BlockTrappedChest.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public int getWeakPower(BlockFace face) { int playerCount = 0; BlockEntity blockEntity = this.level.getBlockEntity(this); if (blockEntity instanceof BlockEntityChest) { playerCount = ((BlockEntityChest) blockEntity).getInventory().getViewers().size(); } return playerCount < 0 ? 0 : playerCount > 15 ? 15 : playerCount; }
Example #8
Source File: BlockChest.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onBreak(Item item) { BlockEntity t = this.getLevel().getBlockEntity(this); if (t instanceof BlockEntityChest) { ((BlockEntityChest) t).unpair(); } this.getLevel().setBlock(this, new BlockAir(), true, true); return true; }
Example #9
Source File: BlockChest.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public int getComparatorInputOverride() { BlockEntity blockEntity = this.level.getBlockEntity(this); if (blockEntity instanceof BlockEntityChest) { return ContainerInventory.calculateRedstone(((BlockEntityChest) blockEntity).getInventory()); } return super.getComparatorInputOverride(); }
Example #10
Source File: BlockChest.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public int getComparatorInputOverride() { BlockEntity blockEntity = this.level.getBlockEntity(this); if (blockEntity instanceof BlockEntityChest) { return ContainerInventory.calculateRedstone(((BlockEntityChest) blockEntity).getInventory()); } return super.getComparatorInputOverride(); }
Example #11
Source File: BlockChest.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onBreak(Item item) { BlockEntity t = this.getLevel().getBlockEntity(this); if (t instanceof BlockEntityChest) { ((BlockEntityChest) t).unpair(); } this.getLevel().setBlock(this, Block.get(BlockID.AIR), true, true); return true; }
Example #12
Source File: BlockChest.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public int getComparatorInputOverride() { BlockEntity blockEntity = this.level.getBlockEntity(this); if (blockEntity instanceof BlockEntityChest) { return ContainerInventory.calculateRedstone(((BlockEntityChest) blockEntity).getInventory()); } return super.getComparatorInputOverride(); }
Example #13
Source File: BlockChest.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean onBreak(Item item) { BlockEntity t = this.getLevel().getBlockEntity(this); if (t instanceof BlockEntityChest) { ((BlockEntityChest) t).unpair(); } this.getLevel().setBlock(this, new BlockAir(), true, true); return true; }
Example #14
Source File: BlockChestTrapped.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public int getWeakPower(BlockFace face) { int playerCount = 0; BlockEntity blockEntity = this.level.getBlockEntity(this); if (blockEntity instanceof BlockEntityChest) { playerCount = ((BlockEntityChest) blockEntity).getInventory().getViewers().size(); } return playerCount < 0 ? 0 : playerCount > 15 ? 15 : playerCount; }
Example #15
Source File: ChestInventory.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public ChestInventory(BlockEntityChest chest) { super(chest, InventoryType.CHEST); }
Example #16
Source File: DoubleChestInventory.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public BlockEntityChest getHolder() { return this.left.getHolder(); }
Example #17
Source File: ChestInventory.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public BlockEntityChest getHolder() { return (BlockEntityChest) this.holder; }
Example #18
Source File: DoubleChestInventory.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public BlockEntityChest getHolder() { return this.left.getHolder(); }
Example #19
Source File: ChestInventory.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public BlockEntityChest getHolder() { return (BlockEntityChest) this.holder; }
Example #20
Source File: ChestInventory.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public ChestInventory(BlockEntityChest chest) { super(chest, InventoryType.CHEST); }
Example #21
Source File: DoubleChestInventory.java From Jupiter with GNU General Public License v3.0 | 4 votes |
@Override public BlockEntityChest getHolder() { return this.left.getHolder(); }
Example #22
Source File: ChestInventory.java From Jupiter with GNU General Public License v3.0 | 4 votes |
@Override public BlockEntityChest getHolder() { return (BlockEntityChest) this.holder; }
Example #23
Source File: ChestInventory.java From Jupiter with GNU General Public License v3.0 | 4 votes |
public ChestInventory(BlockEntityChest chest) { super(chest, InventoryType.CHEST); }