Skip to content

Commit fa86939

Browse files
committed
Fix small drags not taking effect
1 parent 703dd96 commit fa86939

File tree

7 files changed

+47
-25
lines changed

7 files changed

+47
-25
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: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import dev.xpple.seedmapper.thread.SeedMapCache;
2828
import dev.xpple.seedmapper.thread.SeedMapExecutor;
2929
import dev.xpple.seedmapper.util.QuartPos2;
30+
import dev.xpple.seedmapper.util.QuartPos2f;
3031
import dev.xpple.seedmapper.util.RegionPos;
3132
import dev.xpple.seedmapper.util.TwoDTree;
3233
import dev.xpple.seedmapper.util.WorldIdentifier;
@@ -182,7 +183,7 @@ public class SeedMapScreen extends Screen {
182183

183184
private final BlockPos playerPos;
184185

185-
private QuartPos2 centerQuart;
186+
private QuartPos2f centerQuart;
186187

187188
private int centerX;
188189
private int centerY;
@@ -270,8 +271,8 @@ public SeedMapScreen(long seed, int dimension, int version, BlockPos playerPos)
270271

271272
this.playerPos = playerPos;
272273

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);
275276
}
276277

277278
@Override
@@ -303,7 +304,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
303304
int horTileRadius = Math.ceilDiv(this.seedMapWidth, tileSizePixels) + 1;
304305
int verTileRadius = Math.ceilDiv(this.seedMapHeight, tileSizePixels) + 1;
305306

306-
TilePos centerTile = TilePos.fromQuartPos(this.centerQuart);
307+
TilePos centerTile = TilePos.fromQuartPos(QuartPos2.fromQuartPos2f(this.centerQuart));
307308
for (int relTileX = -horTileRadius; relTileX <= horTileRadius; relTileX++) {
308309
for (int relTileZ = -verTileRadius; relTileZ <= verTileRadius; relTileZ++) {
309310
TilePos tilePos = centerTile.add(relTileX, relTileZ);
@@ -340,7 +341,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
340341
return;
341342
}
342343
int regionSize = StructureConfig.regionSize(structureConfig);
343-
RegionPos centerRegion = RegionPos.fromQuartPos(this.centerQuart, regionSize);
344+
RegionPos centerRegion = RegionPos.fromQuartPos(QuartPos2.fromQuartPos2f(this.centerQuart), regionSize);
344345
int horRegionRadius = Math.ceilDiv(horChunkRadius, regionSize);
345346
int verRegionRadius = Math.ceilDiv(verChunkRadius, regionSize);
346347
StructureChecks.GenerationCheck generationCheck = StructureChecks.getGenerationCheck(structure);
@@ -426,8 +427,9 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
426427
}
427428

428429
// 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;
431433
int playerMaxX = playerMinX + 20;
432434
int playerMaxY = playerMinY + 20;
433435
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
460462

461463
private void drawTile(GuiGraphics guiGraphics, Tile tile) {
462464
TilePos tilePos = tile.pos();
463-
QuartPos2 relQuartPos = QuartPos2.fromTilePos(tilePos).subtract(this.centerQuart);
465+
QuartPos2f relTileQuart = QuartPos2f.fromQuartPos(QuartPos2.fromTilePos(tilePos)).subtract(this.centerQuart);
464466
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());
467469
int maxX = minX + tileSizePixels;
468470
int maxY = minY + tileSizePixels;
469471

@@ -687,7 +689,7 @@ private void createWaypointNameField() {
687689
this.addRenderableWidget(this.waypointNameEditBox);
688690
}
689691

690-
private void moveCenter(QuartPos2 newCenter) {
692+
private void moveCenter(QuartPos2f newCenter) {
691693
this.centerQuart = newCenter;
692694

693695
this.featureWidgets.removeIf(widget -> {
@@ -729,7 +731,7 @@ private void handleMapMouseMoved(double mouseX, double mouseY) {
729731
int relXQuart = (int) ((mouseX - this.centerX) / Configs.PixelsPerBiome);
730732
int relZQuart = (int) ((mouseY - this.centerY) / Configs.PixelsPerBiome);
731733

732-
this.mouseQuart = this.centerQuart.add(relXQuart, relZQuart);
734+
this.mouseQuart = QuartPos2.fromQuartPos2f(this.centerQuart.add(relXQuart, relZQuart));
733735
}
734736

735737
@Override
@@ -760,9 +762,8 @@ public boolean mouseDragged(MouseButtonEvent mouseButtonEvent, double dragX, dou
760762
return false;
761763
}
762764

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

767768
this.moveCenter(this.centerQuart.add(relXQuart, relZQuart));
768769
return true;
@@ -953,7 +954,7 @@ private boolean handleTeleportFieldEnter(KeyEvent keyEvent) {
953954
if (z < -Level.MAX_LEVEL_SIZE || z > Level.MAX_LEVEL_SIZE) {
954955
return false;
955956
}
956-
this.moveCenter(new QuartPos2(QuartPos.fromBlock(x), QuartPos.fromBlock(z)));
957+
this.moveCenter(new QuartPos2f(QuartPos.fromBlock(x), QuartPos.fromBlock(z)));
957958
this.teleportEditBoxX.setValue("");
958959
this.teleportEditBoxZ.setValue("");
959960
return true;
@@ -1014,8 +1015,9 @@ public FeatureWidget(MapFeature feature, BlockPos featureLocation) {
10141015
}
10151016

10161017
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;
10191021
}
10201022

10211023
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)