Solved How To Use EntityEquipment

Discussion in 'Plugin Development' started by mkezar, Mar 20, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    mkezar

    Hi. I am working on spawning in a zombie (which i have done) now, what i want that zombie to have is the exact armor and item i have in hand, in order to do this, i need to use EntityEquipment which ive never used before. How would i use it? thank you! :D
     
  2. Offline

    Funergy

    @mkezar Isn't zombie.getEquipment().setHelmet(player.getInventory().getHelmet()); Working?
     
  3. Offline

    mkezar

    well i never really declared EntityEquipment and i dont really know where to start...

    to spawn the zombie i did
    Code:
    Entity e = player.getWorld().spawnEntity(player.getLocation(), EntityType.ZOMBIE);
     
  4. Offline

    nverdier

  5. Offline

    mkezar

  6. Offline

    nverdier

    @mkezar What method are you using? But the Zombie class is at the end of a long list of extensions, eventually going to LivingEntity, so you can just use the method on the Zombie.
     
  7. Offline

    Funergy

    @mkezar
    The Zombie from bukkit is an Living Entity. So just do what I did here. I casted the Entity to a Zombie (That is a LivingEntity) and then I can get the equipment.
    Code:
    Zombie z = (Zombie)player.getWorld().spawnEntity(player.getLocation(), EntityType.ZOMBIE);
    z.getEquipment().setHelmet(player.getInventory().getHelmet());
    
    
     
  8. Offline

    mkezar

    OMG OMG OMG OMG :D :D :D It works! thank you so much! im like really happy right now :)
     
    Funergy likes this.
  9. Offline

    nverdier

  10. Offline

    mkezar

    even though this thread technically is still in "solved" i have just ONE more question :p im trying to replace .getHelmet() with a players head and its not working out so well :p is there any methods that gets the players head like player.getHead() or like player.getSkull()? or anything like that? :D
     
  11. Offline

    nverdier

    @mkezar
    1) Create a new ItemStack
    Code:
    new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
    2) Get the SkullMeta
    Code:
    (SkullMeta) skullItemStack
    3) Set the owner
    Code:
    skullMeta.setOwner(String owner)
     
  12. Offline

    mkezar

    man, your the best :D
     
  13. Offline

    nverdier

Thread Status:
Not open for further replies.

Share This Page