Package org.spout.api.inventory

Examples of org.spout.api.inventory.ItemStack


    assertTrue(Enchantment.getEnchantmentLevel(itemStack, VanillaEnchantments.FORTUNE) == 0);
  }

  @Test
  public void testEnchantmentSword() {
    ItemStack itemStack = new ItemStack(VanillaMaterials.DIAMOND_SWORD, 1);
    Enchantment.addEnchantment(itemStack, VanillaEnchantments.KNOCKBACK, 2, false);
    Enchantment.addEnchantment(itemStack, VanillaEnchantments.FORTUNE, 2, false);
    assertTrue(!VanillaEnchantments.FORTUNE.canEnchant(VanillaMaterials.DIAMOND_SWORD));
    assertTrue(Enchantment.getEnchantmentLevel(itemStack, VanillaEnchantments.KNOCKBACK) == 2);
    assertTrue(Enchantment.getEnchantmentLevel(itemStack, VanillaEnchantments.FORTUNE) == 0);
View Full Code Here


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

      final int y = point.getBlockX();
      final int z = point.getBlockX();
      final Block translated = getOwner().getWorld().getBlock(x, y, z).translate(BlockFace.TOP);
      final BlockMaterial material = translated.getMaterial();
      if (material.isPlacementObstacle()) {
        Item.dropNaturally(point, new ItemStack(getMaterial(), 1));
      } else {
        translated.setMaterial(getMaterial(), getMaterial().toCause(point));
      }
      getOwner().remove();
    }
View Full Code Here

   */
  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

   * Handles a shift click on the given inventory slot
   *
   * @return true if the action completed successfully.
   */
  public boolean onShiftClick(int slot, PlayerInventory toInventory) {
    ItemStack result = get(getOutputSlot());
    Material resultMat = (result != null ? result.getMaterial() : null);
    if (slot == getOutputSlot() + getOffset() && result != null) {
      while (result != null && !result.isEmpty()) {
        toInventory.add(result);
        set(getOutputSlot(), null);
        result = get(getOutputSlot());
        //Changed recipes, stop!
        if (result != null && !result.getMaterial().isMaterial(resultMat)) {
          break;
        }
      }
      return true;
    }
View Full Code Here

    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();
      }
      current.add(mat);
      if (mat != null) {
        shapeless.add(mat);
      }
View Full Code Here

    super(SIZE);
  }

  @Override
  public void updateHeldItem(Entity entity) {
    ItemStack item = this.get(this.selected);

    entity.getNetwork().callProtocolEvent(new EntityEquipmentEvent(entity, EntityEquipmentMessage.HELD_SLOT, item), true);
  }
View Full Code Here

    super.onAttached();
    setEntityProtocol(new ObjectEntityProtocol(ObjectType.MINECART));

    if (getAttachedCount() == 1) {
      // Set drops
      getOwner().add(DeathDrops.class).addDrop(new ItemStack(VanillaMaterials.MINECART, 1));
      // Set the displayed block
      setDisplayedBlock(getType().getDefaultDisplayedBlock());
    }

    PhysicsComponent physics = getOwner().getPhysics();
View Full Code Here

    super.onAttached();
    Float nextEgg = (float) (GenericMath.getRandom().nextInt(MINIMUM_EGG_BREEDING_TIME) + MINIMUM_EGG_BREEDING_TIME);
    getOwner().getData().put(VanillaData.TIME_TILL_EGG, nextEgg);
    setEntityProtocol(new CreatureProtocol(CreatureType.CHICKEN));
    DeathDrops dropComponent = getOwner().add(DeathDrops.class);
    dropComponent.addDrop(new ItemStack(VanillaMaterials.FEATHER, getRandom().nextInt(2)));
    dropComponent.addDrop(new ItemStack(VanillaMaterials.RAW_CHICKEN, 1));
    dropComponent.addXpDrop((short) (getRandom().nextInt(3) + 1));

    if (getAttachedCount() == 1) {
      getOwner().add(Health.class).setSpawnHealth(4);
    }
View Full Code Here

    }
  }

  private void layEgg() {
    Point position = getOwner().getPhysics().getPosition();
    Item.drop(position, new ItemStack(VanillaMaterials.EGG, 1), Vector3f.ZERO);
    Float nextEgg = (float) (GenericMath.getRandom().nextInt(MINIMUM_EGG_BREEDING_TIME) + MINIMUM_EGG_BREEDING_TIME);
    getOwner().getData().put(VanillaData.TIME_TILL_EGG, nextEgg);
  }
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.