Package org.bukkit.inventory

Examples of org.bukkit.inventory.EntityEquipment


                entity.addPotionEffect(new PotionEffect(type, duration, amplifier, ambient), true);
            }
        }

        EntityEquipment equip = entity.getEquipment();
        if (compound.isList("Equipment", TagType.COMPOUND)) {
            List<CompoundTag> list = compound.getCompoundList("Equipment");
            if (list.size() == 5) {
                equip.setItemInHand(NbtSerialization.readItem(list.get(0)));
                equip.setBoots(NbtSerialization.readItem(list.get(1)));
                equip.setLeggings(NbtSerialization.readItem(list.get(2)));
                equip.setChestplate(NbtSerialization.readItem(list.get(3)));
                equip.setHelmet(NbtSerialization.readItem(list.get(4)));
            }
        }
        if (compound.isList("DropChances", TagType.FLOAT)) {
            List<Float> list = compound.getList("DropChances", TagType.FLOAT);
            if (list.size() == 5) {
                equip.setItemInHandDropChance(list.get(0));
                equip.setBootsDropChance(list.get(1));
                equip.setLeggingsDropChance(list.get(2));
                equip.setChestplateDropChance(list.get(3));
                equip.setHelmetDropChance(list.get(4));
            }
        }
        if (compound.isByte("CanPickUpLoot")) {
            entity.setCanPickupItems(compound.getBool("CanPickUpLoot"));
        }
View Full Code Here


            effectTag.putBool("ShowParticles", true);
            effects.add(effectTag);
        }
        tag.putCompoundList("ActiveEffects", effects);

        EntityEquipment equip = entity.getEquipment();
        tag.putCompoundList("Equipment", Arrays.asList(
                NbtSerialization.writeItem(equip.getItemInHand(), -1),
                NbtSerialization.writeItem(equip.getBoots(), -1),
                NbtSerialization.writeItem(equip.getLeggings(), -1),
                NbtSerialization.writeItem(equip.getChestplate(), -1),
                NbtSerialization.writeItem(equip.getHelmet(), -1)
        ));
        tag.putList("DropChances", TagType.FLOAT, Arrays.asList(
                equip.getItemInHandDropChance(),
                equip.getBootsDropChance(),
                equip.getLeggingsDropChance(),
                equip.getChestplateDropChance(),
                equip.getHelmetDropChance()
        ));
        tag.putBool("CanPickUpLoot", entity.getCanPickupItems());
    }
View Full Code Here

        // head facing
        result.add(new EntityHeadRotationMessage(id, yaw));

        // equipment
        EntityEquipment equipment = getEquipment();
        result.add(new EntityEquipmentMessage(id, 0, equipment.getItemInHand()));
        for (int i = 0; i < 4; i++) {
            result.add(new EntityEquipmentMessage(id, i + 1, equipment.getArmorContents()[i]));
        }
        return result;
    }
View Full Code Here

     * Slot 0 is the item in the hand.
     * Slot 1 to 4 is armor (boots to helmet).
     * @return The item in that slot.
     */
    private ItemStack getItem(int slot) {
        EntityEquipment equipment = entity.getEquipment();
        if (equipment == null) {
            return null;
        }
        if (slot == 0) {
            return equipment.getItemInHand();
        } else {
            return equipment.getArmorContents()[slot - 1];
        }
    }
View Full Code Here

   * @param inIgnoreArmor    If armor should not be copied or if it should
   */
  public void copyInventory(Player inPlayer, boolean inIgnoreArmor)
  {
    this.copyInventory(inPlayer.getInventory());
    EntityEquipment equip = this.getBukkitEntity().getEquipment();
    if(!inIgnoreArmor)
      equip.setArmorContents(inPlayer.getInventory().getArmorContents());

    if(this.getInventory() instanceof CraftInventoryPlayer)
      ((CraftInventoryPlayer)this.getInventory()).setHeldItemSlot(inPlayer.getInventory().getHeldItemSlot());
    else
      equip.setItemInHand(inPlayer.getItemInHand());
  }
View Full Code Here

        // note: players get their armor checked here
        // the double-check on the held item doesn't really matter
        if (ent instanceof LivingEntity)
        {
          EntityEquipment eq = ((LivingEntity) ent).getEquipment();
          for (ItemStack item : eq.getArmorContents())
          {
            submitMatches(item, ent, goals);
          }
          submitMatches(eq.getItemInHand(), ent, goals);
        }

        // these 3 should be obvious
        if (ent instanceof FallingBlock)
          submitMatches(new BlockData(((FallingBlock) ent).getMaterial(), ((FallingBlock) ent).getBlockData()), ent, goals);
View Full Code Here

                }
              }
            };
          }
        }
        final EntityEquipment e = p.getEquipment();
        if (e == null)
          return null;
        return new EquipmentSlot(e, EquipmentSlot.EquipSlot.TOOL) {
          @Override
          public String toString_i() {
View Full Code Here

  }
 
  @Override
  @Nullable
  public Slot convert(final LivingEntity e) {
    final EntityEquipment eq = e.getEquipment();
    if (eq == null)
      return null;
    return new EquipmentSlot(eq, slot);
  }
View Full Code Here

TOP

Related Classes of org.bukkit.inventory.EntityEquipment

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.