Use more correct distance function for real-time updates
This commit is contained in:
@@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================//
|
||||
|
||||
Reference in New Issue
Block a user