Package org.bukkit.block

Examples of org.bukkit.block.Chest


        m = parse(m);
        Block chest = getBackBlock().getRelative(0, -1, 0);

        if (chest.getTypeId() == BlockID.CHEST) {
            Chest c = (Chest) chest.getState();

            if (((Factory) getFactory()).buckets) {

                HashMap<Integer, ItemStack> over = c.getInventory().removeItem(
                        new ItemStack(m == BlockID.LAVA ? ItemID.LAVA_BUCKET : ItemID.WATER_BUCKET, 1));
                if (over.isEmpty()) return m;
            } else {

                HashMap<Integer, ItemStack> over = c.getInventory().removeItem(new ItemStack(m, 1));
                if (over.isEmpty()) return m;

                over = c.getInventory().removeItem(new ItemStack(unparse(m), 1));
                if (over.isEmpty()) return m;
            }
        }

        return BlockID.AIR;
View Full Code Here


    public boolean consumeWater() {

        Block chest = getBackBlock().getRelative(0, 1, 0);
        if (chest.getType() == Material.CHEST) {
            Chest c = (Chest) chest.getState();
            HashMap<Integer, ItemStack> over = c.getInventory().removeItem(new ItemStack(Material.WATER, 1));
            if (over.isEmpty()) return true;
            over = c.getInventory().removeItem(new ItemStack(Material.STATIONARY_WATER, 1));
            if (over.isEmpty()) return true;
            over = c.getInventory().removeItem(new ItemStack(Material.WATER_BUCKET, 1));
            if (over.isEmpty()) {
                c.getInventory().addItem(new ItemStack(Material.BUCKET, 1));
                return true;
            }
        } else if (chest.getType() == Material.WATER || chest.getType() == Material.STATIONARY_WATER) {
            chest.setType(Material.AIR);
            return true;
View Full Code Here

        if (item != null && !plantableItem(item)) return false;

        if (getBackBlock().getRelative(0, 1, 0).getType() == Material.CHEST || getBackBlock().getRelative(0, 1, 0).getType() == Material.TRAPPED_CHEST) {

            Chest c = (Chest) getBackBlock().getRelative(0, 1, 0).getState();
            for (ItemStack it : c.getInventory().getContents()) {

                if (!ItemUtil.isStackValid(it)) continue;
                if (!plantableItem(it)) continue;

                if (item != null && !ItemUtil.areItemsIdentical(it, item)) continue;

                Block b;

                if ((b = searchBlocks(it)) != null) {
                    if (c.getInventory().removeItem(new ItemStack(it.getType(), 1, it.getDurability())).isEmpty()) {
                        return plantBlockAt(it, b);
                    }
                }
            }
        } else {
View Full Code Here

        Block b = SignUtil.getBackBlock(event.getBlock());
        Block fire = b.getRelative(0, 1, 0);
        Block cb = b.getRelative(0, 2, 0);
        if (cb.getType() == Material.CHEST) {
            if (fire.getType() == Material.FIRE) {
                Chest chest = (Chest) cb.getState();
                List<ItemStack> items;
                if(cookingPotOres)
                    items = ItemUtil.getRawMaterials(chest.getInventory());
                else
                    items = ItemUtil.getRawFood(chest.getInventory());

                if(items.size() == 0) return;

                if(lastTick < 500) {
                    lastTick = cookingPotSuperFast ? lastTick + getMultiplier(sign) : lastTick + Math.min(getMultiplier(sign), 5);
                    if(getMultiplier(sign) > 0)
                        decreaseMultiplier(sign, 1);
                }
                if (lastTick >= 50) {
                    for (ItemStack i : items) {

                        if (!ItemUtil.isStackValid(i)) continue;
                        ItemStack cooked = ItemUtil.getCookedResult(i);
                        if (cooked == null) {
                            if (cookingPotOres)
                                cooked = ItemUtil.getSmeletedResult(i);
                            if (cooked == null) continue;
                        }
                        if (chest.getInventory().addItem(cooked).isEmpty()) {
                            ItemStack toRemove = i.clone();
                            toRemove.setAmount(1);
                            chest.getInventory().removeItem(toRemove);
                            chest.update();
                            lastTick -= 50;
                            break;
                        }
                    }
                }
View Full Code Here

    public int getFromChest() {

        Block chest = getBackBlock().getRelative(0, -1, 0);

        if (chest.getTypeId() == BlockID.CHEST) {
            Chest c = (Chest) chest.getState();
            if (((Factory) getFactory()).buckets) {
                HashMap<Integer, ItemStack> over = c.getInventory().removeItem(new ItemStack(ItemID.WATER_BUCKET, 1));
                if (over.isEmpty()) return BlockID.WATER;
                over = c.getInventory().removeItem(new ItemStack(ItemID.LAVA_BUCKET, 1));
                if (over.isEmpty()) return BlockID.LAVA;
            } else {
                HashMap<Integer, ItemStack> over = c.getInventory().removeItem(new ItemStack(BlockID.WATER, 1));
                if (over.isEmpty()) return BlockID.WATER;
                over = c.getInventory().removeItem(new ItemStack(BlockID.STATIONARY_WATER, 1));
                if (over.isEmpty()) return BlockID.WATER;
                over = c.getInventory().removeItem(new ItemStack(BlockID.LAVA, 1));
                if (over.isEmpty()) return BlockID.LAVA;
                over = c.getInventory().removeItem(new ItemStack(BlockID.STATIONARY_LAVA, 1));
                if (over.isEmpty()) return BlockID.LAVA;
            }
        }

        return BlockID.AIR;
View Full Code Here

    public boolean doesChestContain(Material item) {

        if (chest.getType() == Material.CHEST) {

            Chest c = (Chest) chest.getState();
            return c.getInventory().contains(item);
        }

        return false;
    }
View Full Code Here

    public boolean addToChest(Material item) {

        if (chest.getType() == Material.CHEST) {

            Chest c = (Chest) chest.getState();
            return c.getInventory().addItem(new ItemStack(item, 1)).isEmpty();
        }

        return false;
    }
View Full Code Here

    public boolean addToChest(ItemStack item) {

        if (chest.getType() == Material.CHEST) {

            Chest c = (Chest) chest.getState();
            return c.getInventory().addItem(item).isEmpty();
        }

        return false;
    }
View Full Code Here

    public boolean removeFromChest(Material item) {

        if (chest.getType() == Material.CHEST) {

            Chest c = (Chest) chest.getState();
            return c.getInventory().removeItem(new ItemStack(item, 1)).isEmpty();
        }

        return false;
    }
View Full Code Here

        }
    }

    private String getBookCode(Block chestBlock) throws CodeNotFoundException {

        Chest c = (Chest) chestBlock.getState();
        Inventory i = c.getBlockInventory();
        ItemStack book = null;
        for (ItemStack s : i.getContents()) {
            if (s != null && s.getAmount() > 0 && (s.getType() == Material.BOOK_AND_QUILL || s.getType() == Material.WRITTEN_BOOK)) {
                if (book != null) throw new CodeNotFoundException("More than one written book found in chest!!");
                book = s;
View Full Code Here

TOP

Related Classes of org.bukkit.block.Chest

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.