|
33 | 33 | import dev.xpple.seedmapper.thread.SeedMapExecutor; |
34 | 34 | import dev.xpple.seedmapper.util.NativeAccess; |
35 | 35 | import dev.xpple.seedmapper.util.QuartPos2; |
| 36 | +import dev.xpple.seedmapper.util.QuartPos2f; |
36 | 37 | import dev.xpple.seedmapper.util.RegionPos; |
37 | 38 | import dev.xpple.seedmapper.util.TwoDTree; |
38 | 39 | import dev.xpple.seedmapper.util.WorldIdentifier; |
@@ -224,7 +225,7 @@ private static int scaleToPixels(int quartOffset) { |
224 | 225 |
|
225 | 226 | private final BlockPos playerPos; |
226 | 227 |
|
227 | | - private QuartPos2 centerQuart; |
| 228 | + private QuartPos2f centerQuart; |
228 | 229 |
|
229 | 230 | private int centerX; |
230 | 231 | private int centerY; |
@@ -323,8 +324,8 @@ public SeedMapScreen(long seed, int dimension, int version, BlockPos playerPos) |
323 | 324 |
|
324 | 325 | this.playerPos = playerPos; |
325 | 326 |
|
326 | | - this.centerQuart = QuartPos2.fromBlockPos(playerPos); |
327 | | - this.mouseQuart = new QuartPos2(this.centerQuart.x(), this.centerQuart.z()); |
| 327 | + this.centerQuart = QuartPos2f.fromQuartPos(QuartPos2.fromBlockPos(this.playerPos)); |
| 328 | + this.mouseQuart = QuartPos2.fromQuartPos2f(this.centerQuart); |
328 | 329 | } |
329 | 330 |
|
330 | 331 | @Override |
@@ -359,7 +360,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia |
359 | 360 | int horTileRadius = Math.ceilDiv(this.seedMapWidth, tileSizePixels) + 1; |
360 | 361 | int verTileRadius = Math.ceilDiv(this.seedMapHeight, tileSizePixels) + 1; |
361 | 362 |
|
362 | | - TilePos centerTile = TilePos.fromQuartPos(this.centerQuart); |
| 363 | + TilePos centerTile = TilePos.fromQuartPos(QuartPos2.fromQuartPos2f(this.centerQuart)); |
363 | 364 | for (int relTileX = -horTileRadius; relTileX <= horTileRadius; relTileX++) { |
364 | 365 | for (int relTileZ = -verTileRadius; relTileZ <= verTileRadius; relTileZ++) { |
365 | 366 | TilePos tilePos = centerTile.add(relTileX, relTileZ); |
@@ -397,7 +398,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia |
397 | 398 | return; |
398 | 399 | } |
399 | 400 | int regionSize = StructureConfig.regionSize(structureConfig); |
400 | | - RegionPos centerRegion = RegionPos.fromQuartPos(this.centerQuart, regionSize); |
| 401 | + RegionPos centerRegion = RegionPos.fromQuartPos(QuartPos2.fromQuartPos2f(this.centerQuart), regionSize); |
401 | 402 | int horRegionRadius = Math.ceilDiv(horChunkRadius, regionSize); |
402 | 403 | int verRegionRadius = Math.ceilDiv(verChunkRadius, regionSize); |
403 | 404 | StructureChecks.GenerationCheck generationCheck = StructureChecks.getGenerationCheck(structure); |
@@ -493,8 +494,9 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia |
493 | 494 | } |
494 | 495 |
|
495 | 496 | // draw player position |
496 | | - int playerMinX = this.centerX + scaleToPixels(QuartPos.fromBlock(this.playerPos.getX()) - this.centerQuart.x()) - 10; |
497 | | - int playerMinY = this.centerY + scaleToPixels(QuartPos.fromBlock(this.playerPos.getZ()) - this.centerQuart.z()) - 10; |
| 497 | + QuartPos2f relPlayerQuart = QuartPos2f.fromQuartPos(QuartPos2.fromBlockPos(this.playerPos)).subtract(this.centerQuart); |
| 498 | + int playerMinX = this.centerX + Mth.floor(Configs.PixelsPerBiome * relPlayerQuart.x()) - 10; |
| 499 | + int playerMinY = this.centerY + Mth.floor(Configs.PixelsPerBiome * relPlayerQuart.z()) - 10; |
498 | 500 | int playerMaxX = playerMinX + 20; |
499 | 501 | int playerMaxY = playerMinY + 20; |
500 | 502 | if (playerMinX >= HORIZONTAL_PADDING && playerMaxX <= HORIZONTAL_PADDING + this.seedMapWidth && playerMinY >= VERTICAL_PADDING && playerMaxY <= VERTICAL_PADDING + this.seedMapHeight) { |
@@ -529,13 +531,12 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia |
529 | 531 |
|
530 | 532 | private void drawTile(GuiGraphics guiGraphics, Tile tile) { |
531 | 533 | TilePos tilePos = tile.pos(); |
532 | | - QuartPos2 relQuartPos = QuartPos2.fromTilePos(tilePos).subtract(this.centerQuart); |
533 | | - double pixelsPerQuart = Math.max(MIN_PIXELS_PER_BIOME, Configs.PixelsPerBiome); |
534 | | - double tileSizePixels = TilePos.TILE_SIZE_CHUNKS * (double) SCALED_CHUNK_SIZE * pixelsPerQuart; |
535 | | - double minXDouble = this.centerX + relQuartPos.x() * pixelsPerQuart; |
536 | | - double minYDouble = this.centerY + relQuartPos.z() * pixelsPerQuart; |
537 | | - double maxXDouble = minXDouble + tileSizePixels; |
538 | | - double maxYDouble = minYDouble + tileSizePixels; |
| 534 | + QuartPos2f relTileQuart = QuartPos2f.fromQuartPos(QuartPos2.fromTilePos(tilePos)).subtract(this.centerQuart); |
| 535 | + int tileSizePixels = TILE_SIZE_PIXELS.getAsInt(); |
| 536 | + int minX = this.centerX + Mth.floor(Configs.PixelsPerBiome * relTileQuart.x()); |
| 537 | + int minY = this.centerY + Mth.floor(Configs.PixelsPerBiome * relTileQuart.z()); |
| 538 | + int maxX = minX + tileSizePixels; |
| 539 | + int maxY = minY + tileSizePixels; |
539 | 540 |
|
540 | 541 | if (maxXDouble <= HORIZONTAL_PADDING || minXDouble >= HORIZONTAL_PADDING + this.seedMapWidth) { |
541 | 542 | return; |
@@ -1239,7 +1240,7 @@ private String getBiomeName(BlockPos pos) { |
1239 | 1240 | return NativeAccess.readString(Cubiomes.biome2str(this.version, biome)); |
1240 | 1241 | } |
1241 | 1242 |
|
1242 | | - private void moveCenter(QuartPos2 newCenter) { |
| 1243 | + private void moveCenter(QuartPos2f newCenter) { |
1243 | 1244 | this.centerQuart = newCenter; |
1244 | 1245 |
|
1245 | 1246 | this.featureWidgets.removeIf(widget -> { |
@@ -1281,7 +1282,7 @@ private void handleMapMouseMoved(double mouseX, double mouseY) { |
1281 | 1282 | int relXQuart = (int) ((mouseX - this.centerX) / Configs.PixelsPerBiome); |
1282 | 1283 | int relZQuart = (int) ((mouseY - this.centerY) / Configs.PixelsPerBiome); |
1283 | 1284 |
|
1284 | | - this.mouseQuart = this.centerQuart.add(relXQuart, relZQuart); |
| 1285 | + this.mouseQuart = QuartPos2.fromQuartPos2f(this.centerQuart.add(relXQuart, relZQuart)); |
1285 | 1286 | } |
1286 | 1287 |
|
1287 | 1288 | @Override |
@@ -1313,9 +1314,8 @@ public boolean mouseDragged(MouseButtonEvent mouseButtonEvent, double dragX, dou |
1313 | 1314 | return false; |
1314 | 1315 | } |
1315 | 1316 |
|
1316 | | - // TODO: fix small drags not taking effect |
1317 | | - int relXQuart = (int) (-dragX / Configs.PixelsPerBiome); |
1318 | | - int relZQuart = (int) (-dragY / Configs.PixelsPerBiome); |
| 1317 | + float relXQuart = (float) (-dragX / Configs.PixelsPerBiome); |
| 1318 | + float relZQuart = (float) (-dragY / Configs.PixelsPerBiome); |
1319 | 1319 |
|
1320 | 1320 | this.moveCenter(this.centerQuart.add(relXQuart, relZQuart)); |
1321 | 1321 | return true; |
@@ -1531,7 +1531,7 @@ private boolean handleTeleportFieldEnter(KeyEvent keyEvent) { |
1531 | 1531 | if (z < -Level.MAX_LEVEL_SIZE || z > Level.MAX_LEVEL_SIZE) { |
1532 | 1532 | return false; |
1533 | 1533 | } |
1534 | | - this.moveCenter(new QuartPos2(QuartPos.fromBlock(x), QuartPos.fromBlock(z))); |
| 1534 | + this.moveCenter(new QuartPos2f(QuartPos.fromBlock(x), QuartPos.fromBlock(z))); |
1535 | 1535 | this.teleportEditBoxX.setValue(""); |
1536 | 1536 | this.teleportEditBoxZ.setValue(""); |
1537 | 1537 | return true; |
@@ -1623,8 +1623,9 @@ public FeatureWidget(MapFeature feature, BlockPos featureLocation) { |
1623 | 1623 | } |
1624 | 1624 |
|
1625 | 1625 | private void updatePosition() { |
1626 | | - this.x = centerX + scaleToPixels(QuartPos.fromBlock(this.featureLocation.getX()) - centerQuart.x()) - this.feature.getTexture().width() / 2; |
1627 | | - this.y = centerY + scaleToPixels(QuartPos.fromBlock(this.featureLocation.getZ()) - centerQuart.z()) - this.feature.getTexture().height() / 2; |
| 1626 | + QuartPos2f relFeatureQuart = QuartPos2f.fromQuartPos(QuartPos2.fromBlockPos(this.featureLocation)).subtract(centerQuart); |
| 1627 | + this.x = centerX + Mth.floor(Configs.PixelsPerBiome * relFeatureQuart.x()) - this.feature.getTexture().width() / 2; |
| 1628 | + this.y = centerY + Mth.floor(Configs.PixelsPerBiome * relFeatureQuart.z()) - this.feature.getTexture().height() / 2; |
1628 | 1629 | } |
1629 | 1630 |
|
1630 | 1631 | private int width() { |
|
0 commit comments