[SPIGOT-7063] DragonBattle.initiateRespawn() shouldn't check if the 4 ender crystal are placed Created: 15/Jun/22  Updated: 25/Dec/24  Resolved: 04/Aug/23

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: MrSot Assignee: Doc
Resolution: Fixed Votes: 0
Labels: NMS, Spigot, enderdragon, spigot
Environment:

Spigot 1.18.1


Issue Links:
Relates
relates to SPIGOT-6498 It is impossible to respawn the ender... Resolved
Version: 1.18.1
Guidelines Read: Yes

 Description   

The DragonBattle.initiateRespawn() function calls an NMS function, which checks if the 4 ender crystals are placed (as one would manually respawn the ender dragon), and only then proceeds to respawn the dragon using an different private NMS function.

Why is this? wouldn't it be better if it would actually just respawn the dragon (using the previously mentioned private function), or create a new function called respawn() ?

More info (and solution): https://www.spigotmc.org/threads/re-spawning-the-ender-dragon.255183/#post-2534599



 Comments   
Comment by Doc [ 15/Jun/22 ]

Created PR with this method

https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/pull-requests/763/overview

https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/1071/overview

 

The logic is allow pass custom ender crystals or empty/null and follow this tasks

  • Validate exit portal like NMS
  • Ignore the ender crystals not valid (in another world than the dragon battle or with null world)
Comment by MrSot [ 15/Jun/22 ]

You're right, that's a better idea. Thanks I really appreciate it

Comment by Doc [ 15/Jun/22 ]

Hmm okay i see its "valid" pass a empty list (if pass a null list the server can try again to respawn based in the rules).

i think can be better a method like DragonBattle#initiateRespawn(List<EnderCrystal> list) for pass endercrystals in custom positions and allow pass null/empty list for work like the NMS method but with empty list... if can i make a PR with this idea and see what happen.

Comment by MrSot [ 15/Jun/22 ]

At the end of the NMS method used by initiateRespawn(), there is a function call to a private method which accepts a List of NMS' ender crystal entities.

The private method is called with a List of those 4 placed ender crystals, by the NMS method used by initiateRespawn() (which populates the List)

So the private method is actually responsible for respawning the ender dragon.

My suggestion would be to create a new DragonBattle function called respawn(), which would call the private function (using Reflection) with an empty List.

There's my implementation: https://github.com/kvbc/EndlessDragon/blob/2d8a6aab1a82f16fcd36cf7a05d573a81fa147bd/src/main/java/io/github/kvbc/endlessdragon/EndlessDragon.java#L56

Based on: https://www.spigotmc.org/threads/re-spawning-the-ender-dragon.255183/#post-2534599

Also, in my opinion, the docs don't clearly state that the 4 ender crystals should be placed before calling initiateRespawn()

Comment by Doc [ 15/Jun/22 ]

The docs about the method already say about the requeriments. (https://hub.spigotmc.org/javadocs/spigot/org/bukkit/boss/DragonBattle.html#initiateRespawn())

the suggention its like the same method but with a "boolean force" param for not validate the crystals? ifs so then how can this works? the NMS method for initiateRespawn use the Crystals placed for the animation for respawn the dragon and another things for start the battle again.

Generated at Tue Apr 15 08:35:15 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.