mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 10:49:07 +00:00
Fix Rendering Glitches
This commit is contained in:
1 parent
08728efcdd
commit
abc34b3f6f
7 files changed
+71
-42
No files matched your search
@@ -801,19 +801,21 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
|
||||
/**
|
||||
* Handle client-side position interpolation.
|
||||
* Only moves position during active interpolation (interpSteps > 0).
|
||||
* Does NOT predict/drift between server updates — the motion values are
|
||||
* derived from correction deltas, not actual entity velocity, so applying
|
||||
* them between updates causes entities to fly off in wrong directions.
|
||||
* This matches vanilla Minecraft behavior for non-player entities.
|
||||
*/
|
||||
protected void handleClientInterpolation() {
|
||||
if (this.interpSteps > 0) {
|
||||
// For very slow / stationary projectiles, snap directly to avoid jitter
|
||||
double dx = this.interpTargetX - this.posX;
|
||||
double dy = this.interpTargetY - this.posY;
|
||||
double dz = this.interpTargetZ - this.posZ;
|
||||
double distSq = dx * dx + dy * dy + dz * dz;
|
||||
if (distSq < 0.04) {
|
||||
|
||||
if (distSq < 0.0001) {
|
||||
this.setPosition(this.interpTargetX, this.interpTargetY, this.interpTargetZ);
|
||||
this.motionX = this.interpTargetMotionX;
|
||||
this.motionY = this.interpTargetMotionY;
|
||||
this.motionZ = this.interpTargetMotionZ;
|
||||
this.interpSteps = 0;
|
||||
return;
|
||||
}
|
||||
@@ -828,16 +830,6 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
|
||||
this.setPosition(newX, newY, newZ);
|
||||
this.interpSteps--;
|
||||
} else {
|
||||
// Skip motion application for nearly-stationary projectiles to prevent drift
|
||||
double speedSq = this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ;
|
||||
if (speedSq < 0.0001) {
|
||||
return;
|
||||
}
|
||||
this.posX += this.motionX;
|
||||
this.posY += this.motionY;
|
||||
this.posZ += this.motionZ;
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1542,9 +1534,7 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
protected void setChargeOrigin(Vec3 pos) {
|
||||
if (pos == null) return;
|
||||
this.setPosition(pos.xCoord, pos.yCoord, pos.zCoord);
|
||||
this.prevPosX = pos.xCoord;
|
||||
this.prevPosY = pos.yCoord;
|
||||
this.prevPosZ = pos.zCoord;
|
||||
syncPositionState(pos.xCoord, pos.yCoord, pos.zCoord, true);
|
||||
this.startX = pos.xCoord;
|
||||
this.startY = pos.yCoord;
|
||||
this.startZ = pos.zCoord;
|
||||
|
||||
Reference in new issue
Block a user