diff options
author | Nassim Jahnke <[email protected]> | 2024-01-23 18:01:39 +0100 |
---|---|---|
committer | Nassim Jahnke <[email protected]> | 2024-01-23 18:06:51 +0100 |
commit | c57d1aa24560ec71331e685e9fd27aa3d9274f69 (patch) | |
tree | b585b2246be85ecc5047b02b704c0a5f59c96dd9 /patches/server/0511-Add-EntityMoveEvent.patch | |
parent | e66037960b02c7b22bbed75318904c55a4177977 (diff) | |
download | Paper-c57d1aa24560ec71331e685e9fd27aa3d9274f69.tar.gz Paper-c57d1aa24560ec71331e685e9fd27aa3d9274f69.zip |
Move diffs around to compile without later ones applied
Diffstat (limited to 'patches/server/0511-Add-EntityMoveEvent.patch')
-rw-r--r-- | patches/server/0511-Add-EntityMoveEvent.patch | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/patches/server/0511-Add-EntityMoveEvent.patch b/patches/server/0511-Add-EntityMoveEvent.patch new file mode 100644 index 0000000000..201613e609 --- /dev/null +++ b/patches/server/0511-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 1aa73c3934c754fb9a4e09e8ac9c7f96d608ceb5..849161e11d547445d9bd10ac54bcd994a62aab06 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -1529,6 +1529,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(() -> { + return worldserver + " " + worldserver.dimension().location(); +diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java +index 5020d671c7bbaf4277c300f3688c770b6a565129..f69fae303770b3ccace8e7d421b762504a7cb5dc 100644 +--- a/src/main/java/net/minecraft/server/level/ServerLevel.java ++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +@@ -222,6 +222,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 95ee76c0e96318866a7b21355c9617c2ca79776e..bcd1a608796065eb705363bdc246151b68553c0e 100644 +--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java ++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +@@ -3361,6 +3361,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); + } |