2021-03-16 09:00:00 +11:00
|
|
|
--- a/net/minecraft/world/entity/projectile/EntityEnderPearl.java
|
|
|
|
+++ b/net/minecraft/world/entity/projectile/EntityEnderPearl.java
|
2023-12-06 03:40:00 +11:00
|
|
|
@@ -18,6 +18,13 @@
|
2021-03-16 09:00:00 +11:00
|
|
|
import net.minecraft.world.phys.MovingObjectPosition;
|
|
|
|
import net.minecraft.world.phys.MovingObjectPositionEntity;
|
2021-03-09 08:47:33 +11:00
|
|
|
|
2014-11-26 08:32:16 +11:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.Bukkit;
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2016-07-01 12:30:28 +10:00
|
|
|
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
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) {
|
2023-12-06 03:40:00 +11:00
|
|
|
@@ -54,23 +61,36 @@
|
2020-06-25 10:00:00 +10:00
|
|
|
EntityPlayer entityplayer = (EntityPlayer) entity;
|
2015-02-26 22:41:06 +00:00
|
|
|
|
2023-06-08 01:30:00 +10:00
|
|
|
if (entityplayer.connection.isAcceptingMessages() && entityplayer.level() == this.level() && !entityplayer.isSleeping()) {
|
|
|
|
- if (this.random.nextFloat() < 0.05F && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
|
|
|
|
- EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(this.level());
|
2014-11-26 08:32:16 +11:00
|
|
|
+ // CraftBukkit start - Fire PlayerTeleportEvent
|
|
|
|
+ org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayer.getBukkitEntity();
|
|
|
|
+ org.bukkit.Location location = getBukkitEntity().getLocation();
|
|
|
|
+ location.setPitch(player.getLocation().getPitch());
|
|
|
|
+ location.setYaw(player.getLocation().getYaw());
|
2023-09-22 02:57:13 +10:00
|
|
|
|
|
|
|
- if (entityendermite != null) {
|
|
|
|
- entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
|
|
|
|
- this.level().addFreshEntity(entityendermite);
|
2014-11-26 08:32:16 +11:00
|
|
|
+ PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
|
|
|
|
+ Bukkit.getPluginManager().callEvent(teleEvent);
|
|
|
|
+
|
2023-03-15 04:14:08 +11:00
|
|
|
+ if (!teleEvent.isCancelled() && entityplayer.connection.isAcceptingMessages()) {
|
2023-06-08 01:30:00 +10:00
|
|
|
+ if (this.random.nextFloat() < 0.05F && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
|
|
|
|
+ EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(this.level());
|
2021-06-11 15:00:00 +10:00
|
|
|
+
|
2022-12-08 03:00:00 +11:00
|
|
|
+ if (entityendermite != null) {
|
|
|
|
+ entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
|
2023-06-08 01:30:00 +10:00
|
|
|
+ this.level().addFreshEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL);
|
2022-12-08 03:00:00 +11:00
|
|
|
+ }
|
|
|
|
}
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if (entity.isPassenger()) {
|
|
|
|
- entityplayer.dismountTo(this.getX(), this.getY(), this.getZ());
|
|
|
|
- } else {
|
|
|
|
- entity.teleportTo(this.getX(), this.getY(), this.getZ());
|
2023-09-22 02:57:13 +10:00
|
|
|
- }
|
|
|
|
+ if (entity.isPassenger()) {
|
|
|
|
+ entity.stopRiding();
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- entity.resetFallDistance();
|
|
|
|
- entity.hurt(this.damageSources().fall(), 5.0F);
|
2021-06-11 15:00:00 +10:00
|
|
|
+ entityplayer.connection.teleport(teleEvent.getTo());
|
2021-11-22 09:00:00 +11:00
|
|
|
+ entity.resetFallDistance();
|
2014-11-26 08:32:16 +11:00
|
|
|
+ CraftEventFactory.entityDamage = this;
|
2023-03-15 03:30:00 +11:00
|
|
|
+ entity.hurt(this.damageSources().fall(), 5.0F);
|
2014-11-26 08:32:16 +11:00
|
|
|
+ CraftEventFactory.entityDamage = null;
|
2023-09-22 02:57:13 +10:00
|
|
|
+ }
|
2014-11-26 08:32:16 +11:00
|
|
|
+ // CraftBukkit end
|
2023-12-06 03:40:00 +11:00
|
|
|
this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_TELEPORT, SoundCategory.PLAYERS);
|
2016-03-02 16:48:00 +00:00
|
|
|
}
|
2020-06-25 10:00:00 +10:00
|
|
|
} else if (entity != null) {
|
2023-12-06 03:40:00 +11:00
|
|
|
@@ -100,7 +120,7 @@
|
2021-11-22 09:00:00 +11:00
|
|
|
public Entity changeDimension(WorldServer worldserver) {
|
|
|
|
Entity entity = this.getOwner();
|
2020-08-28 12:28:06 +10:00
|
|
|
|
2023-06-08 01:30:00 +10:00
|
|
|
- if (entity != null && entity.level().dimension() != worldserver.dimension()) {
|
|
|
|
+ if (entity != null && worldserver != null && entity.level().dimension() != worldserver.dimension()) { // CraftBukkit - SPIGOT-6113
|
2021-11-22 09:00:00 +11:00
|
|
|
this.setOwner((Entity) null);
|
2020-08-28 12:28:06 +10:00
|
|
|
}
|
|
|
|
|