The dragon egg does not spawn if there already is an end gateway.
Steps to reproduce
- Create a new world
- Go to the End
- Place an end gateway (for example using the command /setblock ~ ~100 ~ end_gateway to make sure that the dragon does not escape through it)
- Leave the world (or the server) and open it again (or rejoin)
- Kill the ender dragon. Note that no egg is spawned.
The egg will spawn if you skipped step 3 or step 4.
If you are trying to Spawn a Dragon for the first time and you have an End Gateway around for some reason already, it will spawn a Dragon which does not behave like the first one. I think changing the detection for endPortals to something like this is going to be sufficient.