Java Code Examples for cn.nukkit.Player#addWindow()
The following examples show how to use
cn.nukkit.Player#addWindow() .
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: BlockDispenser.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Item item, Player player) { if (player != null) { BlockEntity t = getLevel().getBlockEntity(this); BlockEntityDispenser dispenser; if (t instanceof BlockEntityDispenser) { dispenser = (BlockEntityDispenser) t; } else { CompoundTag nbt = new CompoundTag() .putList(new ListTag<>("Items")) .putString("id", BlockEntity.DISPENSER) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z); dispenser = new BlockEntityDispenser(this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt); } if (dispenser.namedTag.contains("Lock") && dispenser.namedTag.get("Lock") instanceof StringTag) { if (!dispenser.namedTag.getString("Lock").equals(item.getCustomName())) { return false; } } player.addWindow(dispenser.getInventory()); } return true; }
Example 3
Source File: BlockShulkerBoxUndyed.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Item item, Player player) { if (player != null) { Block top = up(); if (!top.isTransparent()) { return true; } BlockEntity t = this.getLevel().getBlockEntity(this); BlockEntityShulkerBox shulkerBox; if (t instanceof BlockEntityShulkerBox) { shulkerBox = (BlockEntityShulkerBox) t; } else { CompoundTag nbt = new CompoundTag("") .putString("id", BlockEntity.SHULKER_BOX) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z); shulkerBox = new BlockEntityShulkerBox(this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt); } if (shulkerBox.namedTag.contains("Lock") && shulkerBox.namedTag.get("Lock") instanceof StringTag) { if (!shulkerBox.namedTag.getString("Lock").equals(item.getCustomName())) { return true; } } player.addWindow(shulkerBox.getInventory()); } return true; }
Example 4
Source File: BlockDropper.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Item item, Player player) { if (player != null) { BlockEntity t = getLevel().getBlockEntity(this); BlockEntityDropper dropper; if (t instanceof BlockEntityDropper) { dropper = (BlockEntityDropper) t; } else { CompoundTag nbt = new CompoundTag() .putList(new ListTag<>("Items")) .putString("id", BlockEntity.DROPPER) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z); dropper = new BlockEntityDropper(this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt); } if (dropper.namedTag.contains("Lock") && dropper.namedTag.get("Lock") instanceof StringTag) { if (!dropper.namedTag.getString("Lock").equals(item.getCustomName())) { return false; } } player.addWindow(dropper.getInventory()); } return true; }
Example 5
Source File: BlockShulkerBox.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Item item, Player player) { if (player != null) { Block top = up(); if (!top.isTransparent()) { return true; } BlockEntity t = this.getLevel().getBlockEntity(this); BlockEntityShulkerBox shulkerBox; if (t instanceof BlockEntityShulkerBox) { shulkerBox = (BlockEntityShulkerBox) t; } else { CompoundTag nbt = new CompoundTag("") .putString("id", BlockEntity.SHULKER_BOX) .putInt("x", (int) this.x) .putInt("y", (int) this.y) .putInt("z", (int) this.z); shulkerBox = new BlockEntityShulkerBox(this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt); } if (shulkerBox.namedTag.contains("Lock") && shulkerBox.namedTag.get("Lock") instanceof StringTag) { if (!shulkerBox.namedTag.getString("Lock").equals(item.getCustomName())) { return true; } } player.addWindow(shulkerBox.getInventory()); } return true; }
Example 6
Source File: BlockHopper.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Item item, Player player) { BlockEntity blockEntity = this.level.getBlockEntity(this); if (blockEntity instanceof BlockEntityHopper) { return player.addWindow(((BlockEntityHopper) blockEntity).getInventory()) != -1; } return false; }
Example 7
Source File: BlockAnvil.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Item item, Player player) { if (player != null) { player.addWindow(new AnvilInventory(this)); } return true; }
Example 8
Source File: BlockHopper.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Item item, Player player) { BlockEntity blockEntity = this.level.getBlockEntity(this); if (blockEntity instanceof BlockEntityHopper) { return player.addWindow(((BlockEntityHopper) blockEntity).getInventory()) != -1; } return false; }
Example 9
Source File: BlockAnvil.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Item item, Player player) { if (player != null) { player.addWindow(new AnvilInventory(player.getUIInventory(), this), Player.ANVIL_WINDOW_ID); } return true; }
Example 10
Source File: BlockHopper.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Item item, Player player) { BlockEntity blockEntity = this.level.getBlockEntity(this); if (blockEntity instanceof BlockEntityHopper) { return player.addWindow(((BlockEntityHopper) blockEntity).getInventory()) != -1; } return false; }
Example 11
Source File: BlockAnvil.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Item item, Player player) { if (player != null) { player.addWindow(new AnvilInventory(this), Player.ANVIL_WINDOW_ID); } return true; }
Example 12
Source File: EntityVillager.java From Jupiter with GNU General Public License v3.0 | 4 votes |
@Override public boolean onInteract(Player player, Item item) { player.addWindow(this.getInventory()); return true; }
Example 13
Source File: BlockBeacon.java From Jupiter with GNU General Public License v3.0 | 4 votes |
@Override public boolean onActivate(Item item, Player player) { player.addWindow(new BeaconInventory(this)); return true; }
Example 14
Source File: EntityMinecartChest.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public boolean onInteract(Player player, Item item, Vector3 clickedPos) { player.addWindow(this.inventory); return false; // If true, the count of items player has in hand decreases }
Example 15
Source File: EntityMinecartHopper.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public boolean onInteract(Player player, Item item, Vector3 clickedPos) { player.addWindow(this.inventory); return false; // If true, the count of items player has in hand decreases }