2026-07-09 00:03:09 +08:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: MrHua269 <mrhua269@gmail.com>
|
|
|
|
|
Date: Wed, 8 Jul 2026 21:20:44 +0800
|
|
|
|
|
Subject: [PATCH] Fix riding statistics desync
|
|
|
|
|
|
|
|
|
|
Referred to: https://github.com/CraftCanvasMC/Canvas/commit/057175b0c10d5a4d1d9059fd9d077750c32633b2
|
|
|
|
|
|
|
|
|
|
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
2026-07-14 15:09:17 +08:00
|
|
|
index e66cfcaa92b90f6b0fd26fd3cec1a5cdbb025117..b08af3a31b80125d02a4f2ff85311d2f9fdcc0ae 100644
|
2026-07-09 00:03:09 +08:00
|
|
|
--- a/net/minecraft/server/level/ServerPlayer.java
|
|
|
|
|
+++ b/net/minecraft/server/level/ServerPlayer.java
|
|
|
|
|
@@ -2537,7 +2537,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- private void checkRidingStatistics(final double dx, final double dy, final double dz) {
|
2026-07-14 11:32:51 +08:00
|
|
|
+ public void checkRidingStatistics(final double dx, final double dy, final double dz) { // Shiroha - Fix riding statics desync - make public
|
2026-07-09 00:03:09 +08:00
|
|
|
if (this.isPassenger() && !didNotMove(dx, dy, dz)) {
|
|
|
|
|
int distance = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F);
|
|
|
|
|
Entity vehicle = this.getVehicle();
|
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
2026-07-14 15:09:17 +08:00
|
|
|
index bc26de6e58d9d315122c7f8721ab30490f382c18..7b8f88ed956b65bf7accfcfa57df4b51d8876ecd 100644
|
2026-07-09 00:03:09 +08:00
|
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
|
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
|
|
|
@@ -4199,7 +4199,13 @@ public abstract class Entity
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-14 11:32:51 +08:00
|
|
|
+ // Shiroha start - Fix riding statics desync
|
2026-07-09 00:03:09 +08:00
|
|
|
public void adjustRiders(boolean teleport) {
|
|
|
|
|
+ this.adjustRiders(teleport, false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void adjustRiders(boolean teleport, boolean syncStatics) {
|
2026-07-14 11:32:51 +08:00
|
|
|
+ // Shiroha end - Fix riding statics desync
|
2026-07-09 00:03:09 +08:00
|
|
|
java.util.ArrayDeque<EntityTreeNode> queue = new java.util.ArrayDeque<>();
|
|
|
|
|
queue.add(this);
|
|
|
|
|
|
|
|
|
|
@@ -4212,14 +4218,24 @@ public abstract class Entity
|
|
|
|
|
|
|
|
|
|
for (EntityTreeNode passenger : passengers) {
|
|
|
|
|
queue.add(passenger);
|
2026-07-14 11:32:51 +08:00
|
|
|
+ // Shiroha start - Fix riding statics desync
|
2026-07-09 00:03:09 +08:00
|
|
|
+ final double oldX = passenger.root.getX();
|
|
|
|
|
+ final double oldY = passenger.root.getY();
|
|
|
|
|
+ final double oldZ = passenger.root.getZ();
|
2026-07-14 11:32:51 +08:00
|
|
|
+ // Shiroha end - Fix riding statics desync
|
2026-07-09 00:03:09 +08:00
|
|
|
curr.root.positionRider(passenger.root, teleport ? Entity::snapTo : Entity::setPos);
|
2026-07-14 11:32:51 +08:00
|
|
|
+ // Shiroha start - Fix riding statics desync
|
2026-07-09 00:03:09 +08:00
|
|
|
+ if (syncStatics && passenger.root instanceof net.minecraft.server.level.ServerPlayer serverPlayer) {
|
|
|
|
|
+ serverPlayer.checkRidingStatistics(serverPlayer.getX() - oldX, serverPlayer.getY() - oldY, serverPlayer.getZ() - oldZ);
|
|
|
|
|
+ }
|
2026-07-14 11:32:51 +08:00
|
|
|
+ // Shiroha end - Fix riding statics desync
|
2026-07-09 00:03:09 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void repositionAllPassengers(boolean teleport) {
|
|
|
|
|
- this.makePassengerTree().adjustRiders(teleport);
|
2026-07-14 11:32:51 +08:00
|
|
|
+ this.makePassengerTree().adjustRiders(teleport, true); // Shiroha - Fix riding statics desync
|
2026-07-09 00:03:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected EntityTreeNode makePassengerTree() {
|