mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2025-02-27 01:41:35 +01:00
Fix possible int-overflow on radius-update
This commit is contained in:
parent
2033d91497
commit
ef5e2c08aa
@ -100,13 +100,13 @@ private static List<Vector2i> getRegions(World world, Vector2i center, int radiu
|
||||
|
||||
Grid regionGrid = world.getRegionGrid();
|
||||
Vector2i halfCell = regionGrid.getGridSize().div(2);
|
||||
int increasedRadiusSquared = (int) Math.pow(radius + Math.ceil(halfCell.length()), 2);
|
||||
long increasedRadiusSquared = (long) Math.pow(radius + Math.ceil(halfCell.length()), 2);
|
||||
|
||||
for (Vector2i region : world.listRegions()) {
|
||||
Vector2i min = regionGrid.getCellMin(region);
|
||||
Vector2i regionCenter = min.add(halfCell);
|
||||
|
||||
if (regionCenter.distanceSquared(center) <= increasedRadiusSquared)
|
||||
if (regionCenter.toLong().distanceSquared(center.toLong()) <= increasedRadiusSquared)
|
||||
regions.add(region);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user