2021-03-16 09:00:00 +11:00
|
|
|
--- a/net/minecraft/world/entity/projectile/EntityEnderPearl.java
|
|
|
|
+++ b/net/minecraft/world/entity/projectile/EntityEnderPearl.java
|
2024-06-14 01:05:00 +10:00
|
|
|
@@ -21,6 +21,13 @@
|
2021-03-16 09:00:00 +11:00
|
|
|
import net.minecraft.world.phys.MovingObjectPositionEntity;
|
2024-06-14 01:05:00 +10:00
|
|
|
import net.minecraft.world.phys.Vec3D;
|
2021-03-09 08:47:33 +11:00
|
|
|
|
2014-11-26 08:32:16 +11:00
|
|
|
+// CraftBukkit start
|
2024-06-14 01:05:00 +10:00
|
|
|
+import net.minecraft.world.level.dimension.WorldDimension;
|
2016-07-01 12:30:28 +10:00
|
|
|
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
2024-02-21 20:55:34 +11:00
|
|
|
+import org.bukkit.event.entity.EntityRemoveEvent;
|
2014-11-26 08:32:16 +11:00
|
|
|
+import org.bukkit.event.player.PlayerTeleportEvent;
|
|
|
|
+// CraftBukkit end
|
2021-03-09 08:47:33 +11:00
|
|
|
+
|
2019-04-23 12:00:00 +10:00
|
|
|
public class EntityEnderPearl extends EntityProjectileThrowable {
|
2014-11-26 08:32:16 +11:00
|
|
|
|
2021-03-09 08:47:33 +11:00
|
|
|
public EntityEnderPearl(EntityTypes<? extends EntityEnderPearl> entitytypes, World world) {
|
2024-06-14 01:05:00 +10:00
|
|
|
@@ -65,19 +72,26 @@
|
|
|
|
EntityPlayer entityplayer = (EntityPlayer) entity;
|
2015-02-26 22:41:06 +00:00
|
|
|
|
2024-06-14 01:05:00 +10:00
|
|
|
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;
|
2022-12-08 03:00:00 +11:00
|
|
|
+ }
|
2024-06-14 01:05:00 +10:00
|
|
|
+ // 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);
|
|
|
|
}
|
|
|
|
}
|
2022-12-08 03:00:00 +11:00
|
|
|
|
2024-06-14 01:05:00 +10:00
|
|
|
- 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());
|
|
|
|
}
|
2023-09-22 02:57:13 +10:00
|
|
|
|
2024-06-14 01:05:00 +10:00
|
|
|
- this.discard();
|
|
|
|
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
|
|
|
|
return;
|
2016-03-02 16:48:00 +00:00
|
|
|
}
|
2024-02-21 20:55:34 +11:00
|
|
|
|
2024-06-14 01:05:00 +10:00
|
|
|
- this.discard();
|
|
|
|
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
|
|
|
|
return;
|
|
|
|
}
|
2024-02-21 20:55:34 +11:00
|
|
|
}
|
2024-06-14 01:05:00 +10:00
|
|
|
@@ -116,7 +130,7 @@
|
2024-02-21 20:55:34 +11:00
|
|
|
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();
|
|
|
|
}
|
2024-06-14 01:05:00 +10:00
|
|
|
@@ -129,7 +143,7 @@
|
2020-08-28 12:28:06 +10:00
|
|
|
|
2024-06-14 01:05:00 +10:00
|
|
|
@Override
|
|
|
|
public boolean canChangeDimensions(World world, World world1) {
|
|
|
|
- if (world.dimension() == World.END) {
|
|
|
|
+ if (world.getTypeKey() == WorldDimension.END) { // CraftBukkit
|
|
|
|
Entity entity = this.getOwner();
|
2020-08-28 12:28:06 +10:00
|
|
|
|
2024-06-14 01:05:00 +10:00
|
|
|
if (entity instanceof EntityPlayer) {
|