|
1 | 1 | package com.mamiyaotaru.voxelmap.persistent; |
2 | 2 |
|
3 | 3 | import com.mamiyaotaru.voxelmap.MapSettingsManager; |
| 4 | +import com.mamiyaotaru.voxelmap.NewerNewChunksManager; |
4 | 5 | import com.mamiyaotaru.voxelmap.RadarSettingsManager; |
5 | 6 | import com.mamiyaotaru.voxelmap.VoxelConstants; |
6 | 7 | import com.mamiyaotaru.voxelmap.WaypointManager; |
@@ -850,6 +851,7 @@ public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mo |
850 | 851 | } |
851 | 852 | } |
852 | 853 | drawExploredChunkLinesWorldMap(graphics, exploredLeftRegion, exploredRightRegion, exploredTopRegion, exploredBottomRegion); |
| 854 | + drawNewOldChunkOverlayWorldMap(graphics, exploredLeftRegion, exploredRightRegion, exploredTopRegion, exploredBottomRegion); |
853 | 855 |
|
854 | 856 | if (!farZoomPerformanceMode && mapOptions.worldBorder) { |
855 | 857 | WorldBorder worldBorder = minecraft.level.getWorldBorder(); |
@@ -1297,6 +1299,111 @@ private void drawExploredChunkLinesWorldMap(GuiGraphicsExtractor graphics, int l |
1297 | 1299 | } |
1298 | 1300 | } |
1299 | 1301 |
|
| 1302 | + private void drawNewOldChunkOverlayWorldMap(GuiGraphicsExtractor graphics, int leftRegion, int rightRegion, int topRegion, int bottomRegion) { |
| 1303 | + if (!options.showNewOldChunks || !radarOptions.showNewerNewChunks) { |
| 1304 | + return; |
| 1305 | + } |
| 1306 | + |
| 1307 | + int minChunkX = leftRegion * 16; |
| 1308 | + int maxChunkX = rightRegion * 16 + 15; |
| 1309 | + int minChunkZ = topRegion * 16; |
| 1310 | + int maxChunkZ = bottomRegion * 16 + 15; |
| 1311 | + int centerChunkX = (minChunkX + maxChunkX) >> 1; |
| 1312 | + int centerChunkZ = (minChunkZ + maxChunkZ) >> 1; |
| 1313 | + int radius = Math.max(maxChunkX - centerChunkX, maxChunkZ - centerChunkZ) + 2; |
| 1314 | + |
| 1315 | + boolean farZoomPerformanceMode = isFarZoomPerformanceMode(); |
| 1316 | + boolean mapInMotion = currentDragging |
| 1317 | + || Math.abs(this.deltaX) > 0.01F |
| 1318 | + || Math.abs(this.deltaY) > 0.01F |
| 1319 | + || this.zoom != this.zoomGoal; |
| 1320 | + |
| 1321 | + NewerNewChunksManager manager = VoxelConstants.getVoxelMapInstance().getNewerNewChunksManager(); |
| 1322 | + List<ChunkPos> oldChunks = new ArrayList<>(manager.getOldChunksInRange(centerChunkX, centerChunkZ, radius)); |
| 1323 | + List<ChunkPos> newChunks = new ArrayList<>(manager.getNewChunksInRange(centerChunkX, centerChunkZ, radius)); |
| 1324 | + |
| 1325 | + int oldAlpha = Mth.clamp((int) Math.round((radarOptions.newerNewChunksOldOpacity / 100.0D) * 255.0D), 0, 255); |
| 1326 | + int newAlpha = Mth.clamp((int) Math.round((radarOptions.newerNewChunksNewOpacity / 100.0D) * 255.0D), 0, 255); |
| 1327 | + if (oldAlpha <= 0 && newAlpha <= 0) { |
| 1328 | + return; |
| 1329 | + } |
| 1330 | + |
| 1331 | + int oldColor = (oldAlpha << 24) | (radarOptions.getNewerNewChunksOldColorRgb() & 0x00FFFFFF); |
| 1332 | + int newColor = (newAlpha << 24) | (radarOptions.getNewerNewChunksNewColorRgb() & 0x00FFFFFF); |
| 1333 | + |
| 1334 | + int cellChunkSize = 1; |
| 1335 | + if (this.mapToGui < 0.03F) { |
| 1336 | + cellChunkSize = mapInMotion ? 8 : 6; |
| 1337 | + } else if (this.mapToGui < 0.06F) { |
| 1338 | + cellChunkSize = mapInMotion ? 6 : 4; |
| 1339 | + } else if (this.mapToGui < 0.10F) { |
| 1340 | + cellChunkSize = mapInMotion ? 4 : 3; |
| 1341 | + } else if (this.mapToGui < 0.18F) { |
| 1342 | + cellChunkSize = mapInMotion ? 3 : 2; |
| 1343 | + } |
| 1344 | + |
| 1345 | + int maxDraw = Integer.MAX_VALUE; |
| 1346 | + if (farZoomPerformanceMode) { |
| 1347 | + maxDraw = mapInMotion ? 2200 : 4500; |
| 1348 | + } else if (this.mapToGui < 0.06F) { |
| 1349 | + maxDraw = mapInMotion ? 900 : 2000; |
| 1350 | + } else if (this.mapToGui < 0.10F) { |
| 1351 | + maxDraw = mapInMotion ? 1500 : 2800; |
| 1352 | + } |
| 1353 | + |
| 1354 | + int drawn = 0; |
| 1355 | + drawn = drawChunkSquaresWorldMap(graphics, oldChunks, minChunkX, maxChunkX, minChunkZ, maxChunkZ, oldColor, cellChunkSize, maxDraw, drawn); |
| 1356 | + drawChunkSquaresWorldMap(graphics, newChunks, minChunkX, maxChunkX, minChunkZ, maxChunkZ, newColor, cellChunkSize, maxDraw, drawn); |
| 1357 | + } |
| 1358 | + |
| 1359 | + private int drawChunkSquaresWorldMap(GuiGraphicsExtractor graphics, List<ChunkPos> chunks, int minChunkX, int maxChunkX, int minChunkZ, int maxChunkZ, int color, int cellChunkSize, int maxDraw, int startDrawn) { |
| 1360 | + int drawn = startDrawn; |
| 1361 | + if (cellChunkSize > 1) { |
| 1362 | + java.util.HashSet<Long> cells = new java.util.HashSet<>(); |
| 1363 | + for (ChunkPos chunk : chunks) { |
| 1364 | + int chunkX = chunk.x(); |
| 1365 | + int chunkZ = chunk.z(); |
| 1366 | + if (chunkX < minChunkX || chunkX > maxChunkX || chunkZ < minChunkZ || chunkZ > maxChunkZ) { |
| 1367 | + continue; |
| 1368 | + } |
| 1369 | + int cellX = Math.floorDiv(chunkX, cellChunkSize); |
| 1370 | + int cellZ = Math.floorDiv(chunkZ, cellChunkSize); |
| 1371 | + cells.add(chunkKey(cellX, cellZ)); |
| 1372 | + } |
| 1373 | + |
| 1374 | + float worldCellSize = 16.0F * cellChunkSize; |
| 1375 | + for (long key : cells) { |
| 1376 | + if (drawn >= maxDraw) { |
| 1377 | + break; |
| 1378 | + } |
| 1379 | + int cellX = (int) (key >> 32); |
| 1380 | + int cellZ = (int) key; |
| 1381 | + float minX = cellX * worldCellSize; |
| 1382 | + float minZ = cellZ * worldCellSize; |
| 1383 | + VoxelMapGuiGraphics.fillGradient(graphics, minX, minZ, minX + worldCellSize, minZ + worldCellSize, color, color, color, color); |
| 1384 | + drawn++; |
| 1385 | + } |
| 1386 | + return drawn; |
| 1387 | + } |
| 1388 | + |
| 1389 | + for (ChunkPos chunk : chunks) { |
| 1390 | + if (drawn >= maxDraw) { |
| 1391 | + break; |
| 1392 | + } |
| 1393 | + int chunkX = chunk.x(); |
| 1394 | + int chunkZ = chunk.z(); |
| 1395 | + if (chunkX < minChunkX || chunkX > maxChunkX || chunkZ < minChunkZ || chunkZ > maxChunkZ) { |
| 1396 | + continue; |
| 1397 | + } |
| 1398 | + |
| 1399 | + float minX = chunk.getMinBlockX(); |
| 1400 | + float minZ = chunk.getMinBlockZ(); |
| 1401 | + VoxelMapGuiGraphics.fillGradient(graphics, minX, minZ, minX + 16.0F, minZ + 16.0F, color, color, color, color); |
| 1402 | + drawn++; |
| 1403 | + } |
| 1404 | + return drawn; |
| 1405 | + } |
| 1406 | + |
1300 | 1407 | private long chunkKey(int x, int z) { |
1301 | 1408 | return (((long) x) << 32) ^ (z & 0xFFFFFFFFL); |
1302 | 1409 | } |
|
0 commit comments