The bug
Ender dragons, like most entities, use end gateways when touching them. If, for some reason, the ender dragon flies through an end portal, it will be teleported through it, away from the main island and loaded chunks.
How to reproduce
/execute in minecraft:the_end run tp @p 0 80 5 180 -30
/setblock 0 ~5 0 minecraft:end_gateway{ExitPortal:{X:-100,Y:100,Z:0}} replace
Update: In 1.17 snapshots it requires several tries for this but to occur. It is inconsistent for some reason.
Code Analysis & Fix
Code Analysis done by @unknown
The End Gateway allows all entities, including dragons to teleport through it. Simply doing a check in the canEntityTeleport method in the TheEndGatewayBlockEntity class for the ender dragon fixes this issue
Current Code
net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
public static boolean canEntityTeleport(Entity p_59941_) {
return EntitySelector.NO_SPECTATORS.test(p_59941_) && !p_59941_.getRootVehicle().isOnPortalCooldown();
}
Fixed Code
net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
public static boolean canEntityTeleport(Entity p_59941_) {
//Check if the entity is the Ender Dragon fixes MC-86836 & MC-257097
if(p_59941_ instanceof EnderDragon)
{
return false;
}
else {
return EntitySelector.NO_SPECTATORS.test(p_59941_) && !p_59941_.getRootVehicle().isOnPortalCooldown();
}
}
Linked issues
is duplicated by 5
relates to 2
Attachments
Comments 38
yeah, also reported by me. ๐
After fix of MC 85542 i checked what happens now.
Interesting fact is that enderdragon can't tp to overworld via end_portal.
@unknown, 1.20 is an outdated and archived version, and thus cannot be added to reports. Only the latest release or latest snapshot can be added as affected versions.
Most likely caused by the fix of MC-85542