Use more correct distance function for real-time updates

This commit is contained in:
s809
2024-09-29 22:24:38 +05:00
parent db524efba0
commit 7f0c42396b
2 changed files with 9 additions and 1 deletions
@@ -426,7 +426,7 @@ public abstract class AbstractDhServerLevel extends AbstractDhLevel implements I
}
Vec3d playerPosition = serverPlayerState.getServerPlayer().getPosition();
int distanceFromPlayer = DhSectionPos.getManhattanBlockDistance(data.getPos(), new DhBlockPos2D((int) playerPosition.x, (int) playerPosition.z)) / 16;
int distanceFromPlayer = DhSectionPos.getChebyshevBlockDistance(data.getPos(), new DhBlockPos2D((int) playerPosition.x, (int) playerPosition.z)) / 16;
if (distanceFromPlayer >= serverPlayerState.getServerPlayer().getViewDistance()
&& distanceFromPlayer <= serverPlayerState.sessionConfig.getRenderDistanceRadius())
{
@@ -261,6 +261,14 @@ public class DhSectionPos
+ Math.abs(getCenterBlockPosZ(pos) - blockPos.z);
}
public static int getChebyshevBlockDistance(long pos, DhBlockPos2D blockPos)
{
return Math.max(
Math.abs(getCenterBlockPosX(pos) - blockPos.x),
Math.abs(getCenterBlockPosZ(pos) - blockPos.z)
);
}
//==================//