Package org.spout.api.inventory

Examples of org.spout.api.inventory.Slot


   * returns the slot that is currently selected on the quickbar
   *
   * @return slot selected
   */
  public Slot getSelectedSlot() {
    return new Slot(this, this.selected);
  }
View Full Code Here


    super.onInteract(event);
    if (event instanceof PlayerInteractEntityEvent) {
      final PlayerInteractEntityEvent pie = (PlayerInteractEntityEvent) event;
      switch (pie.getAction()) {
        case RIGHT_CLICK:
          Slot inv = PlayerUtil.getHeldSlot(pie.getEntity());
          if (inv != null && this.canPlay(inv.get())) {
            this.setPlayedItem(inv.get().clone().setAmount(1));
            if (!PlayerUtil.isCostSuppressed(pie.getEntity())) {
              inv.addAmount(-1);
            }
          } else {
            this.eject();
          }
      }
View Full Code Here

   * Drops the player's current item.
   */
  public void dropItem() {
    PlayerInventory inventory = getOwner().get(PlayerInventory.class);
    if (inventory != null) {
      Slot selected = inventory.getQuickbar().getSelectedSlot();
      ItemStack drop = selected.get();
      if (drop == null) {
        return;
      } else {
        drop = drop.clone().setAmount(1);
      }
      selected.addAmount(-1);
      dropItem(drop);
    }
  }
View Full Code Here

  public static final int OUTPUT_SLOT = 2, FUEL_SLOT = 0, INGREDIENT_SLOT = 1;
  private final Slot fuel, ingredient, output;

  public FurnaceInventory() {
    super(SIZE);
    this.fuel = new Slot(this, FUEL_SLOT);
    this.ingredient = new Slot(this, INGREDIENT_SLOT);
    this.output = new Slot(this, OUTPUT_SLOT);
  }
View Full Code Here

    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

   * Reloads the window's items
   */
  public final void reload() {
    ItemStack[] items = new ItemStack[getSize()];
    for (int i = 0; i < items.length; i++) {
      Slot entry = getSlot(i);
      if (entry != null) {
        items[i] = entry.get();
      }
    }
    getPlayer().getNetwork().callProtocolEvent(new WindowItemsEvent(this, items), getPlayer());
  }
View Full Code Here

        slot = widget.add(RenderSlot.class);
        slot.setPosition(positions[i]);
      } else {
        slot = new RenderSlot();
      }
      slot.setSlot(new Slot(inventory, i));
    }
  }
View Full Code Here

            Item.dropNaturally(pos, new ItemStack(material, 1));
          }
          getOwner().remove();
          break;
        case RIGHT_CLICK:
          Slot slot = PlayerUtil.getHeldSlot(getOwner());
          if (slot != null && slot.get() != null) {
            setMaterial(slot.get().getMaterial());
            slot.addAmount(-1);
          }
          break;
      }
    }
  }
View Full Code Here

    if (event instanceof PlayerInteractEntityEvent) {
      final PlayerInteractEntityEvent pie = (PlayerInteractEntityEvent) event;
      final Player player = (Player) pie.getEntity();
      switch (pie.getAction()) {
        case LEFT_CLICK:
          Slot slot = PlayerUtil.getHeldSlot(player);
          if (slot.get() != null) {
            ItemStack stack = slot.get();
            if (stack.getMaterial() instanceof Fuel) {
              setFueled(true);
              slot.addAmount(-1);
            }
          }
      }
    }
    super.onInteract(event);
View Full Code Here

      } else {
        return;
      }

      // Change item if applicable
      Slot selected = PlayerUtil.getHeldSlot(entity);
      if (selected != null && !PlayerUtil.isCostSuppressed(entity)) {
        selected.set(new ItemStack(filled, 1));
      }

      // Change the clicked block to air
      final Cause<?> cause;
      if (entity instanceof Player) {
View Full Code Here

TOP

Related Classes of org.spout.api.inventory.Slot

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.