mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
fa9c5e0f95
Previously, Entity Activation Range only applied to the root entity of a vehicle chain. If that vehicle is active, every entity as it's passenger would then tick. This creates scenarios where EAR does not apply your desired ranges to passengers. Additionally, any entity that was a passenger never had its inactiveTick method called when the parent was inactive, creating behavioral desyncs. This could of been a source of many villager issues when those villagers were in minecarts as players commonly do. Now we will process passengers checking their activation state independently of their vehicle and if they are inactive, call their inactiveTick() method to ensure state remains consistent. This also helps improve any desync issues with entity position of passengers too. This also removes immunity for passenger/vehicles, so it should improve performance of these minecart villagers too for EAR.
58 lines
3.8 KiB
Diff
58 lines
3.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Tue, 25 Aug 2020 20:45:36 -0400
|
|
Subject: [PATCH] Fix Entity Teleportation and cancel velocity if teleported
|
|
|
|
Uses correct setPositionRotation for Entity teleporting instead of setLocation
|
|
as this is how Vanilla teleports entities.
|
|
|
|
Cancel any pending motion when teleported.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index 013ae4264eae85eb967839e005acb0d3c343b7c8..50f9df315d91446b78efaa9bb76719213427a563 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -1315,6 +1315,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
}
|
|
|
|
public void setPositionRotation(double d0, double d1, double d2, float f, float f1) {
|
|
+ this.mot = new Vec3D(0, 0, 0); // Paper - cancel entity velocity if teleported
|
|
this.g(d0, d1, d2);
|
|
this.yaw = f;
|
|
this.pitch = f1;
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
index 3aa56d5246660aa49fa881f0b3c80c986cb4a27f..b067f3b7031509bb94e617785e5a4d19b9d5d3e1 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -501,7 +501,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
|
public void a(PacketPlayInTeleportAccept packetplayinteleportaccept) {
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinteleportaccept, this, this.player.getWorldServer());
|
|
if (packetplayinteleportaccept.b() == this.teleportAwait && this.teleportPos != null) { // CraftBukkit
|
|
- this.player.setLocation(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch);
|
|
+ this.player.setPositionRotation(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); // Paper - use proper setPositionRotation for teleportation
|
|
this.o = this.teleportPos.x;
|
|
this.p = this.teleportPos.y;
|
|
this.q = this.teleportPos.z;
|
|
@@ -1302,7 +1302,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
|
// CraftBukkit end
|
|
|
|
this.A = this.e;
|
|
- this.player.setLocation(d0, d1, d2, f, f1);
|
|
+ this.player.setPositionRotation(d0, d1, d2, f, f1); // Paper - use proper setPositionRotation for teleportation
|
|
this.player.forceCheckHighPriority(); // Paper
|
|
this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.teleportAwait));
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
index b1fdc5737d332c6210d57793468da1eda8f8b9d2..6ceb2d50c59b63a337364605f8a5280d905f2662 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -547,7 +547,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
}
|
|
|
|
// entity.setLocation() throws no event, and so cannot be cancelled
|
|
- entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
|
+ entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); // Paper - use proper setPosition, as per vanilla teleporting
|
|
// SPIGOT-619: Force sync head rotation also
|
|
entity.setHeadRotation(location.getYaw());
|
|
((net.minecraft.server.WorldServer) entity.world).chunkCheck(entity); // Spigot - register to new chunk
|