|
27 | 27 | import dev.xpple.seedmapper.thread.SeedMapCache; |
28 | 28 | import dev.xpple.seedmapper.thread.SeedMapExecutor; |
29 | 29 | import dev.xpple.seedmapper.util.QuartPos2; |
| 30 | +import dev.xpple.seedmapper.util.QuartPos2f; |
30 | 31 | import dev.xpple.seedmapper.util.RegionPos; |
31 | 32 | import dev.xpple.seedmapper.util.TwoDTree; |
32 | 33 | import dev.xpple.seedmapper.util.WorldIdentifier; |
@@ -182,7 +183,7 @@ public class SeedMapScreen extends Screen { |
182 | 183 |
|
183 | 184 | private final BlockPos playerPos; |
184 | 185 |
|
185 | | - private QuartPos2 centerQuart; |
| 186 | + private QuartPos2f centerQuart; |
186 | 187 |
|
187 | 188 | private int centerX; |
188 | 189 | private int centerY; |
@@ -270,8 +271,8 @@ public SeedMapScreen(long seed, int dimension, int version, BlockPos playerPos) |
270 | 271 |
|
271 | 272 | this.playerPos = playerPos; |
272 | 273 |
|
273 | | - this.centerQuart = QuartPos2.fromBlockPos(playerPos); |
274 | | - this.mouseQuart = new QuartPos2(this.centerQuart.x(), this.centerQuart.z()); |
| 274 | + this.centerQuart = QuartPos2f.fromQuartPos(QuartPos2.fromBlockPos(this.playerPos)); |
| 275 | + this.mouseQuart = QuartPos2.fromQuartPos2f(this.centerQuart); |
275 | 276 | } |
276 | 277 |
|
277 | 278 | @Override |
@@ -303,7 +304,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia |
303 | 304 | int horTileRadius = Math.ceilDiv(this.seedMapWidth, tileSizePixels) + 1; |
304 | 305 | int verTileRadius = Math.ceilDiv(this.seedMapHeight, tileSizePixels) + 1; |
305 | 306 |
|
306 | | - TilePos centerTile = TilePos.fromQuartPos(this.centerQuart); |
| 307 | + TilePos centerTile = TilePos.fromQuartPos(QuartPos2.fromQuartPos2f(this.centerQuart)); |
307 | 308 | for (int relTileX = -horTileRadius; relTileX <= horTileRadius; relTileX++) { |
308 | 309 | for (int relTileZ = -verTileRadius; relTileZ <= verTileRadius; relTileZ++) { |
309 | 310 | TilePos tilePos = centerTile.add(relTileX, relTileZ); |
@@ -340,7 +341,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia |
340 | 341 | return; |
341 | 342 | } |
342 | 343 | int regionSize = StructureConfig.regionSize(structureConfig); |
343 | | - RegionPos centerRegion = RegionPos.fromQuartPos(this.centerQuart, regionSize); |
| 344 | + RegionPos centerRegion = RegionPos.fromQuartPos(QuartPos2.fromQuartPos2f(this.centerQuart), regionSize); |
344 | 345 | int horRegionRadius = Math.ceilDiv(horChunkRadius, regionSize); |
345 | 346 | int verRegionRadius = Math.ceilDiv(verChunkRadius, regionSize); |
346 | 347 | StructureChecks.GenerationCheck generationCheck = StructureChecks.getGenerationCheck(structure); |
@@ -426,8 +427,9 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia |
426 | 427 | } |
427 | 428 |
|
428 | 429 | // draw player position |
429 | | - int playerMinX = this.centerX + Configs.PixelsPerBiome * (QuartPos.fromBlock(this.playerPos.getX()) - this.centerQuart.x()) - 10; |
430 | | - int playerMinY = this.centerY + Configs.PixelsPerBiome * (QuartPos.fromBlock(this.playerPos.getZ()) - this.centerQuart.z()) - 10; |
| 430 | + QuartPos2f relPlayerQuart = QuartPos2f.fromQuartPos(QuartPos2.fromBlockPos(this.playerPos)).subtract(this.centerQuart); |
| 431 | + int playerMinX = this.centerX + Mth.floor(Configs.PixelsPerBiome * relPlayerQuart.x()) - 10; |
| 432 | + int playerMinY = this.centerY + Mth.floor(Configs.PixelsPerBiome * relPlayerQuart.z()) - 10; |
431 | 433 | int playerMaxX = playerMinX + 20; |
432 | 434 | int playerMaxY = playerMinY + 20; |
433 | 435 | if (playerMinX >= HORIZONTAL_PADDING && playerMaxX <= HORIZONTAL_PADDING + this.seedMapWidth && playerMinY >= VERTICAL_PADDING && playerMaxY <= VERTICAL_PADDING + this.seedMapHeight) { |
@@ -460,10 +462,10 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia |
460 | 462 |
|
461 | 463 | private void drawTile(GuiGraphics guiGraphics, Tile tile) { |
462 | 464 | TilePos tilePos = tile.pos(); |
463 | | - QuartPos2 relQuartPos = QuartPos2.fromTilePos(tilePos).subtract(this.centerQuart); |
| 465 | + QuartPos2f relTileQuart = QuartPos2f.fromQuartPos(QuartPos2.fromTilePos(tilePos)).subtract(this.centerQuart); |
464 | 466 | int tileSizePixels = TILE_SIZE_PIXELS.getAsInt(); |
465 | | - int minX = this.centerX + Configs.PixelsPerBiome * relQuartPos.x(); |
466 | | - int minY = this.centerY + Configs.PixelsPerBiome * relQuartPos.z(); |
| 467 | + int minX = this.centerX + Mth.floor(Configs.PixelsPerBiome * relTileQuart.x()); |
| 468 | + int minY = this.centerY + Mth.floor(Configs.PixelsPerBiome * relTileQuart.z()); |
467 | 469 | int maxX = minX + tileSizePixels; |
468 | 470 | int maxY = minY + tileSizePixels; |
469 | 471 |
|
@@ -687,7 +689,7 @@ private void createWaypointNameField() { |
687 | 689 | this.addRenderableWidget(this.waypointNameEditBox); |
688 | 690 | } |
689 | 691 |
|
690 | | - private void moveCenter(QuartPos2 newCenter) { |
| 692 | + private void moveCenter(QuartPos2f newCenter) { |
691 | 693 | this.centerQuart = newCenter; |
692 | 694 |
|
693 | 695 | this.featureWidgets.removeIf(widget -> { |
@@ -729,7 +731,7 @@ private void handleMapMouseMoved(double mouseX, double mouseY) { |
729 | 731 | int relXQuart = (int) ((mouseX - this.centerX) / Configs.PixelsPerBiome); |
730 | 732 | int relZQuart = (int) ((mouseY - this.centerY) / Configs.PixelsPerBiome); |
731 | 733 |
|
732 | | - this.mouseQuart = this.centerQuart.add(relXQuart, relZQuart); |
| 734 | + this.mouseQuart = QuartPos2.fromQuartPos2f(this.centerQuart.add(relXQuart, relZQuart)); |
733 | 735 | } |
734 | 736 |
|
735 | 737 | @Override |
@@ -760,9 +762,8 @@ public boolean mouseDragged(MouseButtonEvent mouseButtonEvent, double dragX, dou |
760 | 762 | return false; |
761 | 763 | } |
762 | 764 |
|
763 | | - // TODO: fix small drags not taking effect |
764 | | - int relXQuart = (int) (-dragX / Configs.PixelsPerBiome); |
765 | | - int relZQuart = (int) (-dragY / Configs.PixelsPerBiome); |
| 765 | + float relXQuart = (float) (-dragX / Configs.PixelsPerBiome); |
| 766 | + float relZQuart = (float) (-dragY / Configs.PixelsPerBiome); |
766 | 767 |
|
767 | 768 | this.moveCenter(this.centerQuart.add(relXQuart, relZQuart)); |
768 | 769 | return true; |
@@ -953,7 +954,7 @@ private boolean handleTeleportFieldEnter(KeyEvent keyEvent) { |
953 | 954 | if (z < -Level.MAX_LEVEL_SIZE || z > Level.MAX_LEVEL_SIZE) { |
954 | 955 | return false; |
955 | 956 | } |
956 | | - this.moveCenter(new QuartPos2(QuartPos.fromBlock(x), QuartPos.fromBlock(z))); |
| 957 | + this.moveCenter(new QuartPos2f(QuartPos.fromBlock(x), QuartPos.fromBlock(z))); |
957 | 958 | this.teleportEditBoxX.setValue(""); |
958 | 959 | this.teleportEditBoxZ.setValue(""); |
959 | 960 | return true; |
@@ -1014,8 +1015,9 @@ public FeatureWidget(MapFeature feature, BlockPos featureLocation) { |
1014 | 1015 | } |
1015 | 1016 |
|
1016 | 1017 | private void updatePosition() { |
1017 | | - this.x = centerX + Configs.PixelsPerBiome * (QuartPos.fromBlock(this.featureLocation.getX()) - centerQuart.x()) - this.feature.getTexture().width() / 2; |
1018 | | - this.y = centerY + Configs.PixelsPerBiome * (QuartPos.fromBlock(this.featureLocation.getZ()) - centerQuart.z()) - this.feature.getTexture().height() / 2; |
| 1018 | + QuartPos2f relFeatureQuart = QuartPos2f.fromQuartPos(QuartPos2.fromBlockPos(this.featureLocation)).subtract(centerQuart); |
| 1019 | + this.x = centerX + Mth.floor(Configs.PixelsPerBiome * relFeatureQuart.x()) - this.feature.getTexture().width() / 2; |
| 1020 | + this.y = centerY + Mth.floor(Configs.PixelsPerBiome * relFeatureQuart.z()) - this.feature.getTexture().height() / 2; |
1019 | 1021 | } |
1020 | 1022 |
|
1021 | 1023 | private int width() { |
|
0 commit comments