Package org.bukkit.block

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


    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

      }
      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

      }
      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

        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

      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

        }
    }

    private void chestCheck(String player, Block block) {
        if (block.getState() instanceof Chest) {
            Chest chest = (Chest) block.getState();
            bystanders.add(new DeltaChest(player, chest, chest.getInventory().getContents(),new ItemStack[chest.getInventory().getSize()]));
        }
    }
View Full Code Here

        super.send();
    }

    private void chestCheck(String player, Block block) {
        if (block.getState() instanceof Chest) {
            Chest chest = (Chest) block.getState();
            ItemStack[] destroyedStack=new ItemStack[chest.getInventory().getSize()];
            ItemStack[] contents = chest.getInventory().getContents();
            bystanders.add(new DeltaChest(player, chest, contents,destroyedStack));
        }
    }
View Full Code Here

            do_OldRollback(currWorld,block);
        }
    }
    private void do_NewRollback(World currWorld, Block block) {
        if (block.getState() instanceof Chest) {
            Chest chest = (Chest) block.getState();
            DeltaEntry[] diff = processDeltaStream(chest.getInventory().getSize(),data);
            Inventory inv = chest.getInventory();
            for(int i = 0;i<chest.getInventory().getSize();i++) {
                switch(diff[i].Type) {
                case ADDED:
                case REMOVED:
                    ItemStack stack = inv.getItem(i);
                    stack.setAmount(stack.getAmount()-diff[i].Amount);
View Full Code Here

    }

    public void do_OldRollback(World currWorld,Block block) {
        String[] changes = data.split(";");
        if (block.getState() instanceof Chest) {
            Chest chest = (Chest) block.getState();
            Inventory inv = chest.getInventory();
            for (int i = 0; i < changes.length; i++) {
                String change = changes[i];
                try {
                    if (change.equals("")) {
                        continue;
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.