Refactoring and commenting

This commit is contained in:
James Seibel
2021-08-07 23:31:40 -05:00
parent d68e46a2d0
commit 9a58800499
2 changed files with 14 additions and 7 deletions
@@ -31,6 +31,7 @@ import java.util.concurrent.Executors;
import com.seibel.lod.objects.LodQuadTree;
import com.seibel.lod.objects.LodQuadTreeDimension;
import com.seibel.lod.objects.LodQuadTreeNode;
import com.seibel.lod.objects.RegionPos;
import com.seibel.lod.proxy.ClientProxy;
/**
@@ -98,9 +99,11 @@ public class LodQuadTreeDimensionFileHandler {
* Return the LodQuadTree region at the given coordinates.
* (null if the file doesn't exist)
*/
public LodQuadTree loadRegionFromFile(int regionX, int regionZ)
public LodQuadTree loadRegionFromFile(RegionPos regionPos)
{
int regionX = regionPos.x;
int regionZ = regionPos.z;
String fileName = getFileNameAndPathForRegion(regionX, regionZ);
File f = new File(fileName);
@@ -264,7 +264,7 @@ public class LodQuadTreeDimension
if (regions[xIndex][zIndex] == null)
{
regions[xIndex][zIndex] = getRegionFromFile(regionPos.x, regionPos.z);
regions[xIndex][zIndex] = getRegionFromFile(regionPos);
if (regions[xIndex][zIndex] == null)
{
regions[xIndex][zIndex] = new LodQuadTree(regionPos);
@@ -433,7 +433,8 @@ public class LodQuadTreeDimension
* method to get all the quadtree levels that have to be generated based on the position of the player
* @return list of quadTrees
*/
public List<LodQuadTreeNode> getNodesToGenerate(BlockPos playerPos, byte level, DistanceGenerationMode complexity, int maxDistance, int minDistance)
public List<LodQuadTreeNode> getNodesToGenerate(BlockPos playerPos, byte level, DistanceGenerationMode complexity,
int maxDistance, int minDistance)
{
int regionX;
int regionZ;
@@ -461,7 +462,8 @@ public class LodQuadTreeDimension
}
}
Collections.sort(listOfQuadTree,Map.Entry.comparingByValue());
// TODO why are we sorting the list?
Collections.sort(listOfQuadTree, Map.Entry.comparingByValue());
return listOfQuadTree.stream().map(entry -> entry.getKey()).collect(Collectors.toList());
}
@@ -485,12 +487,14 @@ public class LodQuadTreeDimension
zIndex = (zRegion + center.z) - halfWidth;
region = getRegion(new RegionPos(xIndex,zIndex));
// Recursively add any children
if (region != null)
{
listOfNodes.addAll(region.getNodeListWithMask(complexityMask, getOnlyDirty, getOnlyLeaf));
}
}
}
return listOfNodes;
}
@@ -498,10 +502,10 @@ public class LodQuadTreeDimension
* Get the region at the given X and Z coordinates from the
* RegionFileHandler.
*/
public LodQuadTree getRegionFromFile(int regionX, int regionZ)
public LodQuadTree getRegionFromFile(RegionPos regionPos)
{
if (fileHandler != null)
return fileHandler.loadRegionFromFile(regionX, regionZ);
return fileHandler.loadRegionFromFile(regionPos);
else
return null;
}