mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 08:57:44 +01:00
Optimize EntityMoveEvent detection
This commit is contained in:
@@ -5,7 +5,7 @@ Subject: [PATCH] EntityMoveEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
index 27e6d39a2..5228a11a5 100644
|
||||
index 27e6d39a2f..15d255180f 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
@@ -2802,6 +2802,20 @@ public abstract class EntityLiving extends Entity {
|
||||
@@ -13,7 +13,7 @@ index 27e6d39a2..5228a11a5 100644
|
||||
this.collideNearby();
|
||||
this.world.getMethodProfiler().exit();
|
||||
+ // Purpur start
|
||||
+ if (net.pl3x.purpur.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
+ if (((WorldServer) world).hasEntityMoveEvent) {
|
||||
+ if (lastX != locX() || lastY != locY() || lastZ != locZ() || lastYaw != yaw || lastPitch != pitch) {
|
||||
+ Location from = new Location(world.getWorld(), lastX, lastY, lastZ, lastYaw, lastPitch);
|
||||
+ Location to = new Location (world.getWorld(), locX(), locY(), locZ(), yaw, pitch);
|
||||
@@ -29,3 +29,27 @@ index 27e6d39a2..5228a11a5 100644
|
||||
if (!this.world.isClientSide && this.dO() && this.aG()) {
|
||||
this.damageEntity(DamageSource.DROWN, 1.0F);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index dae7888866..2c765ed56b 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1401,6 +1401,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
while (iterator.hasNext()) {
|
||||
WorldServer worldserver = (WorldServer) iterator.next();
|
||||
worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper
|
||||
+ worldserver.hasEntityMoveEvent = net.pl3x.purpur.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Purpur
|
||||
TileEntityHopper.skipHopperEvents = worldserver.paperConfig.disableHopperMoveEvents || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper
|
||||
|
||||
this.methodProfiler.a(() -> {
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index e082faf8cf..63b6a06737 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -101,6 +101,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
||||
public final Convertable.ConversionSession convertable;
|
||||
public final UUID uuid;
|
||||
boolean hasPhysicsEvent = true; // Paper
|
||||
+ boolean hasEntityMoveEvent = false; // Purpur
|
||||
private static Throwable getAddToWorldStackTrace(Entity entity) {
|
||||
return new Throwable(entity + " Added to world at " + new java.util.Date());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user