--- a/net/minecraft/world/level/block/BlockEnderPortal.java
+++ b/net/minecraft/world/level/block/BlockEnderPortal.java
@@ -19,6 +19,13 @@
 import net.minecraft.world.phys.shapes.VoxelShapeCollision;
 import net.minecraft.world.phys.shapes.VoxelShapes;
 
+// CraftBukkit start
+import net.minecraft.server.level.EntityPlayer;
+import net.minecraft.world.level.dimension.WorldDimension;
+import org.bukkit.event.entity.EntityPortalEnterEvent;
+import org.bukkit.event.player.PlayerTeleportEvent;
+// CraftBukkit end
+
 public class BlockEnderPortal extends BlockTileEntity {
 
     protected static final VoxelShape SHAPE = Block.box(0.0D, 6.0D, 0.0D, 16.0D, 12.0D, 16.0D);
@@ -40,13 +47,22 @@
     @Override
     public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
         if (world instanceof WorldServer && entity.canChangeDimensions() && VoxelShapes.joinIsNotEmpty(VoxelShapes.create(entity.getBoundingBox().move((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(world, blockposition), OperatorBoolean.AND)) {
-            ResourceKey<World> resourcekey = world.dimension() == World.END ? World.OVERWORLD : World.END;
+            ResourceKey<World> resourcekey = world.getTypeKey() == WorldDimension.END ? World.OVERWORLD : World.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends
             WorldServer worldserver = ((WorldServer) world).getServer().getLevel(resourcekey);
 
             if (worldserver == null) {
-                return;
+                // return; // CraftBukkit - always fire event in case plugins wish to change it
             }
 
+            // CraftBukkit start - Entity in portal
+            EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+            world.getCraftServer().getPluginManager().callEvent(event);
+
+            if (entity instanceof EntityPlayer) {
+                ((EntityPlayer) entity).changeDimension(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL);
+                return;
+            }
+            // CraftBukkit end
             entity.changeDimension(worldserver);
         }
 
