1.15.2 How to change the state of the enderdragon?

Discussion in 'Spigot Plugin Development' started by CorruptedCookies, Jun 16, 2020.

  1. I'm trying to make an aggressive ender dragon, How would I achieve this?
     
  2. I am using 1.15.2, how could I make it attack though? Could you give me some example code?
     
  3. You can manually change the phase. Anything else requires complicated nms stuff.
     
  4. How would you change the phase? I'm kind of new to java/spigot API

    How would I write the line that changes the state? this is mostly what is confusing me the most
     
  5. This is pretty basic. If you don't know how to do that then I suggest you do something else (java tutorials) first.
     
  6. Could I at least get the answer? I've just never seen this done before and don't know how to figure it out
     
  7. I'm not giving you full (copyable) code. Instead here's some pseudo code
    Code (Text):
    get the end battle (hint: the world has a reference to it)
    get the enderdragon from that battle
    set the phase you want
    Of course you can get the enderdragon through other ways, if you for example have spawned one yourself. Also you can change the phase on whatever occasion you like.
    I gave you all the links to the docs you need in my previous posts.
     
  8. I understand what to do and how to do it. I just can't figure out how to change the state without getting an error

    This is how i'm doing it:
    EnderDragon.Phase.CHARGE_PLAYER

    Like what am I doing wrong here?
     
  9. You just write out the enum, nothing else.
    Here's some more detailed pseudo code...
    Code (Text):
    Enderdragon dragon = ...//told you how to get it
    dragon.setPhase(/*the enum phase you want*/)
     
  10. Thanks this was my only problem. Have a good day :)
     
  11. These are things you shouldn't have to struggle with. Everything is documented, just search terms like "Enderdragon" or "setPhase" in the docs and read the explanations.
    Anyway, glad you got it working.