aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0495-Add-EntityMoveEvent.patch
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2024-05-29 13:58:57 -0700
committerGitHub <[email protected]>2024-05-29 22:58:57 +0200
commita31dc90741ed9c121a13a3c124c9ebf5bafd0da7 (patch)
tree81963bd94fe7772ee08bd21710230de21b6b25da /patches/server/0495-Add-EntityMoveEvent.patch
parented85aac53cfd93d29fa24e6071dbdddd0e49624b (diff)
downloadPaper-a31dc90741ed9c121a13a3c124c9ebf5bafd0da7.tar.gz
Paper-a31dc90741ed9c121a13a3c124c9ebf5bafd0da7.zip
Several fixes and new api for experience merging/stacking (#9242)
Diffstat (limited to 'patches/server/0495-Add-EntityMoveEvent.patch')
-rw-r--r--patches/server/0495-Add-EntityMoveEvent.patch55
1 files changed, 55 insertions, 0 deletions
diff --git a/patches/server/0495-Add-EntityMoveEvent.patch b/patches/server/0495-Add-EntityMoveEvent.patch
new file mode 100644
index 0000000000..222311818a
--- /dev/null
+++ b/patches/server/0495-Add-EntityMoveEvent.patch
@@ -0,0 +1,55 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: William Blake Galbreath <[email protected]>
+Date: Tue, 11 Feb 2020 21:56:48 -0600
+Subject: [PATCH] Add EntityMoveEvent
+
+
+diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
+index d86f01599b02626c72ad0b8da0b6b9d741f8c894..a9851d2c6d89e30f40da35586ac3dddfa72ba421 100644
+--- a/src/main/java/net/minecraft/server/MinecraftServer.java
++++ b/src/main/java/net/minecraft/server/MinecraftServer.java
+@@ -1580,6 +1580,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
+ while (iterator.hasNext()) {
+ ServerLevel worldserver = (ServerLevel) iterator.next();
+ worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
++ worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
+
+ this.profiler.push(() -> {
+ String s = String.valueOf(worldserver);
+diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
+index a9a39c99874001f1024f71bfc97130e8c9a507e7..19333b61bcb50f2171ac2c75d7f4ca4fdf4d4743 100644
+--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
+@@ -227,6 +227,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
+ public final LevelStorageSource.LevelStorageAccess convertable;
+ public final UUID uuid;
+ public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent
++ public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent
+
+ public LevelChunk getChunkIfLoaded(int x, int z) {
+ return this.chunkSource.getChunk(x, z, false);
+diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+index 70f34d741eeafd54fcd2f5aaf9d059ba0f96e60a..533b020ab103bf353be21ccc95954f8e827a89c6 100644
+--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+@@ -3477,6 +3477,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
+
+ this.pushEntities();
+ this.level().getProfiler().pop();
++ // Paper start - Add EntityMoveEvent
++ if (((ServerLevel) this.level()).hasEntityMoveEvent && !(this instanceof net.minecraft.world.entity.player.Player)) {
++ if (this.xo != this.getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) {
++ Location from = new Location(this.level().getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO);
++ Location to = new Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
++ io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone());
++ if (!event.callEvent()) {
++ this.absMoveTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch());
++ } else if (!to.equals(event.getTo())) {
++ this.absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
++ }
++ }
++ }
++ // Paper end - Add EntityMoveEvent
+ if (!this.level().isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) {
+ this.hurt(this.damageSources().drown(), 1.0F);
+ }