Package org.spout.vanilla.component.entity.substance

Examples of org.spout.vanilla.component.entity.substance.Item


    // Conversion factor, some sort of unit problem
    //TODO: This needs an actual value and this value might change when gravity changes!
    impulse = impulse.mul(100);

    // Finally drop using a 4 second pickup delay
    Item spawnedItem = Item.drop(dropFrom.getPosition(), item, impulse);
    spawnedItem.setUncollectableDelay(4000);
  }
View Full Code Here


      GeneralEffects.RANDOM_CLICK2.playGlobal(block.getPosition());
      return false;
    }
    Block facingBlock = block.translate(this.getFacing(block));
    if (facingBlock.getMaterial().getShape() != null) {
      Item item = facingBlock.getWorld().createEntity(facingBlock.getPosition(), Item.class).add(Item.class);
      item.setItemStack(slot.get().clone());
      item.getItemStack().setAmount(1);
      facingBlock.getWorld().spawnEntity(item.getOwner());

      GeneralEffects.RANDOM_CLICK1.playGlobal(block.getPosition());
      GeneralEffects.SMOKE.playGlobal(facingBlock.getPosition());
      slot.addAmount(-1);
      return true;
View Full Code Here

  }

  @Override
  public void onTick(float dt) {
    for (Entity entity : nearbyEntities) {
      Item item = entity.get(Item.class);
      if (item == null) {
        continue;
      }
      EntityInventory inv = getOwner().get(EntityInventory.class);
      ArmorInventory armorInv = inv.getArmor();
      // Check if this item is equipable armor and has more protection than the currently equipped item
      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);
              entity.remove();
              equip = true;
              break;
            }
          }
        }
      }
      // Check if this weapon deals more damage
      if (!equip && (item.getItemStack().getMaterial() instanceof VanillaItemMaterial || inv.getHeldItem() == null)) {
        if (inv.getHeldItem() == null) {
          equip = true;
        } else if (inv.getHeldItem().getMaterial() instanceof VanillaItemMaterial) {
          VanillaItemMaterial itemMaterial = (VanillaItemMaterial) item.getItemStack().getMaterial();
          VanillaItemMaterial equipMaterial = (VanillaItemMaterial) inv.getHeldItem().getMaterial();
          if (equipMaterial.getDamage() < itemMaterial.getDamage()) {
            equip = true;
          } else if (itemMaterial.getDamage() == equipMaterial.getDamage() && itemMaterial instanceof Tool && equipMaterial instanceof Tool
              && inv.getHeldItem().getData() > item.getItemStack().getData()) {
            equip = true;
          }
        }
        if (equip) {
          getOwner().getNetwork().callProtocolEvent(new EntityCollectItemEvent(getOwner(), entity));
          if (inv.getHeldItem() != null) {
            Item.drop(getOwner().getPhysics().getPosition(), inv.getHeldItem(), Vector3f.ZERO);
          }
          inv.getQuickbar().set(EntityQuickbarInventory.HELD_SLOT, item.getItemStack(), true);
          entity.remove();
          break;
        }
      }
    }
View Full Code Here

        shootEffect = GeneralEffects.SHOOT_FIREBALL;
        //TODO: Spawn
      } else {
        shootEffect = GeneralEffects.RANDOM_CLICK1;
        position = position.sub(0.0, 0.3, 0.0);
        toLaunch = new Item();
        ((Item) toLaunch).setItemStack(item);
      }

      if (toLaunch != null) {
        block.getWorld().createAndSpawnEntity(position, LoadOption.NO_LOAD, toLaunch.getClass());
View Full Code Here

*/
public class PlayerItemCollector extends EntityItemCollector {
  @Override
  public void onTick(float dt) {
    for (Entity entity : getNearbyEntities()) {
      Item item = entity.get(Item.class);
      if (item != null && item.canBeCollected()) {
        getOwner().getNetwork().callProtocolEvent(new EntityCollectItemEvent(getOwner(), entity));
        PlayerInventory inv = getOwner().get(PlayerInventory.class);
        if (inv != null) {
          inv.add(item.getItemStack());
        }
        entity.remove();
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.spout.vanilla.component.entity.substance.Item

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.