Give mobs armour

Discussion in 'Plugin Development' started by PureGero, Feb 24, 2013.

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


    Is there any way to give mobs armor, that works for the latest craftbukkit version? I want a simple function that takes in (ItemStack),(slot int) and (Entity) and will change the entity's equiptment
  2. Offline


    You're after entity.getEquipment() - Gives you an EntityEquipment object that allows you to set the armor, item in hand, and drop chances.
  3. Offline


    hatstand I did try this, but i can't convert Entity to EntityLiving to use this, is there any other way?
  4. Offline


    Check if the entity is an instance of EntityLiving, if it is, cast it.

    Unless you want to go digging around in CB internal stuff, which is a terrible idea, and more complex than that.
  5. Offline


    hatstand When I cast it, the console just gives errors

    java.lang.ClassCastException: org.bukkit.craftbukkit.v1_4_R1.entity.CraftZombie cannot be cast to net.minecraft.server.v1_4_R1.EntityLiving
  6. Offline


    Just double checked that, you're after LivingEntity, not EntityLiving - The former is a Bukkit class, the latter is an NMS class. Hence the exception.

    For reference, this is a similar section of code I'm using:
                EntityType type = event.getEntityType();
                if(type == EntityType.ZOMBIE || type == EntityType.SKELETON)
                    SpawnReason reason = event.getSpawnReason();
                    if(reason == SpawnReason.NATURAL)
                        LivingEntity entity = event.getEntity();
                        EntityEquipment equips = entity.getEquipment();
    This is in a handler for a CreatureSpawnEvent, so I don't need to cast it.
  7. Offline


    Sorry, i was using .setEquiptment() not .getEquiptment()
  8. Offline


    You should be warned that armor doesn't render for non-undead mobs. (At least, I think it doesn't)
  9. Offline


    Would this also work for implementing player heads and overriding skeletons with bows?
  10. Offline


Thread Status:
Not open for further replies.

Share This Page