--- a/net/minecraft/world/entity/projectile/EntityEnderPearl.java +++ b/net/minecraft/world/entity/projectile/EntityEnderPearl.java @@ -21,6 +21,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 { public EntityEnderPearl(EntityTypes entitytypes, World world) { @@ -65,19 +72,26 @@ EntityPlayer entityplayer = (EntityPlayer) entity; if (entityplayer.connection.isAcceptingMessages()) { + // CraftBukkit start + Entity tp = entity.changeDimension(new DimensionTransition(worldserver, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING, PlayerTeleportEvent.TeleportCause.ENDER_PEARL)); + if (tp == 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); 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); } } - entity.changeDimension(new DimensionTransition(worldserver, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING)); + // entity.changeDimension(new DimensionTransition(worldserver, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING)); // CraftBukkit - moved up entity.resetFallDistance(); entityplayer.resetCurrentImpulseContext(); - entity.hurt(this.damageSources().fall(), 5.0F); + entity.hurt(this.damageSources().fall().customEntityDamager(this), 5.0F); // CraftBukkit this.playSound(worldserver, this.position()); } } else { @@ -86,11 +100,11 @@ this.playSound(worldserver, this.position()); } - 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; } } @@ -116,7 +130,7 @@ Entity entity = this.getOwner(); if (entity instanceof EntityPlayer && !entity.isAlive() && this.level().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) { - this.discard(); + this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } else { super.tick(); } @@ -129,7 +143,7 @@ @Override public boolean canChangeDimensions(World world, World world1) { - if (world.dimension() == World.END) { + if (world.getTypeKey() == WorldDimension.END) { // CraftBukkit Entity entity = this.getOwner(); if (entity instanceof EntityPlayer) {