Package org.spout.api.inventory.util

Examples of org.spout.api.inventory.util.GridIterator


  public void onSlotChanged(int slot, ItemStack item, ItemStack previous) {
    if (slot == outputSlot + offset) {
      craft();
      return;
    }
    GridIterator i = grid.iterator();
    while (i.hasNext()) {
      if (i.next() + offset == slot) {
        updateOutput();
        return;
      }
    }
  }
View Full Code Here


  /**
   * Crafts the current recipe, subtracting all the requirements from the crafting grid
   */
  public void craft() {
    GridIterator iterator = grid.iterator();
    while (iterator.hasNext()) {
      addAmount(iterator.next(), -1);
    }
  }
View Full Code Here

  /**
   * Assesses the crafting matrix to determine if an {@link ItemStack} should be crafted to the {@link #outputSlot};
   */
  public void updateOutput() {
    GridIterator iterator = grid.iterator();
    int rowSize = getGrid().getLength();
    List<List<Material>> materials = new ArrayList<List<Material>>();
    List<Material> current = new ArrayList<Material>();
    List<Material> shapeless = new ArrayList<Material>();
    int cntr = 0;
    while (iterator.hasNext()) {
      ItemStack item = get(iterator.next());
      cntr++;
      Material mat = null;
      if (item != null) {
        mat = item.getMaterial();
      }
View Full Code Here

  public GridInventoryConverter(Inventory inventory, int length, int offset, Vector2f pos) {
    super(inventory, new int[inventory.size()], new Vector2f[inventory.size()], offset);
    this.grid = inventory.grid(length);
    this.pos = pos;
    GridIterator iter = grid.iterator();
    while (iter.hasNext()) {
      int i = iter.next(), x = iter.getX(), y = iter.getY(), size = grid.getSize();
      slots[i] = (offset + size) - (length * y) - (length - x);
      if (VanillaPlugin.getInstance().getEngine() instanceof Client) {
        RenderSlot slot = widgets[i].get(RenderSlot.class);
        slot.setSlot(new Slot(inventory, i));
        slot.setPosition(pos.add(x * SLOT_WIDTH, y * SLOT_HEIGHT));
 
View Full Code Here

    addInventoryConverter(new InventoryConverter(inventory, "7-9, 4-6, 1-3, 0", new Vector2f[0]));
  }

  @Override
  public void close() {
    GridIterator iterator = inventory.getGrid().iterator();
    while (iterator.hasNext()) {
      ItemStack item = inventory.get(iterator.next());
      if (item != null) {
        getHuman().dropItem(item);
      }
    }
    inventory.clear();
View Full Code Here

TOP

Related Classes of org.spout.api.inventory.util.GridIterator

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.