diff --git a/build.gradle b/build.gradle index 3e9cb1d..ee5853b 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,6 @@ allprojects { apply plugin: "architectury-plugin" apply plugin: "maven-publish" - archivesBaseName = rootProject.archives_base_name version = rootProject.mod_version group = rootProject.maven_group diff --git a/common/src/main/java/eu/midnightdust/core/MidnightLib.java b/common/src/main/java/eu/midnightdust/core/MidnightLib.java index 1343567..60b8cb7 100755 --- a/common/src/main/java/eu/midnightdust/core/MidnightLib.java +++ b/common/src/main/java/eu/midnightdust/core/MidnightLib.java @@ -5,6 +5,7 @@ import eu.midnightdust.lib.config.AutoCommand; import eu.midnightdust.lib.config.MidnightConfig; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.util.Util; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -13,8 +14,6 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; -import static net.minecraft.client.MinecraftClient.IS_SYSTEM_MAC; - public class MidnightLib { public static List hiddenMods = new ArrayList<>(); public static final String MOD_ID = "midnightlib"; @@ -22,7 +21,7 @@ public class MidnightLib { @Environment(EnvType.CLIENT) public static void onInitializeClient() { - try { if (!IS_SYSTEM_MAC) { + try { if (Util.getOperatingSystem() != Util.OperatingSystem.OSX) { System.setProperty("java.awt.headless", "false"); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }} catch (Exception | Error e) { LOGGER.error("Error setting system look and feel", e); } diff --git a/common/src/main/java/eu/midnightdust/lib/config/MidnightConfig.java b/common/src/main/java/eu/midnightdust/lib/config/MidnightConfig.java index 1d56dd4..8a3d332 100755 --- a/common/src/main/java/eu/midnightdust/lib/config/MidnightConfig.java +++ b/common/src/main/java/eu/midnightdust/lib/config/MidnightConfig.java @@ -6,18 +6,19 @@ import eu.midnightdust.lib.util.PlatformFunctions; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gl.RenderPipelines; +import net.minecraft.client.gui.Click; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.Element; import net.minecraft.client.gui.Selectable; import net.minecraft.client.gui.screen.ConfirmLinkScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.tab.GridScreenTab; import net.minecraft.client.gui.tab.Tab; import net.minecraft.client.gui.tab.TabManager; import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.widget.*; +import net.minecraft.client.input.KeyInput; import net.minecraft.client.resource.language.I18n; import net.minecraft.registry.Registries; import net.minecraft.screen.ScreenTexts; import net.minecraft.text.Style; import net.minecraft.text.Text; import net.minecraft.text.TranslatableTextContent; -import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; -import net.minecraft.util.TranslatableOption; +import net.minecraft.util.*; import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; @@ -30,8 +31,6 @@ import java.util.*; import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Predicate; import java.util.regex.Pattern; -import static net.minecraft.client.MinecraftClient.IS_SYSTEM_MAC; - /** MidnightConfig by Martin "Motschen" Prokoph * Single class config library - feel free to copy! * Based on ... @@ -310,9 +309,8 @@ public abstract class MidnightConfig { button.active = !Objects.equals(String.valueOf(entry.info.value), String.valueOf(entry.info.defaultValue)) && entry.info.conditionsMet; }}}} @Override - public boolean keyPressed(int keyCode, int scanCode, int modifiers) { - if (this.tabNavigation.trySwitchTabsWithKey(keyCode)) return true; - return super.keyPressed(keyCode, scanCode, modifiers); + public boolean keyPressed(KeyInput input) { + return this.tabNavigation.keyPressed(input) || super.keyPressed(input); } @Override public void close() { @@ -428,7 +426,7 @@ public abstract class MidnightConfig { } List widgets = Lists.newArrayList(widget, resetButton); if (info.actionButton != null) { - if (IS_SYSTEM_MAC) info.actionButton.active = false; + if (Util.getOperatingSystem() != Util.OperatingSystem.OSX) info.actionButton.active = false; widget.setWidth(widget.getWidth() - 22); widget.setX(widget.getX() + 22); widgets.add(info.actionButton); } if (cycleButton != null) { @@ -485,24 +483,24 @@ public abstract class MidnightConfig { title.setMaxWidth(!buttons.isEmpty() ? buttons.get(buttons.size() > 2 ? buttons.size()-1 : 0).getX() - 16 : scaledWidth - 24); } } - public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { - buttons.forEach(b -> { b.setY(y); b.render(context, mouseX, mouseY, tickDelta);}); + public void render(DrawContext context, int mouseX, int mouseY, boolean hovered, float tickDelta) { + buttons.forEach(b -> { b.setY(this.getY()); b.render(context, mouseX, mouseY, tickDelta);}); if (title != null) { - title.setY(y+5); + title.setY(this.getY()+5); title.render(context, mouseX, mouseY, tickDelta); if (info.entry != null && !this.buttons.isEmpty() && this.buttons.getFirst() instanceof ClickableWidget widget) { int idMode = this.info.entry.idMode(); - if (idMode != -1) context.drawItem(idMode == 0 ? Registries.ITEM.get(Identifier.tryParse(this.info.tempValue)).getDefaultStack() : Registries.BLOCK.get(Identifier.tryParse(this.info.tempValue)).asItem().getDefaultStack(), widget.getX() + widget.getWidth() - 18, y + 2); + if (idMode != -1) context.drawItem(idMode == 0 ? Registries.ITEM.get(Identifier.tryParse(this.info.tempValue)).getDefaultStack() : Registries.BLOCK.get(Identifier.tryParse(this.info.tempValue)).asItem().getDefaultStack(), widget.getX() + widget.getWidth() - 18, this.getY() + 2); } } } @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { + public boolean mouseClicked(Click click, boolean doubled) { if (this.info != null && this.info.comment != null && !this.info.comment.url().isBlank()) ConfirmLinkScreen.open(MinecraftClient.getInstance().currentScreen, this.info.comment.url(), true); - return super.mouseClicked(mouseX, mouseY, button); + return super.mouseClicked(click, doubled); } public List children() {return Lists.newArrayList(buttons);} diff --git a/common/src/test/java/eu/midnightdust/test/MidnightLibExtras.java b/common/src/test/java/eu/midnightdust/test/MidnightLibExtras.java index 21d4538..9784b59 100644 --- a/common/src/test/java/eu/midnightdust/test/MidnightLibExtras.java +++ b/common/src/test/java/eu/midnightdust/test/MidnightLibExtras.java @@ -7,6 +7,7 @@ import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ClickableWidget; import net.minecraft.client.gui.widget.TextIconButtonWidget; +import net.minecraft.client.input.KeyInput; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; import net.minecraft.text.MutableText; @@ -35,7 +36,7 @@ public class MidnightLibExtras { editButton.updateMessage(false); MidnightConfig.EntryInfo info = new MidnightConfig.EntryInfo(null, screen.modid); - list.addButton(Lists.newArrayList(editButton, resetButton), Text.translatable(binding.getTranslationKey()), info); + list.addButton(Lists.newArrayList(editButton, resetButton), Text.translatable(binding.getId()), info); } private final KeyBinding binding; @@ -44,24 +45,24 @@ public class MidnightLibExtras { super(x, y, width, height, binding.getBoundKeyLocalizedText(), (button) -> { ((KeybindButton) button).updateMessage(true); focusedButton = button; - }, (textSupplier) -> binding.isUnbound() ? Text.translatable("narrator.controls.unbound", binding.getTranslationKey()) : Text.translatable("narrator.controls.bound", binding.getTranslationKey(), textSupplier.get())); + }, (textSupplier) -> binding.isUnbound() ? Text.translatable("narrator.controls.unbound", binding.getId()) : Text.translatable("narrator.controls.bound", binding.getId(), textSupplier.get())); this.binding = binding; updateMessage(false); } @Override - public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + public boolean keyPressed(KeyInput input) { if (focusedButton == this) { - if (keyCode == GLFW.GLFW_KEY_ESCAPE) { + if (input.key() == GLFW.GLFW_KEY_ESCAPE) { this.binding.setBoundKey(InputUtil.UNKNOWN_KEY); } else { - this.binding.setBoundKey(InputUtil.fromKeyCode(keyCode, scanCode)); + this.binding.setBoundKey(InputUtil.fromKeyCode(input)); } updateMessage(false); focusedButton = null; return true; } - return super.keyPressed(keyCode, scanCode, modifiers); + return super.keyPressed(input); } public void updateMessage(boolean focused) { @@ -77,7 +78,7 @@ public class MidnightLibExtras { if (hasConflicts) conflictingBindings.append(", "); hasConflicts = true; - conflictingBindings.append(Text.translatable(keyBinding.getTranslationKey())); + conflictingBindings.append(Text.translatable(keyBinding.getId())); } } } diff --git a/fabric/build.gradle b/fabric/build.gradle index a96efdb..c519181 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -40,7 +40,6 @@ configurations { compileClasspath.extendsFrom common runtimeClasspath.extendsFrom common developmentFabric.extendsFrom common - archivesBaseName = rootProject.archives_base_name version = rootProject.mod_version + "-" + project.name + "+" + rootProject.minecraft_version } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e583..8bdaf60 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 6f64321..2e11132 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https://mirrors.aliyun.com/gradle/distributions/v8.14.3/gradle-8.14.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb..adff685 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +82,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -114,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -133,22 +132,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -165,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -193,16 +198,19 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 53a6b23..e509b2d 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -26,6 +28,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -42,11 +45,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 @@ -56,22 +59,21 @@ 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 :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 3184821..b89be4d 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -68,7 +68,6 @@ configurations { canBeResolved = true canBeConsumed = false } - archivesBaseName = rootProject.archives_base_name version = rootProject.mod_version + "-" + project.name + "+" + rootProject.minecraft_version }