Skip to content

Commit 5668c99

Browse files
xpplecev-api
authored andcommitted
Fix small drags not taking effect
1 parent 544c57c commit 5668c99

File tree

7 files changed

+50
-29
lines changed

7 files changed

+50
-29
lines changed

gradle/wrapper/gradle-wrapper.jar

1.83 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
#
4-
# Copyright © 2015-2021 the original authors.
4+
# Copyright © 2015 the original authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -114,7 +114,6 @@ case "$( uname )" in #(
114114
NONSTOP* ) nonstop=true ;;
115115
esac
116116

117-
CLASSPATH="\\\"\\\""
118117

119118

120119
# Determine the Java command to use to start the JVM.
@@ -172,7 +171,6 @@ fi
172171
# For Cygwin or MSYS, switch paths to Windows format before running java
173172
if "$cygwin" || "$msys" ; then
174173
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
175-
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
176174

177175
JAVACMD=$( cygpath --unix "$JAVACMD" )
178176

@@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
212210

213211
set -- \
214212
"-Dorg.gradle.appname=$APP_BASE_NAME" \
215-
-classpath "$CLASSPATH" \
216213
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217214
"$@"
218215

gradlew.bat

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@ goto fail
7070
:execute
7171
@rem Setup the command line
7272

73-
set CLASSPATH=
7473

7574

7675
@rem Execute Gradle
77-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
76+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7877

7978
:end
8079
@rem End local scope for the variables with windows NT shell

src/main/java/dev/xpple/seedmapper/seedmap/SeedMapScreen.java

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import dev.xpple.seedmapper.thread.SeedMapExecutor;
3434
import dev.xpple.seedmapper.util.NativeAccess;
3535
import dev.xpple.seedmapper.util.QuartPos2;
36+
import dev.xpple.seedmapper.util.QuartPos2f;
3637
import dev.xpple.seedmapper.util.RegionPos;
3738
import dev.xpple.seedmapper.util.TwoDTree;
3839
import dev.xpple.seedmapper.util.WorldIdentifier;
@@ -224,7 +225,7 @@ private static int scaleToPixels(int quartOffset) {
224225

225226
private final BlockPos playerPos;
226227

227-
private QuartPos2 centerQuart;
228+
private QuartPos2f centerQuart;
228229

229230
private int centerX;
230231
private int centerY;
@@ -323,8 +324,8 @@ public SeedMapScreen(long seed, int dimension, int version, BlockPos playerPos)
323324

324325
this.playerPos = playerPos;
325326

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);
328329
}
329330

330331
@Override
@@ -359,7 +360,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
359360
int horTileRadius = Math.ceilDiv(this.seedMapWidth, tileSizePixels) + 1;
360361
int verTileRadius = Math.ceilDiv(this.seedMapHeight, tileSizePixels) + 1;
361362

362-
TilePos centerTile = TilePos.fromQuartPos(this.centerQuart);
363+
TilePos centerTile = TilePos.fromQuartPos(QuartPos2.fromQuartPos2f(this.centerQuart));
363364
for (int relTileX = -horTileRadius; relTileX <= horTileRadius; relTileX++) {
364365
for (int relTileZ = -verTileRadius; relTileZ <= verTileRadius; relTileZ++) {
365366
TilePos tilePos = centerTile.add(relTileX, relTileZ);
@@ -397,7 +398,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
397398
return;
398399
}
399400
int regionSize = StructureConfig.regionSize(structureConfig);
400-
RegionPos centerRegion = RegionPos.fromQuartPos(this.centerQuart, regionSize);
401+
RegionPos centerRegion = RegionPos.fromQuartPos(QuartPos2.fromQuartPos2f(this.centerQuart), regionSize);
401402
int horRegionRadius = Math.ceilDiv(horChunkRadius, regionSize);
402403
int verRegionRadius = Math.ceilDiv(verChunkRadius, regionSize);
403404
StructureChecks.GenerationCheck generationCheck = StructureChecks.getGenerationCheck(structure);
@@ -493,8 +494,9 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
493494
}
494495

495496
// 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;
498500
int playerMaxX = playerMinX + 20;
499501
int playerMaxY = playerMinY + 20;
500502
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
529531

