Examples of Chest


Examples of org.bukkit.block.Chest

    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

Examples of org.bukkit.block.Chest

    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

Examples of org.bukkit.block.Chest

    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

Examples of org.bukkit.block.Chest

        }
    }

    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

Examples of org.bukkit.block.Chest

public class LootProvider_Normal extends LootProvider {

  // Based on work contributed by drew-bahrue (https://github.com/echurchill/CityWorld/pull/2)
  @Override
  public void setLoot(Odds odds, String worldPrefix, LootLocation lootLocation, Block block) {
    Chest chest = (Chest) block.getState();
    Inventory inv = chest.getInventory();
    inv.clear();
    ItemStack[] items = getLoot(odds, lootLocation, block);
    inv.addItem(items);
    chest.update(true);
  }
View Full Code Here

Examples of org.bukkit.block.Chest

    public static ItemStack[] getContainerContents(InventoryHolder container) {

      //If it isn't a chest, there is no issue!
      if (!(container instanceof Chest)) return container.getInventory().getContents();

      Chest chest = (Chest)container;
        Chest second = null;

        //Iterate through nearby blocks to find any other chests
        if (chest.getBlock().getRelative(BlockFace.NORTH).getType() == Material.CHEST)
            second = (Chest) chest.getBlock().getRelative(BlockFace.NORTH).getState();
        else if (chest.getBlock().getRelative(BlockFace.SOUTH).getType() == Material.CHEST)
            second = (Chest) chest.getBlock().getRelative(BlockFace.SOUTH).getState();
        else if (chest.getBlock().getRelative(BlockFace.EAST).getType() == Material.CHEST)
            second = (Chest) chest.getBlock().getRelative(BlockFace.EAST).getState();
        else if (chest.getBlock().getRelative(BlockFace.WEST).getType() == Material.CHEST)
            second = (Chest) chest.getBlock().getRelative(BlockFace.WEST).getState();

        //If we can't find a second chest, just return this one
        if (second == null) {
            return chest.getInventory().getContents();
        }
        else {

            //I think it would be good, to consistently return same chest
            //contents, regardless of what
            //block was clicked on. That means, we must determine, which part
            //of chest comes first, and which second.
            //I choose the one, which has lower X coordinate. If they are same,
            //than it's the one with lower Z coordinate.
            //I believe it can be easily checked with this trick:
            ItemStack[] result = new ItemStack[54];
            ItemStack[] firstHalf;
            ItemStack[] secondHalf;

            if ((chest.getX() + chest.getZ()) < (second.getX() + second.getZ())) {
                firstHalf = chest.getInventory().getContents();
                secondHalf = second.getInventory().getContents();
            } else {
                firstHalf = second.getInventory().getContents();
                secondHalf = chest.getInventory().getContents();
            }

            //Merge them
            for (int i = 0; i < 27; i++) {
View Full Code Here

Examples of org.bukkit.block.Chest

      }
      break;
    }
    case CHEST: {
      // Time for deposit.
      Chest chest = (Chest) block.getState();
      makeDeposit(chest);
      // And for retrieval.
      // (Tools, seeds, saplings).
      lookForStuff(chest);
      break;
View Full Code Here

Examples of org.bukkit.block.Chest

      }
      break;
    }
    case CHEST: {
      // Time for chest fun !
      Chest chest = (Chest) block.getState();
      book = ChestHandler.deposit(Material.BOOK, book, chest);
      getCaneFromChest(chest);
      break;
    }
    case BOOKSHELF: {
View Full Code Here

Examples of org.bukkit.block.Chest

        for (int yOffset = -verticalBelow; yOffset <= verticalAbove; ++yOffset) {
          int yA = y + yOffset;
          Block block = world.getBlockAt(xA, yA, zA);
          Material material = block.getType();
          if (Material.CHEST.equals(material)) {
            Chest chest = (Chest) block.getState();
            // Time to deposit.
            for (int j = 0; j < 16; ++j) {
              wool[j] = ChestHandler.deposit(Material.WOOL,
                  wool[j], chest, (byte) j);
            }
View Full Code Here

Examples of org.bukkit.block.Chest

      Furnace furnace = (Furnace) block.getState();
      furnaces.add(furnace);
      break;
    }
    case CHEST: {
      Chest ch = (Chest) block.getState();
      chest.add(ch);
      break;
    }
    case IRON_BLOCK: {
      if (canMine) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.