Package org.spout.api.inventory

Examples of org.spout.api.inventory.ItemStack


    }
    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?
    PlayerInteractEntityEvent event;
View Full Code Here


    if (inventory == null) {
      player.getEngine().getLogger().warning("EntityEquipmentHandler entity haven't EntityInventory");
      return;
    }

    ItemStack item = message.get();

    switch (message.getSlot()) {
      case 0:
        inventory.getHeldItem().setMaterial(item.getMaterial());
        inventory.getHeldItem().setAmount(item.getAmount());
        return;
      case 1:
        inventory.getArmor().getHelmet().setMaterial(item.getMaterial());
        inventory.getArmor().getHelmet().setAmount(item.getAmount());
        return;
      case 2:
        inventory.getArmor().getChestPlate().setMaterial(item.getMaterial());
        inventory.getArmor().getChestPlate().setAmount(item.getAmount());
        return;
      case 3:
        inventory.getArmor().getLeggings().setMaterial(item.getMaterial());
        inventory.getArmor().getLeggings().setAmount(item.getAmount());
        return;
      case 4:
        inventory.getArmor().getBoots().setMaterial(item.getMaterial());
        inventory.getArmor().getBoots().setAmount(item.getAmount());
        return;
      default:
        player.getEngine().getLogger().warning("EntityEquipmentHandler slot bad value");
    }
  }
View Full Code Here

    this.setHardness(3.0F).setResistance(15.0F).addMiningType(ToolType.PICKAXE).setMiningLevel(ToolLevel.STONE);
  }

  @Override
  public ItemStack getResult() {
    return new ItemStack(VanillaMaterials.IRON_INGOT, 1);
  }
View Full Code Here

    World world = player.getWorld();
    Slot currentSlot = PlayerUtil.getHeldSlot(player);
    if (currentSlot == null) {
      return;
    }
    ItemStack holding = currentSlot.get();
    Material holdingMat = holding == null ? null : holding.getMaterial();

    /*
     * The notch client's packet sending is weird. Here's how it works: If the client is clicking a block not in range, sends a packet with x=-1,y=255,z=-1 If the client is clicking a block in
     * range with an item in hand (id > 255) Sends both the normal block placement packet and a (-1,255,-1) one If the client is placing a block in range with a block in hand, only one normal
     * packet is sent That is how it usually happens. Sometimes it doesn't happen like that. Therefore, a hacky workaround.
     */
    final BlockFace clickedFace = message.getDirection();
    Hunger hunger = player.add(Hunger.class);
    if ((holdingMat instanceof Food && hunger.getHunger() != VanillaData.HUNGER.getDefaultValue()) || holdingMat instanceof Sword || (holdingMat instanceof PotionItem && !((PotionItem) holdingMat).isSplash())) {
      player.get(Living.class).setEatingBlocking(true);
      hunger.setEating(true, currentSlot);
      return;
    }
    if (clickedFace == BlockFace.THIS) {
      // Right clicked air with an item.
      PlayerInteractBlockEvent event = Spout.getEventManager().callEvent(new PlayerInteractBlockEvent(player, null, null, clickedFace, Action.RIGHT_CLICK));

      // May have been changed by the event
      holding = currentSlot.get();
      holdingMat = holding == null ? null : holding.getMaterial();

      if (holdingMat != null) {
        holdingMat.onInteract(player, Action.RIGHT_CLICK);
      }
    } else {
      // TODO: Validate the x/y/z coordinates of the message to check if it is in range of the player
      // This is an anti-hack requirement (else hackers can load far-away chunks and crash the server)

      // Get clicked block and validated face against it was placed
      final Block clickedBlock = world.getBlock(message.getX(), message.getY(), message.getZ());
      final BlockMaterial clickedMaterial = clickedBlock.getMaterial();

      // Perform interaction event
      PlayerInteractBlockEvent interactEvent = Spout.getEventManager().callEvent(new PlayerInteractBlockEvent(player, clickedBlock, clickedBlock.getPosition(), clickedFace, Action.RIGHT_CLICK));

      // May have been changed by the event
      holding = currentSlot.get();
      holdingMat = holding == null ? null : holding.getMaterial();

      // check if the interaction was cancelled by the event
      if (interactEvent.isCancelled()) {
        refreshClient(player, clickedBlock, clickedFace, rm);
        return;
      }
      if (holdingMat != null) {
        holdingMat.onInteract(player, clickedBlock, Action.RIGHT_CLICK, clickedFace);
      }
      clickedMaterial.onInteract(player, clickedBlock, Action.RIGHT_CLICK, clickedFace);

      // If the holding material can be placed, place it
      if (holdingMat instanceof Placeable) {
        Cause<?> cause = new PlayerClickBlockCause(player, clickedBlock);
        short placedData = holding.getData(); // TODO: shouldn't the sub-material deal with this?
        Placeable toPlace = (Placeable) holdingMat;

        final Block placedBlock;
        final BlockFace placedAgainst;
        final boolean placedIsClicked;
View Full Code Here

    getDrops().EXPLOSION.add(VanillaMaterials.DIAMOND);
  }

  @Override
  public ItemStack getResult() {
    return new ItemStack(VanillaMaterials.DIAMOND, 1);
  }
View Full Code Here

      boolean equip = false;
      if (item.getItemStack().getMaterial() instanceof Armor) {
        Armor armor = (Armor) item.getItemStack().getMaterial();
        for (int i = 0; i < armorInv.size(); i++) {
          if (armorInv.canSet(i, item.getItemStack())) {
            ItemStack slot = armorInv.get(i);
            if (slot == null || (slot.getMaterial() instanceof Armor && ((Armor) slot.getMaterial()).getBaseProtection() < armor.getBaseProtection())) {
              getOwner().getNetwork().callProtocolEvent(new EntityCollectItemEvent(getOwner(), entity));
              if (slot != null) {
                Item.drop(getOwner().getPhysics().getPosition(), slot, Vector3f.ZERO);
              }
              armorInv.set(i, item.getItemStack(), true);
View Full Code Here

    getDrops().EXPLOSION.addRange(Dye.LAPIS_LAZULI, 2, 4);
  }

  @Override
  public ItemStack getResult() {
    return new ItemStack(Dye.LAPIS_LAZULI, 1);
  }
View Full Code Here

    this.setHardness(3.0F).setResistance(15.0F).addMiningType(ToolType.PICKAXE).setMiningLevel(ToolLevel.IRON);
  }

  @Override
  public ItemStack getResult() {
    return new ItemStack(VanillaMaterials.GOLD_INGOT, 1);
  }
View Full Code Here

      box.setColor(Color.RED);
      box.setSprite(new Rectangle(pos, RenderItemStack.SPRITE_EXTENTS));
      boxPack.add(box);
      parts.add(boxPack);
    }
    ItemStack item = slot.get();
    if (item != null) {
      System.out.println("Item not null");
      RenderPartPack itemPack = new RenderPartPack(VanillaRenderMaterials.ITEMS_MATERIAL);
      RenderItemStack itemPart = new RenderItemStack(item);
      itemPart.setZIndex(2);
View Full Code Here

    this.getDrops().NOT_CREATIVE.addFlags(ToolTypeFlags.PICKAXE);
  }

  @Override
  public ItemStack getResult() {
    return new ItemStack(VanillaMaterials.NETHER_BRICK, 1);
  }
View Full Code Here

TOP

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

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.