Since 19w08b, the Ender Dragon's vertical velocity when flying to a target node has been incorrect, causing erratic behavior and difficulties flying towards its target, flying back and forth around it. This is most obvious on its perching phase, but also during its hover phase, when it is seen flying back and forth repetitively around its nodes.
This issue is responsible of MC-271336, MC-271337, and in some ways to MC-197201 as the dragon would often fail to reach the player when charging it after a perch. Contrary to what those reports suggest, it is unrelated to the dragon phase mechanic or to any fix given in 19w08b, and must have been introduced in an internal rewrite.
An earlier report, MC-201937 described the same issue but was wrongfully ruled as invalid.
Expected behavior:
The dragon is able to fly up and dive down at the proper vertical velocity and reach its target with the shortest path possible, without needing to fly back and forth.
Steps to Reproduce:
There are several ways to reproduce it:
First way:
1. Go to the End, break all crystals and wait for the dragon to perch on the end podium
-> Notice how it roams back and forth while slowly descending to the podium
Second way:
1. Go to the End, break all crystals
2. Wait for it to perch, build a pillar with a significant height with respect to the end podium, several dozens of blocks away from the dragon, sufficiently far and close to it to charge you at the end of the perch
3. Stand on the pillar and Switch to survival mode
-> Notice how the dragon often fails to charge at the player and glides below the player
Third way (if you have sufficient knowledge of the Ender Dragon's AI):
1. Go to the End
2. Stand by a dragon AI pathfinding node
3. Wait until the dragon pathfinds to it
-> Notice how the dragon circles back and forth and around the target node
Code Analysis:
Before 19w08b, there is a portion of code in the method directing the dragon's movement towards its target (called "aiStep" in mojmaps) which adjusted the vertical velocity of the ender dragon by a certain amount:
(Decompiled from Release 1.12, MCP mappings)
Vec3d vec3d = iphase.getTargetLocation();
if (vec3d != null)
{
double d6 = vec3d.xCoord - this.posX;
double d7 = vec3d.yCoord - this.posY;
double d8 = vec3d.zCoord - this.posZ;
double d3 = d6 * d6 + d7 * d7 + d8 * d8;
float f5 = iphase.getMaxRiseOrFall();
d7 = MathHelper.clamp(d7 / (double)MathHelper.sqrt(d6 * d6 + d8 * d8), (double)(-f5), (double)f5);
this.motionY += d7 * 0.10000000149011612D;
....However, in versions after 19w08b, the same portion of code shows a tiny mistake:
(Decompiled from Release 1.20.6, Mojmaps, in EnderDragon::aiStep)
Vec3 vec32 = dragonPhaseInstance.getFlyTargetLocation();
if (vec32 != null) {
double d = vec32.x - this.getX();
double e = vec32.y - this.getY();
double j = vec32.z - this.getZ();
double k = d * d + e * e + j * j;
float l = dragonPhaseInstance.getFlySpeed();
double m = Math.sqrt(d * d + j * j);
if (m > 0.0) {
e = Mth.clamp(e / m, (double)(-l), (double)l);
}
this.setDeltaMovement(this.getDeltaMovement().add(0.0, e * 0.01, 0.0));
....As shown here, the last line which modifies its vertical velocity, shows a mistake on the scaling factor (0.01 instead of 0.1).
The fix would be to change that scaling factor back to 0.1, which would fix all aforementioned issues related to the dragon behavior.
Linked issues
relates to 2
Attachments
Comments 15
Can confirm in 1.21.3 and 24w44a, it's worth noting that MC-158205, fixed in yesterday's snapshot, appeared in the same version as this bug.
Note that the ramifications of this bug are quite large. Fixing this typo would virtually invalidate all strategies of speedrunning and one cycling.
One cycling was possible before the bug was introduced, it may actually be faster to do even though it's more difficult, since you wouldn't have to wait for the dragon all the time, and the dragon would descend to the portal more often thanks to the fixed AI.
The code above is in net.minecraft.world.entity.boss.enderdragon.EnderDragon::aiStep, in the net/minecrat/world/entity/boss/ender/EnderDragon.class class file.
I used jd-gui-1.6.6.jar to open the current snapshot 26.1.jar. In the file net/minecrat/world/entity/boss/ender/EnderDragon.class, I found the code and marked it. So this bug can be confirmed in the newest version.
This bug is not fixed in the current version 26.1-snapshot 5. We expect the ender dragon behaves like that in 1.9-1.13 version. Also the behavior on bedrock edition is same to java edition 1.9-1.13. However after 1.14 the ender dragon moves so slow on Y axis, so it perches so slow and can’t charges at the player (The explanation in MC-197201 is a little bit inaccurate but the bug exists).
This data pack fixes the problem (https://modrinth.com/datapack/dragon-movement-fix ), it just makes dragon’s y velocity much larger. Then I load this data pack on 26.1-snapshot 5. My conclusion is that the incorrect y velocity leads to these problem, and there is no more AI problems.
Firstly, I gave ender dragon a custom name to know the data pack is loaded successfully.
Video 1: The ender dragon charged to player like that in 1.9-1.13. So it solved MC-197201.
Video 2: The ender dragon perches like that in 1.9-1.13. So it solved MC-272431.
I agree with the previous comments, as it marked in the screenshot(屏幕截图 2025-12-31 164529), ydd * 0.1D is written as ydd * 0.01D and leads to these two problems. I don’t think there is any more bugs in file net/minecrat/world/entity/boss/ender/EnderDragon.class.
I’m so surprised that MC-102774 is fixed. So it’s time for MC-197201 and MC-272431.
can confirm for 1.20.6