add isChunkPosInLoadedArea to LodUtil

This commit is contained in:
James Seibel
2021-07-01 21:10:07 -05:00
parent 5c369fd515
commit 39c7ae8d17
@@ -5,6 +5,7 @@ import com.seibel.lod.enums.LodTemplate;
import com.seibel.lod.handlers.LodConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.ChunkPos;
/**
* This holds miscellaneous helper code
@@ -17,6 +18,22 @@ public class RenderUtil
{
private static final Minecraft mc = Minecraft.getInstance();
/**
* Returns if the given ChunkPos is in the loaded area of the world.
* @param centerCoordinate the center of the loaded world (probably the player's ChunkPos)
*/
public static boolean isChunkPosInLoadedArea(ChunkPos pos, ChunkPos center)
{
Minecraft mc = Minecraft.getInstance();
return (pos.x >= center.x - mc.gameSettings.renderDistanceChunks
&& pos.x <= center.x + mc.gameSettings.renderDistanceChunks)
&&
(pos.z >= center.z - mc.gameSettings.renderDistanceChunks
&& pos.z <= center.z + mc.gameSettings.renderDistanceChunks);
}
/**
* Returns if the given coordinate is in the loaded area of the world.
* @param centerCoordinate the center of the loaded world