--- a/net/minecraft/world/entity/projectile/EntityEnderPearl.java
+++ b/net/minecraft/world/entity/projectile/EntityEnderPearl.java
@@ -29,6 +29,13 @@
 import net.minecraft.world.phys.MovingObjectPositionEntity;
 import net.minecraft.world.phys.Vec3D;
 
+// CraftBukkit start
+import net.minecraft.world.level.dimension.WorldDimension;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.player.PlayerTeleportEvent;
+// CraftBukkit end
+
 public class EntityEnderPearl extends EntityProjectileThrowable {
 
     private long ticketTimer = 0L;
@@ -140,12 +147,19 @@
                         EntityPlayer entityplayer = (EntityPlayer) entity;
 
                         if (entityplayer.connection.isAcceptingMessages()) {
+                            // CraftBukkit start
+                            EntityPlayer entityplayer1 = entityplayer.teleport(new TeleportTransition(worldserver, vec3d, Vec3D.ZERO, 0.0F, 0.0F, Relative.union(Relative.ROTATION, Relative.DELTA), TeleportTransition.DO_NOTHING, PlayerTeleportEvent.TeleportCause.ENDER_PEARL));
+                            if (entityplayer1 == null) {
+                                this.discard(EntityRemoveEvent.Cause.HIT);
+                                return;
+                            }
+                            // CraftBukkit end
                             if (this.random.nextFloat() < 0.05F && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
                                 EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(worldserver, EntitySpawnReason.TRIGGERED);
 
                                 if (entityendermite != null) {
                                     entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
-                                    worldserver.addFreshEntity(entityendermite);
+                                    worldserver.addFreshEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL);
                                 }
                             }
 
@@ -153,12 +167,12 @@
                                 entity.setPortalCooldown();
                             }
 
-                            EntityPlayer entityplayer1 = entityplayer.teleport(new TeleportTransition(worldserver, vec3d, Vec3D.ZERO, 0.0F, 0.0F, Relative.union(Relative.ROTATION, Relative.DELTA), TeleportTransition.DO_NOTHING));
+                            // EntityPlayer entityplayer1 = entityplayer.teleport(new TeleportTransition(worldserver, vec3d, Vec3D.ZERO, 0.0F, 0.0F, Relative.union(Relative.ROTATION, Relative.DELTA), TeleportTransition.DO_NOTHING)); // CraftBukkit - moved up
 
                             if (entityplayer1 != null) {
                                 entityplayer1.resetFallDistance();
                                 entityplayer1.resetCurrentImpulseContext();
-                                entityplayer1.hurtServer(entityplayer.serverLevel(), this.damageSources().enderPearl(), 5.0F);
+                                entityplayer1.hurtServer(entityplayer.serverLevel(), this.damageSources().enderPearl().customEntityDamager(this), 5.0F); // CraftBukkit
                             }
 
                             this.playSound(worldserver, vec3d);
@@ -173,11 +187,11 @@
                         this.playSound(worldserver, vec3d);
                     }
 
-                    this.discard();
+                    this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
                     return;
                 }
 
-                this.discard();
+                this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
                 return;
             }
         }
@@ -210,7 +224,7 @@
             entity = this.getOwner();
             if (entity instanceof EntityPlayer entityplayer) {
                 if (!entity.isAlive() && entityplayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) {
-                    this.discard();
+                    this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
                     break label30;
                 }
             }
@@ -248,7 +262,7 @@
 
     @Override
     public boolean canTeleport(World world, World world1) {
-        if (world.dimension() == World.END && world1.dimension() == World.OVERWORLD) {
+        if (world.getTypeKey() == WorldDimension.END && world1.getTypeKey() == WorldDimension.OVERWORLD) { // CraftBukkit
             Entity entity = this.getOwner();
 
             if (entity instanceof EntityPlayer) {
