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-06-13 01:51:45 +02:00
|
|
|
index d29b66d9db69309087ee2eac2561ab2fcd797eb8..5ac0773a375d833f141f1a1754ca8a0661a0499b 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
|
2023-06-13 01:51:45 +02:00
|
|
|
@@ -1504,6 +1504,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
|
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
|
2023-06-09 06:29:58 +02:00
|
|
|
index fb256e7c60f4e82b028f6768f591098882e27dd1..cfd0e75ac4e7edbd219cc0f5fb802e37737cc4ba 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
|
2023-06-08 02:54:54 +02:00
|
|
|
@@ -220,6 +220,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-06-12 19:03:51 +02:00
|
|
|
index 77fe0eaadaf7c79b441d1f5ca3bc0da01261ebba..1efe051326b83354c4e72c1d25054f27f1f84cf1 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
|
2023-06-12 19:03:51 +02:00
|
|
|
@@ -3343,6 +3343,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();
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper start
|
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);
|
|
|
|
+ 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
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
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
|
|
|
}
|