Package org.bukkit.block

Examples of org.bukkit.block.Chest


                      // Chests set
                      worldBlock.setType(Material.getMaterial(diskBlockType));
                      worldBlock.setData(diskBlockData);
                      BlockState state = worldBlock.getState();
                      if (state instanceof Chest) {
                        Chest chest = (Chest) state;
                        if (items != null) {
                          int ii = 0;
                          chest.getInventory().clear();
                          for (ItemStack item : items) {
                            if (item != null) {
                              chest.getInventory().setItem(ii, item);
                              ii++;
                            }
                          }
                          chest.update(true);
                        }
                      }
                    } else if (diskBlockType == Material.DISPENSER.getId()) {
                      // Dispensers read
                      List<ItemStack> items = VolumeMapper.readInventoryString(invsReader.readLine());
View Full Code Here


                    signsWriter.write(extra);
                    signsWriter.newLine();
                  }
                } else if (state instanceof Chest) {
                  // Chests
                  Chest chest = (Chest) state;
                  Inventory inv = chest.getInventory();
                  List<ItemStack> items = VolumeMapper.getItemListFromInv(inv);
                  invsWriter.write(VolumeMapper.buildInventoryStringFromItemList(items));
                  invsWriter.newLine();
                } else if (state instanceof Dispenser) {
                  // Dispensers
View Full Code Here

                          // Chests set
                          worldBlock.setType(Material.getMaterial(diskBlockType));
                          worldBlock.setData(diskBlockData);
                          BlockState state = worldBlock.getState();
                          if (state instanceof Chest) {
                            Chest chest = (Chest) state;
                            if (items != null) {
                              int ii = 0;
                              chest.getInventory().clear();
                              for (ItemStack item : items) {
                                if (item != null) {
                                  chest.getInventory().setItem(ii, item);
                                  ii++;
                                }
                              }
                              chest.update(true);
                            }
                          }
                        } else if (diskBlockType == Material.DISPENSER.getId()) {
                          // Dispensers read
                          List<ItemStack> items = null;
View Full Code Here

   */
  public void fillChest(final Block block) {
    try {
      if (!(block.getState() instanceof Chest))
        return;
      Chest chestB = ((Chest) block.getState());
      Inventory chest = chestB.getBlockInventory();
      for (int i = 0; i < plugin.getSingleRandom().nextInt(
          chest.getSize()); i++) {
        ItemStack cis = getItem();
        while (cis == null) {
          cis = getItem();
View Full Code Here

   */
  public void fillChest(final Block block, final int size) {
    try {
      if (!(block.getState() instanceof Chest))
        return;
      Chest chestB = ((Chest) block.getState());
      Inventory chest = chestB.getBlockInventory();
      for (int i = 0; i < size; i++) {
        ItemStack cis = getItem();
        while (cis == null) {
          cis = getItem();
        }
View Full Code Here

     */
    public boolean scan() {

        Block pump = getBackBlock();
        if (!(pump.getRelative(0, 1, 0).getType() == Material.CHEST)) return false;
        Chest c = (Chest) pump.getRelative(0, 1, 0).getState();
        for (int y = -1; y > -11; y--) {
            Block liquid = pump.getRelative(0, y, 0);
            if (check(c, liquid, 0)) return true;
        }
        return false;
View Full Code Here

    }

    public boolean damageHoe() {

        if (getBackBlock().getRelative(0, 1, 0).getType() == Material.CHEST) {
            Chest c = (Chest) getBackBlock().getRelative(0, 1, 0).getState();
            for (int i = 290; i <= 294; i++) {
                for (int slot = 0; slot < c.getInventory().getSize(); slot++) {
                    if (c.getInventory().getItem(slot) == null || c.getInventory().getItem(slot).getTypeId() != i)
                        continue;
                    if (ItemUtil.isStackValid(c.getInventory().getItem(slot))) {
                        ItemStack item = c.getInventory().getItem(slot);
                        item.setDurability((short) (item.getDurability() + 1));
                        if(item.getDurability() > ItemUtil.getMaxDurability(item.getType()))
                            item = null;
                        c.getInventory().setItem(slot, item);
                        return true;
                    }
                }
            }
        }
View Full Code Here

        }
        BlockState state = bl.getState();
        if (!(state instanceof Chest)) {
            return false;
        }
        Chest c = (Chest) state;
        ItemStack[] is = c.getInventory().getContents();
        for (int i = 0; i < is.length; i++) {
            final ItemStack stack = is[i];
            if (stack == null) {
                continue;
            }
            if (stack.getAmount() > 0 && stack.getType() == item.getType()) {
                if (item.getData() != -1 && stack.getData().getData() != item.getData()) {
                    continue;
                }
                if (stack.getAmount() == 1) {
                    is[i] = new ItemStack(Material.AIR, 0);
                } else {
                    stack.setAmount(stack.getAmount() - 1);
                }
                c.getInventory().setContents(is);
                c.update();
                return true;
            }
        }
        return false;
    }
View Full Code Here

            final BlockState blockState = block.getState();
            boolean fake = false;
            switch (block.getType()) {
                case TRAPPED_CHEST:
                case CHEST:
                    final Chest chest = (Chest) blockState;
                    inventory = this.plugin.getServer().createInventory(player, chest.getInventory().getSize());
                    inventory.setContents(chest.getInventory().getContents());
                    fake = true;
                    break;
                case ENDER_CHEST:
                    if (this.plugin.getServer().getPluginManager().isPluginEnabled("EnderChestPlus") && VanishPerms.canNotInteract(player)) {
                        event.setCancelled(true);
View Full Code Here

        int z = b.getZ();
        Block bl = BukkitUtil.toSign(getSign()).getBlock().getWorld().getBlockAt(x, y, z);
        ItemStack stack = null;
        Inventory inv = null;
        if (bl.getType() == Material.CHEST) {
            Chest c = (Chest) bl.getState();
            for (ItemStack it : c.getInventory().getContents()) {
                if (ItemUtil.isStackValid(it)) {
                    if(item == null || ItemUtil.areItemsIdentical(it, item)) {
                        stack = it;
                        inv = c.getInventory();
                        break;
                    }
                }
            }
        } else if (bl.getType() == Material.FURNACE || bl.getType() == Material.BURNING_FURNACE) {
            Furnace c = (Furnace) bl.getState();
            stack = c.getInventory().getResult();
            inv = c.getInventory();
        } else if (bl.getType() == Material.BREWING_STAND) {
            BrewingStand c = (BrewingStand) bl.getState();
            for (ItemStack it : c.getInventory().getContents()) {
                if (ItemUtil.isStackValid(it)) {
                    if (ItemUtil.areItemsIdentical(it, c.getInventory().getIngredient())) {
                        continue;
                    }
                    if(item == null || ItemUtil.areItemsIdentical(it, item)) {
                        stack = it;
                        inv = c.getInventory();
                        break;
                    }
                }
            }
        } else if (bl.getType() == Material.DISPENSER) {
            Dispenser c = (Dispenser) bl.getState();
            for (ItemStack it : c.getInventory().getContents()) {
                if (ItemUtil.isStackValid(it)) {
                    if(item == null || ItemUtil.areItemsIdentical(it, item)) {
                        stack = it;
                        inv = c.getInventory();
                        break;
                    }
                }
            }
        }
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.