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
|
|
|
|
Subject: [PATCH] EntityMoveEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2023-02-28 17:36:01 +01:00
|
|
|
index 04137173ca7034b9dff37a68518e8b6fb0330188..cd9022186351fa398bb8ab590ee8108b8ff1c9d3 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
|
2022-12-07 21:16:54 +01:00
|
|
|
@@ -1496,6 +1496,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
2021-06-11 14:02:28 +02:00
|
|
|
while (iterator.hasNext()) {
|
|
|
|
ServerLevel worldserver = (ServerLevel) iterator.next();
|
|
|
|
worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper
|
2021-06-14 21:58:32 +02:00
|
|
|
+ worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper
|
2022-06-09 10:51:45 +02:00
|
|
|
net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
this.profiler.push(() -> {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
2023-03-14 18:11:24 +01:00
|
|
|
index e6f931b8443a539441d9f918909e8244c853e43e..9945e53fdcbc057623ed35ec1dd3d6181017bf32 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
|
2022-12-19 11:46:55 +01:00
|
|
|
@@ -219,6 +219,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;
|
|
|
|
public boolean hasPhysicsEvent = true; // Paper
|
|
|
|
+ public boolean hasEntityMoveEvent = false; // Paper
|
2021-06-14 21:58:32 +02:00
|
|
|
public static Throwable getAddToWorldStackTrace(Entity entity) {
|
2022-10-19 04:21:07 +02:00
|
|
|
final Throwable thr = new Throwable(entity + " Added to world at " + new java.util.Date());
|
|
|
|
io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(thr);
|
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
|
2023-03-14 18:11:24 +01:00
|
|
|
index 128b4ce85bc8f79a1291d087fdb24e5a083f9464..82da840ed901d922665feff643ef2e364f3fa353 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
|
2022-12-07 21:16:54 +01:00
|
|
|
@@ -3327,6 +3327,20 @@ public abstract class LivingEntity extends Entity {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
this.pushEntities();
|
|
|
|
this.level.getProfiler().pop();
|
|
|
|
+ // Paper start
|
2021-08-15 19:37:42 +02:00
|
|
|
+ if (((ServerLevel) this.level).hasEntityMoveEvent && !(this instanceof net.minecraft.world.entity.player.Player)) {
|
2021-06-14 21:58:32 +02:00
|
|
|
+ if (this.xo != 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());
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (!event.callEvent()) {
|
|
|
|
+ absMoveTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch());
|
|
|
|
+ } else if (!to.equals(event.getTo())) {
|
|
|
|
+ absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
if (!this.level.isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) {
|
|
|
|
this.hurt(DamageSource.DROWN, 1.0F);
|
|
|
|
}
|