Solved Could not cast Slime to Creature

Discussion in 'Plugin Development' started by Deleted user, Dec 8, 2014.

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

    Deleted user

    I need a Creature object to access the Creature.setTarget(LivingEntity) method.
    How do I get it from a Slime object?

    Here is what I have so far. The same problem occurs when using an Entity object.
    Code:java
    1. Creature creature = (Creature)Slime;

    Code:
    java.lang.ClassCastException: org.bukkit.craftbukkit.v1_7_R3.entity.CraftSlime cannot be cast to org.bukkit.entity.Creature
     
    Last edited by a moderator: Dec 10, 2014
  2. Joiner I'm guessing that'll be because CraftSlime isn't a Creature ;) Have you tried looking at the methods (including inherited methods) that CraftSlime has available?
     
  3. Offline

    aaomidi

    Joiner Please don't name your variables starting with capital letters, follow the java conventions.
     
    AdamQpzm likes this.
  4. Offline

    Deleted user

    AdamQpzm :O
    Then how do I get access to the Creature.setTarget(LivingEntity) method for a slime?

    aaomidi It is not a variable. I use to put the class name to represent a non-relevant variable when posting on the web.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 29, 2016
  5. Offline

    aaomidi

  6. Offline

    Deleted user

    aaomidi I cannot find any Slime.setTarget(LivingEntity) methods.
     
  7. Offline

    fireblast709

    Joiner that should tell you enough about Slimes :p.
     
  8. Offline

    Deleted user

  9. Offline

    fireblast709

    Joiner that you can't set it's target (at least not through the API).
     
  10. Offline

    Deleted user

    fireblast709 Ok. What does the Creature class represent?
    It says: Creatures are non-intelligent monsters or animals which have very simple abilities.
    Isn't slime a monster?
     
  11. Offline

    teej107

    Joiner Looks at Slime's superinterfaces
     
  12. Offline

    fireblast709

    Joiner If Slime doesn't extend / implement Creature then that's too bad, not much you can do about it. For all we know, this might be a huge bug, and at the same time it might be intended.
     
  13. Offline

    Deleted user

  14. Offline

    Gingerbreadman

    @Joiner [NMS] You can try to make a class that extends EntitySlime and implements Creature
     
  15. @Gingerbreadman The solution wouldn't be so simple, though. You could, but you'd still need to actually make the methods yourself.
     
  16. Offline

    Gingerbreadman

  17. Offline

    Deleted user

  18. Offline

    fireblast709

    @Joiner you could always check which PathfinderGoals Slimes have, and set the target yourself (requires some knowledge of nms, but you might avoid implementing stuff yourself)
     
  19. Offline

    Deleted user

    @fireblast709 Too hard.
    EntityTargetEvent.setTarget(Entity) seems easy, then why is it so hard out of that event?
     
  20. @Joiner Maybe it's not in Slime's nature to have a target. Maybe it was a mistake.
     
  21. Offline

    Deleted user

  22. Offline

    Gingerbreadman

    @Joiner I actually was working on an API (It works, I just didint release it), it lets you change the health, speed, damage per an attack and target
     
  23. Offline

    Deleted user

Thread Status:
Not open for further replies.

Share This Page