aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch140
1 files changed, 140 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch
new file mode 100644
index 0000000000..0bf0250ceb
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch
@@ -0,0 +1,140 @@
+--- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
++++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
+@@ -10,14 +10,22 @@
+ import net.minecraft.world.entity.EntityType;
+ import net.minecraft.world.entity.LivingEntity;
+ import net.minecraft.world.entity.monster.Endermite;
++import net.minecraft.world.entity.player.Player;
+ import net.minecraft.world.item.Item;
+ import net.minecraft.world.item.Items;
+ import net.minecraft.world.level.GameRules;
+ import net.minecraft.world.level.Level;
+ import net.minecraft.world.phys.EntityHitResult;
+ import net.minecraft.world.phys.HitResult;
++// CraftBukkit start
++import org.bukkit.Bukkit;
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++import org.bukkit.event.entity.CreatureSpawnEvent;
++import org.bukkit.event.player.PlayerTeleportEvent;
++// CraftBukkit end
+
+ public class ThrownEnderpearl extends ThrowableItemProjectile {
++
+ public ThrownEnderpearl(EntityType<? extends ThrownEnderpearl> entityType, Level level) {
+ super(entityType, level);
+ }
+@@ -41,66 +49,78 @@
+ protected void onHit(HitResult result) {
+ super.onHit(result);
+
+- for (int i = 0; i < 32; i++) {
+- this.level()
+- .addParticle(
+- ParticleTypes.PORTAL,
+- this.getX(),
+- this.getY() + this.random.nextDouble() * 2.0,
+- this.getZ(),
+- this.random.nextGaussian(),
+- 0.0,
+- this.random.nextGaussian()
+- );
++ for (int i = 0; i < 32; ++i) {
++ this.level().addParticle(ParticleTypes.PORTAL, this.getX(), this.getY() + this.random.nextDouble() * 2.0D, this.getZ(), this.random.nextGaussian(), 0.0D, this.random.nextGaussian());
+ }
+
+ if (!this.level().isClientSide && !this.isRemoved()) {
+- Entity owner = this.getOwner();
+- if (owner instanceof ServerPlayer serverPlayer) {
+- if (serverPlayer.connection.isAcceptingMessages() && serverPlayer.level() == this.level() && !serverPlayer.isSleeping()) {
+- if (this.random.nextFloat() < 0.05F && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
+- Endermite endermite = EntityType.ENDERMITE.create(this.level());
+- if (endermite != null) {
+- endermite.moveTo(owner.getX(), owner.getY(), owner.getZ(), owner.getYRot(), owner.getXRot());
+- this.level().addFreshEntity(endermite);
++ Entity entity = this.getOwner();
++
++ if (entity instanceof ServerPlayer) {
++ ServerPlayer entityplayer = (ServerPlayer) entity;
++
++ if (entityplayer.connection.isAcceptingMessages() && entityplayer.level() == this.level() && !entityplayer.isSleeping()) {
++ // 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());
++
++ PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
++ Bukkit.getPluginManager().callEvent(teleEvent);
++
++ if (!teleEvent.isCancelled() && entityplayer.connection.isAcceptingMessages()) {
++ if (this.random.nextFloat() < 0.05F && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
++ Endermite entityendermite = (Endermite) EntityType.ENDERMITE.create(this.level());
++
++ if (entityendermite != null) {
++ entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
++ this.level().addFreshEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL);
++ }
+ }
+- }
+
+- if (owner.isPassenger()) {
+- serverPlayer.dismountTo(this.getX(), this.getY(), this.getZ());
+- } else {
+- owner.teleportTo(this.getX(), this.getY(), this.getZ());
+- }
++ if (entity.isPassenger()) {
++ entity.stopRiding();
++ }
+
+- owner.resetFallDistance();
+- owner.hurt(this.damageSources().fall(), 5.0F);
+- this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_TELEPORT, SoundSource.PLAYERS);
++ entityplayer.connection.teleport(teleEvent.getTo());
++ entity.resetFallDistance();
++ CraftEventFactory.entityDamage = this;
++ entity.hurt(this.damageSources().fall(), 5.0F);
++ CraftEventFactory.entityDamage = null;
++ }
++ // CraftBukkit end
++ this.level().playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_TELEPORT, SoundSource.PLAYERS);
+ }
+- } else if (owner != null) {
+- owner.teleportTo(this.getX(), this.getY(), this.getZ());
+- owner.resetFallDistance();
++ } else if (entity != null) {
++ entity.teleportTo(this.getX(), this.getY(), this.getZ());
++ entity.resetFallDistance();
+ }
+
+ this.discard();
+ }
++
+ }
+
+ @Override
+ public void tick() {
+- Entity owner = this.getOwner();
+- if (owner instanceof ServerPlayer && !owner.isAlive() && this.level().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) {
++ Entity entity = this.getOwner();
++
++ if (entity instanceof ServerPlayer && !entity.isAlive() && this.level().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) {
+ this.discard();
+ } else {
+ super.tick();
+ }
++
+ }
+
+ @Nullable
+ @Override
+ public Entity changeDimension(ServerLevel server) {
+- Entity owner = this.getOwner();
+- if (owner != null && owner.level().dimension() != server.dimension()) {
+- this.setOwner(null);
++ Entity entity = this.getOwner();
++
++ if (entity != null && server != null && entity.level().dimension() != server.dimension()) { // CraftBukkit - SPIGOT-6113
++ this.setOwner((Entity) null);
+ }
+
+ return super.changeDimension(server);