1.8.8 NMS Custom Ender Dragon

Discussion in 'Spigot Plugin Development' started by Delected_, Oct 9, 2020.

  1. Hey! I've been playing around with custom entities and pathfinders. Basically, I am trying to make my EntityEnderDragon go to a certain coord and then roam around within a certain radius. I am unable to use
    PathfinderGoalRandomStroll because it wants an entityCreature.

    If someone could explain to me how I could do such a thing, that'd be awesome.

    Cheers!
     
  2. For going to a certain coordinate you can spawn an entity there and set the dragons target to that entity.
    The else, idk
     
  3. The dragon spawning has been done, but coords are not an entity right? Once the dragon is spawned, it always ends up going to 0,0.

    Not sure, I never touch NMS
     
  4. What?
    Spawn an entity to the coordinates that you want the dragon to go to, and set the dragons target to that entity (dragon#setTarget(entity))
     
  5. This should let the EnderDragon "walk" to the location you want.
    Code (Java):
    public void walkToPosition(LivingEntity le, Location loc, float speed) {
        ((CraftCreature) le)
                .getHandle()
                .getNavigation()
                .a(loc.getX(), loc.getY(), loc.getZ(), speed);
    }
     
  6. Alright, thanks. This will work on 1.8 with an EntityEnderDragon, right?
     
  7. Yea, I got that.

    I just mean like what entity do I set as its target? Coords aren't an entity. Would I have to spawn like a pig or something that it targets?
     
  8. You can use anything really. You could spawn an invisible armor stand as the target
     
  9. Should work, yes.
     
  10. Well EntityCreature or Creature is how you set the target of the mob, LivingEntity doesn't supply a function for it.
    When casting the Enderdragon to Creature it returns a cast error.

    Right now me and Delected are using NMS because of how customizable it is.
    BUT! There are very little tutorials of using NMS for 1.8, which is the reason why we are here.
     
  11. Code (Java):

    java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R3.entity.CraftEnderDragon cannot be cast to org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature
            at xyz.apollo30.skyblockremastered.events.Dragon.walkToPosition(Dragon.java:238) ~[?:?]
            at xyz.apollo30.skyblockremastered.events.Dragon.lambda$null$2(Dragon.java:229) ~[?:?]
            at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:59) ~[patched.jar:git-PaperSpigot-"4c7641d"]
            at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:352) [patched.jar:git-PaperSpigot-"4c7641d"]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:783) [patched.jar:git-PaperSpigot-"4c7641d"]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378) [patched.jar:git-PaperSpigot-"4c7641d"]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:713) [patched.jar:git-PaperSpigot-"4c7641d"]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:616) [patched.jar:git-PaperSpigot-"4c7641d"]
            at java.lang.Thread.run(Thread.java:748) [?:1.8.0_265]
     
     
  12. Well enderdragon does not implement creature for some reason it looks like
    https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/EnderDragon.html

    Also if you are using server jars to access NMS classes it will be version dependant.
    Meaning they won't work on other server versions unless added as libs and coded for that version too
     
  13. Sorry but Apollo and I are still a bit confused on what we could do. What was mentioned above would work for zombies, for example, but ender dragon pathfinding is so much different from literally any other mob in the game.

    Bump.
     
  14. Well it looks like the Enderdragon (or rather EntityInsentient) has a direct function to access its navigation. In 1.14 at least, which is the lowest version I have experience with. Try if you can do:
    Code (Java):
    this.getNavigation().a(loc.getX(), loc.getY(), loc.getZ(), speed);
    inside your custom class extending EntityEnderDragon.
     
  15. Pretty sure I've tried that, but I don't think it works on 1.8.8. Thanks for the reply tho, I'll try it out tomorrow!

    EDIT: ^^ Because I'm not certain if that is what I tried.
     
  16. Doesn't seem to work at all, although how would I check once the task to head to that specific coordinate is done?
    Not to mention the variable speed? Does it determine how long it takes before executing, how fast until the dragon completes that task? What does it do? Setting it to 1-1000 doesn't affect the speed.
     
    #16 Apollyon365, Oct 11, 2020
    Last edited: Oct 11, 2020
  17. Still looking for a solution. Thanks for everyones' replies, they are getting us closer to an answer.

    Bump.
     
  18. been 12 hours, bump
     
  19. We already answered your request, we won’t spoon feed you.