Custom Mob with armor

Discussion in 'Plugin Development' started by Julian., Aug 23, 2021.

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

    Julian.

    Hi i trying to make custom mob have amor when i try to cast my custom mob in EntitySpawnigEvent with the armor i choice its say
    Code:
    Caused by: java.lang.ClassCastException: fr.julian.SpecialMob.SpeMob.ZombieCuir cannot be cast to org.bukkit.entity.LivingEntity
            at fr.julian.SpecialMob.events.SpawningEvent.onSpawn(SpawningEvent.java:100) ~[?:?]
            at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source) ~[?:?]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_211]
            at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_211]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:315) ~[server.jar:git-Spigot-37d799b-3eb7236]



    and there is my code :

    Code:
    if (chance < 0.75f && chance > 0.25f) {
                    ZombieCuir ZombieC = new ZombieCuir(e.getLocation());
                    ((CraftWorld) e.getLocation().getWorld()).getHandle().addEntity(ZombieC);
                    LivingEntity entity = (LivingEntity)ZombieC;
                   
                    entity.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
                }
     
  2. Offline

    davidclue

    You cannot cast your custom class to a LivingEntity, read the error.
     
  3. Offline

    Tim_M

    Why dont you try ZombieC.getBukkitEntity().getInventory().setBoots() //not sure if thats how you do it but smthing like that.
     
Thread Status:
Not open for further replies.

Share This Page