2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
|
|
Date: Tue, 11 Feb 2020 21:56:48 -0600
|
2024-01-19 22:13:42 +01:00
|
|
|
Subject: [PATCH] Add EntityMoveEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2024-02-01 10:15:57 +01:00
|
|
|
index 06b7816bafa3ac1093b796ca6e7bb3462df8bfec..3f061e1135bac08e6ea1530407ff2667904339a5 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2024-01-25 10:54:46 +01:00
|
|
|
@@ -1526,6 +1526,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
2021-06-11 14:02:28 +02:00
|
|
|
while (iterator.hasNext()) {
|
|
|
|
ServerLevel worldserver = (ServerLevel) iterator.next();
|
2024-02-01 10:15:57 +01:00
|
|
|
worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
|
2024-01-19 22:13:42 +01:00
|
|
|
+ worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
this.profiler.push(() -> {
|
2023-03-14 21:25:13 +01:00
|
|
|
return worldserver + " " + worldserver.dimension().location();
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
index a2113c01d8ea3da13efbf4f0b23460e7fa4e8c68..125e3425af05541e5c848ee0e9390cea44a29302 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
2024-01-23 15:43:48 +01:00
|
|
|
@@ -222,6 +222,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
2021-06-11 14:02:28 +02:00
|
|
|
public final LevelStorageSource.LevelStorageAccess convertable;
|
|
|
|
public final UUID uuid;
|
2024-01-23 14:34:17 +01:00
|
|
|
public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent
|
2024-01-21 17:39:05 +01:00
|
|
|
+ public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent
|
|
|
|
|
2024-01-23 14:34:17 +01:00
|
|
|
public LevelChunk getChunkIfLoaded(int x, int z) {
|
2024-01-21 17:39:05 +01:00
|
|
|
return this.chunkSource.getChunk(x, z, false);
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
index 87fb0fe5579ba09534e379d34b134c868e838143..26ac98e0dbcac5d20a013cc1b8f5d70133e23154 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -3382,6 +3382,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
this.pushEntities();
|
2023-06-08 02:54:54 +02:00
|
|
|
this.level().getProfiler().pop();
|
2024-01-19 22:13:42 +01:00
|
|
|
+ // Paper start - Add EntityMoveEvent
|
2023-06-08 02:54:54 +02:00
|
|
|
+ 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);
|
2024-02-01 10:15:57 +01:00
|
|
|
+ Location to = new Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
|
2021-06-14 21:58:32 +02:00
|
|
|
+ io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone());
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (!event.callEvent()) {
|
2023-06-08 02:54:54 +02:00
|
|
|
+ this.absMoveTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch());
|
2021-06-11 14:02:28 +02:00
|
|
|
+ } else if (!to.equals(event.getTo())) {
|
2023-06-08 02:54:54 +02:00
|
|
|
+ this.absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2024-01-19 22:13:42 +01:00
|
|
|
+ // Paper end - Add EntityMoveEvent
|
2023-06-08 02:54:54 +02:00
|
|
|
if (!this.level().isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) {
|
2023-03-14 21:25:13 +01:00
|
|
|
this.hurt(this.damageSources().drown(), 1.0F);
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|