Package org.spout.api.inventory

Examples of org.spout.api.inventory.Slot


  public void onInteractBy(Entity entity, Block block, Action type, BlockFace clickedFace) {
    super.onInteractBy(entity, block, type, clickedFace);
    if (type != Action.RIGHT_CLICK) {
      return;
    }
    Slot inv = PlayerUtil.getHeldSlot(entity);
    if (inv != null && inv.get() != null && inv.get().isMaterial(Dye.BONE_MEAL) && type.equals(Action.RIGHT_CLICK)) {
      if (!PlayerUtil.isCostSuppressed(entity)) {
        inv.addAmount(-1);
      }
      if (GenericMath.getRandom().nextDouble() < 0.4D) {
        final BlockMaterial mushroomType = block.getMaterial();
        final VariableHeightObject mushroom;
        if (mushroomType == VanillaMaterials.RED_MUSHROOM) {
View Full Code Here


  }

  @Override
  public void onInteractBy(Entity entity, Block block, Action type, BlockFace clickedFace) {
    super.onInteractBy(entity, block, type, clickedFace);
    Slot inv = PlayerUtil.getHeldSlot(entity);
    if (inv != null && inv.get() != null && type.equals(Action.RIGHT_CLICK)) {
      if (grow(block, inv.get().getMaterial()) && !PlayerUtil.isCostSuppressed(entity)) {
        inv.addAmount(-1);
      }
    }
  }
View Full Code Here

  public void onInteractBy(Entity entity, Block block, Action type, BlockFace clickedFace) {
    super.onInteract(entity, block, type, clickedFace);
    if (type != Action.RIGHT_CLICK) {
      return;
    }
    Slot selected = PlayerUtil.getHeldSlot(entity);
    if (selected == null || selected.get() == null) {
      return;
    }
    FlowerPotBlock material = getForFlower(selected.get().getMaterial());
    if (material == null) {
      return;
    }
    block.setMaterial(material);
    if (!PlayerUtil.isCostSuppressed(entity)) {
      selected.addAmount(-1);
    }
  }
View Full Code Here

    return false;
  }

  @Override
  public void onInteractBy(Entity entity, Block block, Action type, BlockFace clickedFace) {
    Slot inv = PlayerUtil.getHeldSlot(entity);
    if (inv != null && inv.get() != null && type.equals(Action.RIGHT_CLICK)) {
      if (grow(block, inv.get().getMaterial()) && !PlayerUtil.isCostSuppressed(entity)) {
        inv.addAmount(-1);
      }
    }
  }
View Full Code Here

      Sheep sheep = other.get(Sheep.class);
      if (sheep == null) {
        return;
      }

      Slot inv = PlayerUtil.getHeldSlot(entity);
      if (inv != null && inv.get() != null) {
        // get color from holding item
        sheep.setColor(Wool.WoolColor.getById((short) (0xF - inv.get().getData())));
        if (!PlayerUtil.isCostSuppressed(entity)) {
          inv.addAmount(-1);
        }
      }
    }
  }
View Full Code Here

        if (this.canCreate(block, (short) 0, cause)) {
          this.onCreate(block, (short) 0, cause);

          //TODO Subtract from inventory component
          // Subtract item
          Slot inv = PlayerUtil.getHeldSlot(entity);
          if (inv != null && !PlayerUtil.isCostSuppressed(entity)) {
            inv.addAmount(-1);
          }
        }
        break;
      }
    }
View Full Code Here

      }
    } else if (message.getSlot() == -1) {
      window.setCursorItem(message.get());
      window.onOutsideClick();
    } else {
      Slot entry = window.getSlot(message.getSlot());
      if (entry != null) {
        window.onCreativeClick(entry.getInventory(), entry.getIndex(), message.get());
      }
    }
  }
View Full Code Here

      return;
    }
    Window window = holder.getActiveWindow();
    ItemStack[] slots = msg.getItems();
    for (int i = 0; i < slots.length; i++) {
      Slot entry = window.getSlot(i);
      if (entry == null) {
        return;
      }
      entry.getInventory().set(entry.getIndex(), slots[i]);
    }
  }
View Full Code Here

    Human player = playerEnt.get(Human.class);
    Entity clickedEntity = playerEnt.getWorld().getEntity(message.getTarget());
    if (clickedEntity == null || player == null) {
      return;
    }
    Slot held = PlayerUtil.getHeldSlot(playerEnt);
    if (held == null) {
      return;
    }
    ItemStack holding = held.get();
    Material holdingMat = holding == null ? VanillaMaterials.AIR : holding.getMaterial();
    if (holdingMat == null) {
      holdingMat = VanillaMaterials.AIR;
    }
    //TODO VanillaPlayerInteractEntityEvent maybe?
View Full Code Here

  @Override
  public void handleClient(ClientSession session, WindowSlotMessage msg) {
    Player player = session.getPlayer();
    WindowHolder holder = player.get(WindowHolder.class);
    if (holder != null) {
      Slot entry = holder.getActiveWindow().getSlot(msg.getSlot());
      if (entry == null) {
        return;
      }

      entry.getInventory().set(entry.getIndex(), msg.get());
    }
  }
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.