530532
private void drawTile(GuiGraphics guiGraphics, Tile tile) {
531533
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;
539540

540541
if (maxXDouble <= HORIZONTAL_PADDING || minXDouble >= HORIZONTAL_PADDING + this.seedMapWidth) {
541542
return;
@@ -1239,7 +1240,7 @@ private String getBiomeName(BlockPos pos) {
12391240
return NativeAccess.readString(Cubiomes.biome2str(this.version, biome));
12401241
}
12411242

1242-
private void moveCenter(QuartPos2 newCenter) {
1243+
private void moveCenter(QuartPos2f newCenter) {
12431244
this.centerQuart = newCenter;
12441245

12451246
this.featureWidgets.removeIf(widget -> {
@@ -1281,7 +1282,7 @@ private void handleMapMouseMoved(double mouseX, double mouseY) {
12811282
int relXQuart = (int) ((mouseX - this.centerX) / Configs.PixelsPerBiome);
12821283
int relZQuart = (int) ((mouseY - this.centerY) / Configs.PixelsPerBiome);
12831284

1284-
this.mouseQuart = this.centerQuart.add(relXQuart, relZQuart);
1285+
this.mouseQuart = QuartPos2.fromQuartPos2f(this.centerQuart.add(relXQuart, relZQuart));
12851286
}
12861287

12871288
@Override
@@ -1313,9 +1314,8 @@ public boolean mouseDragged(MouseButtonEvent mouseButtonEvent, double dragX, dou
13131314
return false;
13141315
}
13151316

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);
13191319

13201320
this.moveCenter(this.centerQuart.add(relXQuart, relZQuart));
13211321
return true;
@@ -1531,7 +1531,7 @@ private boolean handleTeleportFieldEnter(KeyEvent keyEvent) {
15311531
if (z < -Level.MAX_LEVEL_SIZE || z > Level.MAX_LEVEL_SIZE) {
15321532
return false;
15331533
}
1534-
this.moveCenter(new QuartPos2(QuartPos.fromBlock(x), QuartPos.fromBlock(z)));
1534+
this.moveCenter(new QuartPos2f(QuartPos.fromBlock(x), QuartPos.fromBlock(z)));
15351535
this.teleportEditBoxX.setValue("");
15361536
this.teleportEditBoxZ.setValue("");
15371537
return true;
@@ -1623,8 +1623,9 @@ public FeatureWidget(MapFeature feature, BlockPos featureLocation) {
16231623
}
16241624

16251625
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;
16281629
}
16291630

16301631
private int width() {

src/main/java/dev/xpple/seedmapper/util/QuartPos2.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33
import dev.xpple.seedmapper.seedmap.TilePos;
44
import net.minecraft.core.BlockPos;
55
import net.minecraft.core.QuartPos;
6+
import net.minecraft.util.Mth;
67
import net.minecraft.world.level.ChunkPos;
78

89
public record QuartPos2(int x, int z) {
10+
public static QuartPos2 fromQuartPos2f(QuartPos2f quartPos2f) {
11+
return new QuartPos2(Mth.floor(quartPos2f.x()), Mth.floor(quartPos2f.z()));
12+
}
13+
914
public static QuartPos2 fromBlockPos(BlockPos blockPos) {
1015
return new QuartPos2(QuartPos.fromBlock(blockPos.getX()), QuartPos.fromBlock(blockPos.getZ()));
1116
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package dev.xpple.seedmapper.util;
2+
3+
public record QuartPos2f(float x, float z) {
4+
public static QuartPos2f fromQuartPos(QuartPos2 quartPos2) {
5+
return new QuartPos2f(quartPos2.x(), quartPos2.z());
6+
}
7+
8+
public QuartPos2f add(QuartPos2f quartPos) {
9+
return this.add(quartPos.x, quartPos.z);
10+
}
11+
12+
public QuartPos2f add(float quartX, float quartZ) {
13+
return new QuartPos2f(this.x + quartX, this.z + quartZ);
14+
}
15+
16+
public QuartPos2f subtract(QuartPos2f quartPos) {
17+
return this.add(-quartPos.x, -quartPos.z);
18+
}
19+
}

0 commit comments

Comments
 (0)