Allow EnderDragon in 1.12 to Mimic Movement from 1.8

Discussion in 'Spigot Plugin Development' started by Redned, Jul 17, 2018.

  1. Hello all,

    Recently I've been working on EnderDragons for a boss plugin and from what I can understand, in 1.9 EnderDragon movement has changed quite a bit and any time an EnderDragon is spawned, it just spawns idle within the world.

    I've been able to hook into Bukkit's API and set the phase of the dragon to target the player. However the dragon never appears to find the player at all. I've debugged and tried many other solutions. I want to be able to spawn the dragon in back how it used to spawn in 1.8 but I don't want to have to use the center of the world every time.

    Is there a way I can either, a) Set the player target or, b) Change the area where the dragon considers the "center of the world". I've looked up lots of information on this and haven't been able to find much.

    Thanks
     
  2. ScarabCoder

    ScarabCoder Retired Resource Staff
    Retired

    You could check out the NMS AI from 1.8 and copy and paste and modify into your own custom AI class for the EnderDragon. Most of it will probably be in the pathfinding goals, though.
     
  3. Apparently with EnderDragons there is absolutely no pathfinding goals whatsoever. Even in both 1.8 and 1.12 classes I was unable to find anything regarding this.
     
  4. ScarabCoder

    ScarabCoder Retired Resource Staff
    Retired

    The AI is probably in the class then.
     
  5. I've looked through both multiple times and both are relatively the same. I can't find much regarding the movement and the flight patterns. Honestly if I could just change where the portal location is I'd be happy.
     
  6. The setup for phases is rather simple imo although to properly modify it will require a decent amount of additional work.

    To do it fully like 1.8 one of the better options is to copy the old pathfinder goals and force set them. But you will also have to remove any handling of the phase/manager system. Or if you can grab enough info from the current phases you can just create custom phases and use those instead.


    For the 'center of the world' part I'm not sure specifically what phase you are using but I assume "HoldingPattern" and the reason holding pattern centers the world on non-end worlds is due to it going to the end trophy(Which doesn't exist).
    Code (Java):
    BlockPosition localBlockPosition = this.a.world.q(new BlockPosition(WorldGenEndTrophy.a));
    And the default is... 0, 0
    Code (Java):
    public static final BlockPosition a = BlockPosition.ZERO;
    This is likely because "DragonControllerCharge" has a variable called "Vec3D c" which is the current position of the player and that isn't set inside that phase, it is set from some other source which I haven't looked into.

    Also like to add the reason it requires a decent amount of additional work to modify these phases is because mojang sets the phase from inside other phases. So lets say you added a new "Charge" to find the player then charge you'll have to also override "HoldingPattern" to then call your custom charge instead of mojangs.


    Since the first time someone mentioned the ender dragon phases and I helped it still seems no one has made a plugin to properly implement & give enderdragons custom phases. I did start a little project couple days ago but my time is limited and I've mostly left this community.

    Update: Worked on the project today for a bit and some decent success. Tons of cleanup needed and some basic things need to be finished still but it works at least.
     
    #6 Borlea, Jul 17, 2018
    Last edited: Jul 17, 2018
    • Informative Informative x 1
  7. Alright thank you, when I have time I'll test this. Keep me updated on your project.
     
  8. I've attempted to try and create my own phases but the issue I primarily run in to is that the DragonControllerPhase constructor is not visible. I'm not very experienced when it comes to reflection and such. Unless you have a better method of doing this, could you lead me into the right direction to solving this?

    Thanks
     
  9. Sorry for the late reply, don't really check Spigot much.
    I've pushed what I currently have working on github here.
    It is still missing some things like proper modifying of the area "HoldingPattern" since I have to play around with mojangs circle radius calculations, and likely some other random configuration options but base seems to work.
    It is also missing proper saving through shutdowns(The manager will have to be re-applied) and I haven't tested what happens when you create more phases then the client knows exists.

    Had some headaches trying to think of clear ways to explain what a method does because the way Spigot named the ender dragon classes just destroys my brain.

    Hopefully a good chunk is self explanatory. EnderDragonControl has a few methods you can use(setCustomManager is required), then getPhaseManager is used for setting/getting the phases of EnderDragon and modifying the data of the phase.
    I'll probably add a basic wiki for what methods do.
     
    #9 Borlea, Jul 18, 2018
    Last edited: Jul 18, 2018