mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 01:05:12 +00:00
Fix mount movement jitter by following vanilla horse/boat sync pattern
- Remove all velocityChanged=true flags from mount movement code (NPCMountUtil, EntityNPCInterface, EntityNPCFlying) - Make performMountedMovement physics server-side only like vanilla horse - Remove syncMountedRiderVelocity method that forced rider velocity packets - Fix ground movement to not reset motionY every tick - Let Minecraft's entity tracker handle position sync naturally The jitter was caused by S12PacketEntityVelocity being sent every tick, which constantly reset client interpolation. Vanilla horses/boats never set velocityChanged and rely on the entity tracker for smooth sync.
This commit is contained in:
3 files changed
+11
-96
No files matched your search
@@ -2130,35 +2130,21 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
this.moveForward = forward;
|
||||
|
||||
boolean flightMode = isMountFlightModeActive();
|
||||
double prevMotionX = this.motionX;
|
||||
double prevMotionY = this.motionY;
|
||||
double prevMotionZ = this.motionZ;
|
||||
float previousJumpFactor = this.jumpMovementFactor;
|
||||
float appliedJumpFactor = getMountedAirStrafeFactor(moveSpeed, flightMode);
|
||||
|
||||
this.jumpMovementFactor = appliedJumpFactor;
|
||||
|
||||
this.setAIMoveSpeed(moveSpeed);
|
||||
|
||||
super.moveEntityWithHeading(strafe, forward);
|
||||
|
||||
if (flightMode) {
|
||||
this.motionY = prevMotionY;
|
||||
this.isAirBorne = true;
|
||||
}
|
||||
|
||||
this.jumpMovementFactor = previousJumpFactor;
|
||||
|
||||
// Server-side only physics (like vanilla horse)
|
||||
if (!worldObj.isRemote) {
|
||||
double newMotionX = this.motionX;
|
||||
double newMotionY = this.motionY;
|
||||
double newMotionZ = this.motionZ;
|
||||
if (Math.abs(newMotionX - prevMotionX) > 1.0E-5D || Math.abs(newMotionY - prevMotionY) > 1.0E-5D || Math.abs(newMotionZ - prevMotionZ) > 1.0E-5D) {
|
||||
this.velocityChanged = true;
|
||||
this.jumpMovementFactor = getMountedAirStrafeFactor(moveSpeed, flightMode);
|
||||
this.setAIMoveSpeed(moveSpeed);
|
||||
super.moveEntityWithHeading(strafe, forward);
|
||||
|
||||
if (flightMode) {
|
||||
this.motionY = prevMotionY;
|
||||
this.isAirBorne = true;
|
||||
}
|
||||
}
|
||||
|
||||
syncMountedRiderVelocity();
|
||||
// Both sides do animation (like vanilla horse)
|
||||
updateMountedLimbSwing();
|
||||
}
|
||||
|
||||
@@ -2176,28 +2162,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
return moveSpeed * 0.5F;
|
||||
}
|
||||
|
||||
private void syncMountedRiderVelocity() {
|
||||
if (!(this.riddenByEntity instanceof EntityLivingBase)) {
|
||||
return;
|
||||
}
|
||||
EntityLivingBase rider = (EntityLivingBase) this.riddenByEntity;
|
||||
double riderPrevMotionX = rider.motionX;
|
||||
double riderPrevMotionY = rider.motionY;
|
||||
double riderPrevMotionZ = rider.motionZ;
|
||||
|
||||
rider.motionX = this.motionX;
|
||||
rider.motionY = this.motionY;
|
||||
rider.motionZ = this.motionZ;
|
||||
rider.fallDistance = 0.0F;
|
||||
rider.isAirBorne = !this.onGround;
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
if (Math.abs(rider.motionX - riderPrevMotionX) > 1.0E-5D || Math.abs(rider.motionY - riderPrevMotionY) > 1.0E-5D || Math.abs(rider.motionZ - riderPrevMotionZ) > 1.0E-5D) {
|
||||
rider.velocityChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMountedLimbSwing() {
|
||||
this.prevLimbSwingAmount = this.limbSwingAmount;
|
||||
double deltaX = this.posX - this.prevPosX;
|
||||
|
||||
Reference in new issue
Block a user