mojira.dev
MC-86836

Ender dragon can teleport through end_gateway

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

Attachments

Comments 38

Most likely caused by the fix of MC-85542

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.

Wrong link type, probably rather "Relates to"

Agreed, should be relates to. Can confirm.

28 more comments

Can confirm in 1.17.1.

@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.

Ok, but I can still confirmed this in 1.20.1

Nice! Thank you!

[Helper] Michaล‚

(Unassigned)

Confirmed

Gameplay

Low

Entities

end_gateway, ender_dragon, teleport

Minecraft 15w34b, Minecraft 15w41b, Minecraft 15w42a, Minecraft 15w43c, Minecraft 15w44a, ..., 21w16a, 1.17.1, 1.18 Pre-release 8, 22w44a, 1.20.1

Minecraft 15w49a

Retrieved