diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 024b42beda..7f4b1a79f2 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -21,10 +21,10 @@ jobs: uses: actions/checkout@v4 - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 + uses: gradle/wrapper-validation-action@v2 - name: Set up Java 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'microsoft' @@ -33,7 +33,7 @@ jobs: run: chmod +x gradlew - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/gradle-build-action@v3 - name: Check code style with Spotless id: spotless_check diff --git a/build.gradle b/build.gradle index f14cf4bb09..49a8214542 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { } plugins { - id 'fabric-loom' version '1.5-SNAPSHOT' + id 'fabric-loom' version '1.6-SNAPSHOT' id 'maven-publish' id 'com.diffplug.spotless' version '6.23.3' } @@ -101,7 +101,7 @@ spotless { // configure the maven publication publishing { publications { - mavenJava(MavenPublication) { + create("mavenJava", MavenPublication) { from components.java } } diff --git a/gradle.properties b/gradle.properties index caa312c0cd..3675fdc1d3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ org.gradle.parallel=true # https://www.curseforge.com/minecraft/mc-mods/fabric-api minecraft_version=1.20.4 yarn_mappings=1.20.4+build.3 -loader_version=0.15.7 +loader_version=0.15.9 #Fabric api fabric_version=0.96.11+1.20.4 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135c49..d64cd49177 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e0930b..b82aa23a4f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 31042a6773..1aa94a4269 100644 --- a/gradlew +++ b/gradlew @@ -246,4 +246,4 @@ eval "set -- $( tr '\n' ' ' )" '"$@"' -exec "$JAVACMD" "$@" \ No newline at end of file +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 6689b85bee..13ba5d3cb8 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -89,4 +89,4 @@ exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal -:omega +:omega \ No newline at end of file diff --git a/src/main/java/net/wurstclient/hacks/AutoLibrarianHack.java b/src/main/java/net/wurstclient/hacks/AutoLibrarianHack.java index 2f49d3c25c..a0ff9212c4 100644 --- a/src/main/java/net/wurstclient/hacks/AutoLibrarianHack.java +++ b/src/main/java/net/wurstclient/hacks/AutoLibrarianHack.java @@ -297,7 +297,7 @@ private void breakJobSite() // damage block and swing hand if(MC.interactionManager.updateBlockBreakingProgress(jobSite, params.side())) - swingHand.getSelected().swing(Hand.MAIN_HAND); + swingHand.swing(Hand.MAIN_HAND); // update progress overlay.updateProgress(); @@ -359,7 +359,7 @@ private void placeJobSite() // swing hand if(result.isAccepted() && result.shouldSwingHand()) - swingHand.getSelected().swing(hand); + swingHand.swing(hand); // reset sneak ((IKeyBinding)MC.options.sneakKey).resetPressedState(); @@ -401,7 +401,7 @@ private void openTradeScreen() // swing hand if(actionResult.isAccepted() && actionResult.shouldSwingHand()) - swingHand.getSelected().swing(hand); + swingHand.swing(hand); // set cooldown MC.itemUseCooldown = 4; diff --git a/src/main/java/net/wurstclient/hacks/TreeBotHack.java b/src/main/java/net/wurstclient/hacks/TreeBotHack.java index 03e7afc69c..9d582a53b2 100644 --- a/src/main/java/net/wurstclient/hacks/TreeBotHack.java +++ b/src/main/java/net/wurstclient/hacks/TreeBotHack.java @@ -250,7 +250,7 @@ private boolean breakBlock(BlockPos pos) // damage block and swing hand if(MC.interactionManager.updateBlockBreakingProgress(pos, params.side())) - swingHand.getSelected().swing(Hand.MAIN_HAND); + swingHand.swing(Hand.MAIN_HAND); // update progress overlay.updateProgress(); diff --git a/src/main/java/net/wurstclient/settings/RoundingPrecisionSetting.java b/src/main/java/net/wurstclient/settings/RoundingPrecisionSetting.java new file mode 100644 index 0000000000..d8d27c48b9 --- /dev/null +++ b/src/main/java/net/wurstclient/settings/RoundingPrecisionSetting.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2014-2024 Wurst-Imperium and contributors. + * + * This source code is subject to the terms of the GNU General Public + * License, version 3. If a copy of the GPL was not distributed with this + * file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt + */ +package net.wurstclient.settings; + +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Locale; + +public final class RoundingPrecisionSetting extends SliderSetting +{ + private static final DecimalFormatSymbols SYMBOLS = + new DecimalFormatSymbols(Locale.ENGLISH); + + private final DecimalFormat[] FORMATS; + + public RoundingPrecisionSetting(String name, String description, int value, + int min, int max) + { + super(name, description, value, min, max, 1, + ValueDisplay.ROUNDING_PRECISION); + + if(min < 0) + throw new IllegalArgumentException( + "min must be greater than or equal to 0"); + + FORMATS = new DecimalFormat[max + 1]; + } + + public DecimalFormat getFormat() + { + int value = getValueI(); + + if(FORMATS[value] == null) + { + String pattern = "0"; + if(value > 0) + pattern += "." + "#".repeat(value); + + FORMATS[value] = new DecimalFormat(pattern, SYMBOLS); + } + + return FORMATS[value]; + } + + public String format(double value) + { + return getFormat().format(value); + } +} diff --git a/src/main/java/net/wurstclient/settings/SliderSetting.java b/src/main/java/net/wurstclient/settings/SliderSetting.java index fb190074cf..7eb231c872 100644 --- a/src/main/java/net/wurstclient/settings/SliderSetting.java +++ b/src/main/java/net/wurstclient/settings/SliderSetting.java @@ -323,6 +323,9 @@ public String getValueString(double v) public static final ValueDisplay DEGREES = INTEGER.withSuffix("\u00b0"); + public static final ValueDisplay ROUNDING_PRECISION = + v -> (int)v == 0 ? "1" : "0." + "0".repeat((int)v - 1) + "1"; + public static final ValueDisplay NONE = v -> ""; public String getValueString(double value); diff --git a/src/main/java/net/wurstclient/settings/SwingHandSetting.java b/src/main/java/net/wurstclient/settings/SwingHandSetting.java index da846eca8c..47c2fced6a 100644 --- a/src/main/java/net/wurstclient/settings/SwingHandSetting.java +++ b/src/main/java/net/wurstclient/settings/SwingHandSetting.java @@ -34,6 +34,11 @@ public SwingHandSetting(String name, String description, SwingHand selected) super(name, description, SwingHand.values(), selected); } + public void swing(Hand hand) + { + getSelected().swing(hand); + } + public enum SwingHand { OFF("Off", hand -> {}), @@ -44,8 +49,8 @@ public enum SwingHand CLIENT("Client-side", hand -> MC.player.swingHand(hand)); - private String name; - private Consumer swing; + private final String name; + private final Consumer swing; private SwingHand(String name, Consumer swing) { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 827d585e69..e1e2d737db 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -29,7 +29,7 @@ "accessWidener" : "wurst.accesswidener", "depends": { - "fabricloader": ">=0.15.0", + "fabricloader": ">=0.15.9", "fabric-api": ">=0.91.1", "minecraft": "~1.20.3-beta.3", "java": ">=17"