Package org.bukkit.inventory

Examples of org.bukkit.inventory.InventoryHolder


                            if (blockChest == null) blockChest = findChestBelow(blockBehind, 6);
                        }
                       
                        // If a chest was found, get the contents
                        if (blockChest != null) {
                            InventoryHolder holder = (InventoryHolder) blockChest.getState();
                            ItemStack[] contents = holder.getInventory().getContents();
                            // Guard against double-chests for now
                            if (contents.length > 36) {
                                ItemStack[] newContents = new ItemStack[36];
                                System.arraycopy(contents, 0, newContents, 0, 36);
                                contents = newContents;
View Full Code Here


     */
    public void repair() {
        super.repair();
       
        // Grab the inventory
        InventoryHolder cb = (InventoryHolder) getWorld().getBlockAt(getX(),getY(),getZ()).getState();
        Inventory chestInv = cb.getInventory();

        chestInv.setContents(contents);
    }
View Full Code Here

   * @param itemParser to use
   * @param isFuelPreferred - whether (when depositing into furnaces) fuel is preferred over heatable
   * @return the amount of items transferred
   */
  public static int transferItems(Inventory from, Inventory to, ItemParser itemParser, boolean isFuelPreferred) {
    final InventoryHolder toHolder = to.getHolder();
    final InventoryHolder fromHolder = from.getHolder();

    // Obtaining items from a furnace? Only use output slot!
    if (from instanceof FurnaceInventory) {
      final FurnaceInventory finv = (FurnaceInventory) from;
      from = new InventoryBase() {
View Full Code Here

        if (!lowercase.equalsIgnoreCase("random")) {
            if (arena.getSettings().getBoolean("use-class-chests", false)) {
                Location loc = ac.getClassChest();
                if (loc != null) {
                    Block blockChest = loc.getBlock();
                    InventoryHolder holder = (InventoryHolder) blockChest.getState();
                    ItemStack[] contents = holder.getInventory().getContents();
                    // Guard against double-chests for now
                    if (contents.length > 36) {
                        ItemStack[] newContents = new ItemStack[36];
                        System.arraycopy(contents, 0, newContents, 0, 36);
                        contents = newContents;
View Full Code Here

        int id = material.getId();
        return id >= 298 && id <= 317;
    }

    private boolean didPlayerClickOwnInventory(Player player, Inventory inventory) {
        InventoryHolder holder = inventory.getHolder();
        InventoryType type = inventory.getType();
        return holder != null
                && holder.equals(player)
                && type != InventoryType.ENDER_CHEST
                && type != InventoryType.WORKBENCH;
    }
View Full Code Here

                        continue;
                    }
                    if (BlockType.shouldPlaceLast(world.getBlockTypeIdAt(BukkitUtil.toLocation(world, pt)))) {
                        Block block = world.getBlockAt(BukkitUtil.toLocation(world, pt));
                        if (block instanceof InventoryHolder) {
                            InventoryHolder holder = (InventoryHolder) block;
                            holder.getInventory().clear();
                        }
                        block.setType(Material.AIR);
                    } else {
                        // Can't destroy these blocks yet
                        queued.add(pt);
                    }
                }
            }
        }

        for (Vector pt : queued) {
            Block block = world.getBlockAt(BukkitUtil.toLocation(world, pt));
            if (block instanceof InventoryHolder) {

                InventoryHolder holder = (InventoryHolder) block;
                holder.getInventory().clear();
            }
            block.setType(Material.AIR);
        }
    }
View Full Code Here

        if (!(inventory instanceof BrewerInventory)) {
            return;
        }

        InventoryHolder holder = inventory.getHolder();

        if (!(holder instanceof BrewingStand)) {
            return;
        }
View Full Code Here

        if (!(inventory instanceof BrewerInventory)) {
            return;
        }

        InventoryHolder holder = inventory.getHolder();

        if (!(holder instanceof BrewingStand)) {
            return;
        }
View Full Code Here

        if (!(inventory instanceof BrewerInventory)) {
            return;
        }

        InventoryHolder holder = inventory.getHolder();

        if (!(holder instanceof BrewingStand)) {
            return;
        }
View Full Code Here

        Collection<ItemStack> results = event.getItems();

        // If there is a chest add the results to the chest
        Block invHolder = backB.getRelative(offset.getBlockX(), offset.getBlockY(), offset.getBlockZ());
        if (InventoryUtil.doesBlockHaveInventory(invHolder)) {
            InventoryHolder c = (InventoryHolder) invHolder.getState();
            results = c.getInventory().addItem(results.toArray(new ItemStack[results.size()])).values();
        }

        // Drop whatever results were not added to the chest
        for (ItemStack item : results) {
            backB.getWorld().dropItemNaturally(sign.getLocation().add(0.5, 0, 0.5), item);
View Full Code Here

TOP

Related Classes of org.bukkit.inventory.InventoryHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.