Package org.spout.vanilla.inventory.entity

Examples of org.spout.vanilla.inventory.entity.ArmorInventory


    final PlayerInventory inventory = getPlayerInventory();

    // Transferring to the armor slots
    if (!(from instanceof EntityArmorInventory)) {
      // Transferring to the armor slots
      final ArmorInventory armor = inventory.getArmor();
      for (int i = 0; i < armor.size(); i++) {
        if (armor.get(i) == null && canSet(armor, i, stack)) {
          armor.set(i, ItemStack.cloneSpecial(stack));
          from.set(slot, stack.setAmount(0));
          return true;
        }
      }
    }
View Full Code Here


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

    EntityInventory inventory = entity.get(EntityInventory.class);
    final ItemStack boots, leggings, chestplate, helmet, held;
    if (inventory == null) {
      boots = leggings = chestplate = helmet = held = null;
    } else {
      final ArmorInventory armor = inventory.getArmor();
      boots = armor.getBoots();
      leggings = armor.getLeggings();
      chestplate = armor.getChestPlate();
      helmet = armor.getHelmet();
      held = inventory.getQuickbar().getSelectedSlot().get();
    }
    if (held != null) {
      messages.add(new EntityEquipmentMessage(entity.getId(), EntityEquipmentMessage.HELD_SLOT, held));
    }
View Full Code Here

TOP

Related Classes of org.spout.vanilla.inventory.entity.ArmorInventory

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.