Package org.spout.api.inventory

Examples of org.spout.api.inventory.ItemStack


  public void onAttached() {
    super.onAttached();
    setEntityProtocol(new CreatureProtocol(CreatureType.MUSHROOM_COW));
    DeathDrops dropComponent = getOwner().add(DeathDrops.class);
    Random random = getRandom();
    dropComponent.addDrop(new ItemStack(VanillaMaterials.RAW_BEEF, random.nextInt(2) + 1));
    dropComponent.addDrop(new ItemStack(VanillaMaterials.LEATHER, random.nextInt(2)));
    dropComponent.addXpDrop((short) (getRandom().nextInt(3) + 1));
    if (getAttachedCount() == 1) {
      getOwner().add(Health.class).setSpawnHealth(10);
    }
  }
View Full Code Here


          break;
        case Parameter.TYPE_STRING:
          writeString(buf, ((Parameter<String>) parameter).getValue());
          break;
        case Parameter.TYPE_ITEM:
          ItemStack item = ((Parameter<ItemStack>) parameter).getValue();
          writeItemStack(buf, item);
          break;
      }
    }
View Full Code Here

        throw new IOException("Unknown material with id of " + id);
      }
      int count = buffer.readUnsignedByte();
      int damage = buffer.readUnsignedShort();
      CompoundMap nbtData = readCompound(buffer);
      return new ItemStack(material, damage, count).setNBTData(nbtData);
    }
  }
View Full Code Here

          return null;
        }
        // Re-use last item to avoid the creation of too many items
        // If material changes, create a new item to break the reference
        if (lastItem == null || !lastItem.isMaterial(mat)) {
          lastItem = new ItemStack(mat, 1);
        }
        return lastItem;
      }

      @Override
View Full Code Here

    if (event instanceof PlayerInteractEntityEvent) {
      final PlayerInteractEntityEvent pie = (PlayerInteractEntityEvent) event;
      switch (pie.getAction()) {
        case LEFT_CLICK:
          Point pos = getOwner().getPhysics().getPosition();
          Item.dropNaturally(pos, new ItemStack(VanillaMaterials.ITEM_FRAME, 1));
          if (material != null) {
            Item.dropNaturally(pos, new ItemStack(material, 1));
          }
          getOwner().remove();
          break;
        case RIGHT_CLICK:
          Slot slot = PlayerUtil.getHeldSlot(getOwner());
View Full Code Here

  }

  public void setMaterial(Material material) {
    this.material = material;
    List<Parameter<?>> params = new ArrayList<Parameter<?>>();
    params.add(new Parameter<ItemStack>(Parameter.TYPE_ITEM, 2, material == null ? null : new ItemStack(material, 1)));
    getOwner().getNetwork().callProtocolEvent(new EntityMetaChangeEvent(getOwner(), params));
  }
View Full Code Here

  @Override
  public void onAttached() {
    super.onAttached();
    if (getAttachedCount() == 1) {
      getOwner().add(DeathDrops.class).addDrop(new ItemStack(VanillaMaterials.CHEST, 1));
    }
  }
View Full Code Here

  @Override
  public void onAttached() {
    super.onAttached();
    if (getAttachedCount() == 1) {
      getOwner().add(DeathDrops.class).addDrop(new ItemStack(VanillaMaterials.FURNACE, 1));
    }

    // Add smoking puff effect metadata
    getOwner().add(MetadataComponent.class).addMeta(new Metadata<Byte>(Metadata.TYPE_BYTE, 16) {
      @Override
View Full Code Here

      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);
            }
          }
      }
View Full Code Here

  @Override
  public void onAttached() {
    super.onAttached();
    if (getAttachedCount() == 1) {
      getOwner().add(DeathDrops.class).addDrop(new ItemStack(VanillaMaterials.HOPPER, 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.