Why am I having to LivingEntity instanceof LivingEntity?

Discussion in 'Bukkit Help' started by TheTennessee, Aug 18, 2011.

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


    Okay, the following error is seriously driving me nuts. I updated to 1060 in order to support it with my plugin, but an error in 1060 is making it impossible for me to actually make my plugin. Here's what happens. I get this in my console:
    2011-08-18 22:37:00 [SEVERE] Could not pass event ENTITY_TARGET to AnimalCompanion
    java.lang.ClassCastException: org.bukkit.craftbukkit.entity.CraftArrow cannot be cast to org.bukkit.craftbukkit.entity.CraftLivingEntity
        at org.bukkit.craftbukkit.entity.CraftCreature.getTarget(CraftCreature.java:28)
        at org.bukkit.craftbukkit.entity.CraftCreature.getTarget(CraftCreature.java:9)
        at com.bukkit.tennessee.AnimalCompanion.AnimalCompanionEntityListener.onEntityTarget(AnimalCompanionEntityListener.java:488)
        at org.bukkit.plugin.java.JavaPluginLoader$64.execute(JavaPluginLoader.java:691)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:338)
        at net.minecraft.server.EntityCreature.c_(EntityCreature.java:32)
        at net.minecraft.server.EntityLiving.v(EntityLiving.java:685)
        at net.minecraft.server.EntityMonster.v(EntityMonster.java:26)
        at net.minecraft.server.EntitySkeleton.v(EntitySkeleton.java:45)
        at net.minecraft.server.EntityLiving.m_(EntityLiving.java:218)
        at net.minecraft.server.EntityMonster.m_(EntityMonster.java:30)
        at net.minecraft.server.World.entityJoinedWorld(World.java:1212)
        at net.minecraft.server.WorldServer.entityJoinedWorld(WorldServer.java:48)
        at net.minecraft.server.World.playerJoinedWorld(World.java:1194)
        at net.minecraft.server.World.cleanUp(World.java:1110)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:450)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:363)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    Which I found out points to this line:

    if(((Wolf)possibleWolves.get(i)).getTarget() == null)

    So, here's my wtf moment... I'm not dereferencing the getTarget() at all, so this shouldn't be throwing an error. I am making SURE that the target isn't null before I proceed. But wait, I figured it out, it's not me at all.

    See, instead it's getTarget trying to cast an Arrow entity into a LivingEntity, which isn't me at all! Bukkit, can you PLEASE fix this so I can finish my plugin? Every time this error gets thrown, it causes my plugin to just NOT work, and it's driving me up a wall.

    I think you need an "instanceof LivingEntity" before you cast it. Dunno how the arrow is getting SET to the target, but yeah...

    Looks like a mitigated its effect on my plugin, but it still shows up.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 18, 2016
Thread Status:
Not open for further replies.

Share This Page