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-08-08 11:46:48 +08:00
|
|
|
index 297269e18111b93692bdfbc318de6e9e38c18d50..c29167dee1855b142c78d9ae8700b25d97301f12 100644
|
2026-07-09 00:03:09 +08:00
|
|
|
--- a/net/minecraft/server/level/ServerPlayer.java
|
|
|
|
|
+++ b/net/minecraft/server/level/ServerPlayer.java
|
2026-07-27 20:47:44 +08:00
|
|
|
@@ -2516,7 +2516,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
2026-07-09 00:03:09 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- 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-08-08 11:46:48 +08:00
|
|
|
index f2f3e8474b8f251f4d05bba93784c42f3fd173a3..2a6854c4c3ca35807723853128edf16024abbeb7 100644
|
2026-07-09 00:03:09 +08:00
|
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
|
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
2026-08-08 11:46:48 +08:00
|
|
|
@@ -4195,7 +4195,13 @@ public abstract class Entity
|
2026-07-09 00:03:09 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
|
2026-08-08 11:46:48 +08:00
|
|
|
@@ -4208,14 +4214,24 @@ public abstract class Entity
|
2026-07-09 00:03:09 +08:00
|
|
|
|
|
|
|
|
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() {
|