diff --git a/build.gradle b/build.gradle index a307b66..984312e 100644 --- a/build.gradle +++ b/build.gradle @@ -155,6 +155,7 @@ dependencies { include project(path: ':microdurability-1.20') include project(path: ':microdurability-1.20.5') include project(path: ':microdurability-1.21') + include project(path: ':microdurability-1.21.4') runtimeOnly project(path: ':microdurability-core', configuration: "namedElements") runtimeOnly project(path: ':microdurability-1.16', configuration: "namedElements") @@ -164,15 +165,16 @@ dependencies { runtimeOnly project(path: ':microdurability-1.20', configuration: "namedElements") runtimeOnly project(path: ':microdurability-1.20.5', configuration: "namedElements") runtimeOnly project(path: ':microdurability-1.21', configuration: "namedElements") + runtimeOnly project(path: ':microdurability-1.21.4', configuration: "namedElements") - modRuntimeOnly "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version_1_21}" - modRuntimeOnly "com.terraformersmc:modmenu:${project.modmenu_version_1_21}" - modRuntimeOnly("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version_1_21}") { + modRuntimeOnly "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version_1_21_4}" + modRuntimeOnly "com.terraformersmc:modmenu:${project.modmenu_version_1_21_4}" + modRuntimeOnly("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version_1_21_4}") { exclude(group: 'net.fabricmc.fabric-api') } - minecraft "com.mojang:minecraft:${minecraft_version_1_21}" - mappings "net.fabricmc:yarn:${project.yarn_mappings_1_21}:v2" + minecraft "com.mojang:minecraft:${minecraft_version_1_21_4}" + mappings "net.fabricmc:yarn:${project.yarn_mappings_1_21_4}:v2" } diff --git a/gradle.properties b/gradle.properties index db671e8..a7d5f39 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx2G org.gradle.parallel = true # Gradle Plugins -fabric_loom_version = 1.7-SNAPSHOT +fabric_loom_version = 1.10-SNAPSHOT checkstyle_version = 10.18.+ spotless_version = 6.25.+ @@ -13,7 +13,7 @@ maven_group = com.github.reviversmc archives_base_name = microdurability # Global Dependencies -fabric_loader_version = 0.16.7 +fabric_loader_version = 0.16.10 fabric_asm_version = v2.3 # Module Dependencies @@ -52,6 +52,11 @@ minecraft_version_1_21 = 1.21.1 yarn_mappings_1_21 = 1.21.1+build.3 cloth_config_version_1_21 = 15.0.140 modmenu_version_1_21 = 11.0.3 +# 1.21.4 +minecraft_version_1_21_4 = 1.21.4 +yarn_mappings_1_21_4 = 1.21.4+build.8 +cloth_config_version_1_21_4 = 17.0.144 +modmenu_version_1_21_4 = 13.0.3 # Dev-Env Mods use_third_party_mods = true @@ -124,3 +129,12 @@ ferritecore_version_1_21 = 7.0.1-fabric threadtweak_version_1_21 = 0.1.5 fadeless_version_1_21 = 1.1.1 double_hotbar_version_1_21 = 1.3.3-mc1.21-fabric +# 1.21.4 +fabric_api_version_1_21_4 = 0.119.2+1.21.4 +sodium_version_1_21_4 = mc1.21.4-0.6.10-fabric +lithium_version_1_21_4 = mc1.21.4-0.15.1-fabric +ferritecore_version_1_21_4 = 7.1.1-fabric +# threadtweak_version_1_21_4 = 0.1.5 +fadeless_version_1_21_4 = 2.0.2 +midnightlib_version_1_21_4=1.6.6-fabric +double_hotbar_version_1_21_4 = 1.3.4-mc1.21.2-fabric diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e644113..9bbc975 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 a441313..37f853b 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.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a4..faf9300 100755 --- a/gradlew +++ b/gradlew @@ -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/HEAD/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/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +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 @@ -203,7 +205,7 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * 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. diff --git a/gradlew.bat b/gradlew.bat index 25da30d..9b42019 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,92 +1,94 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -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% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -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 - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -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 %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@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 ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +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% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +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 + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +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 %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/microdurability-1.21.4/build.gradle b/microdurability-1.21.4/build.gradle new file mode 100644 index 0000000..ce0ea0f --- /dev/null +++ b/microdurability-1.21.4/build.gradle @@ -0,0 +1,44 @@ +base { + archivesName = archivesName.get() + '-compat-1.21.4' +} + +dependencies { + api project(path: ':microdurability-1.21', configuration: 'namedElements') + + minecraft "com.mojang:minecraft:${project.minecraft_version_1_21_4}" + mappings "net.fabricmc:yarn:${project.yarn_mappings_1_21_4}:v2" + + // Other mods + modRuntimeOnly "com.terraformersmc:modmenu:${project.modmenu_version_1_21_4}" + modRuntimeOnly("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version_1_21_4}") { + exclude(group: 'net.fabricmc.fabric-api') + } + + + if (project.use_third_party_mods == 'true') { + // Use full Fabric API bundle while debugging, since transitive deps aren't always declared correctly + modRuntimeOnly "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version_1_21_4}" + + modRuntimeOnly "maven.modrinth:sodium:${project.sodium_version_1_21_4}" + modRuntimeOnly "maven.modrinth:lithium:${project.lithium_version_1_21_4}" + modRuntimeOnly "maven.modrinth:ferrite-core:${project.ferritecore_version_1_21_4}" + // Not currently updated when written +// modRuntimeOnly "maven.modrinth:threadtweak:${project.threadtweak_version_1_21_4}" + modRuntimeOnly "maven.modrinth:fadeless:${project.fadeless_version_1_21_4}" + modRuntimeOnly "maven.modrinth:midnightlib:${project.midnightlib_version_1_21_4}" + + // Comment out the following dependencies to check vanilla compatibility + // Not currently updated when written +// modRuntimeOnly "maven.modrinth:raised:Fabric-1.21.4-${project.raised_v4_version}" + modRuntimeOnly "maven.modrinth:double-hotbar:${project.double_hotbar_version_1_21_4}" + } +} + +java { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 +} + +tasks.withType(JavaCompile).configureEach { + it.options.release = 21 +} diff --git a/microdurability-1.21.4/src/main/java/com/github/reviversmc/microdurability/MicroDurability1214.java b/microdurability-1.21.4/src/main/java/com/github/reviversmc/microdurability/MicroDurability1214.java new file mode 100644 index 0000000..156c95d --- /dev/null +++ b/microdurability-1.21.4/src/main/java/com/github/reviversmc/microdurability/MicroDurability1214.java @@ -0,0 +1,20 @@ +package com.github.reviversmc.microdurability; + +import java.util.function.Supplier; + +import com.github.reviversmc.microdurability.compat.minecraft.McVersionCompatInitializer; +import com.github.reviversmc.microdurability.compat.minecraft.McVersionHelper; + +public class MicroDurability1214 extends McVersionCompatInitializer { + static final Supplier IS_COMPATIBLE = () -> McVersionHelper.isWithin("1.21.4", McVersionHelper.INFINITY); + + @Override + public boolean isCompatible() { + return IS_COMPATIBLE.get(); + } + + @Override + protected void initialize() { + MicroDurability.renderer = new Renderer1214(); + } +} diff --git a/microdurability-1.21.4/src/main/java/com/github/reviversmc/microdurability/MixinProvider1214.java b/microdurability-1.21.4/src/main/java/com/github/reviversmc/microdurability/MixinProvider1214.java new file mode 100644 index 0000000..1cc41ca --- /dev/null +++ b/microdurability-1.21.4/src/main/java/com/github/reviversmc/microdurability/MixinProvider1214.java @@ -0,0 +1,16 @@ +package com.github.reviversmc.microdurability; + +import java.util.List; + +import com.github.reviversmc.microdurability.compat.minecraft.McVersionMixinProvider; + +public class MixinProvider1214 extends McVersionMixinProvider { + @Override + public List getMixins() { + if (MicroDurability1214.IS_COMPATIBLE.get()) { + return List.of("InGameHudMixin1214"); + } + + return null; + } +} diff --git a/microdurability-1.21.4/src/main/java/com/github/reviversmc/microdurability/Renderer1214.java b/microdurability-1.21.4/src/main/java/com/github/reviversmc/microdurability/Renderer1214.java new file mode 100644 index 0000000..8cbc5f5 --- /dev/null +++ b/microdurability-1.21.4/src/main/java/com/github/reviversmc/microdurability/Renderer1214.java @@ -0,0 +1,18 @@ +package com.github.reviversmc.microdurability; + +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.util.math.ColorHelper; + +import com.github.reviversmc.microdurability.compat.mods.RaisedCompat; + +public class Renderer1214 extends Renderer121 { + @Override + protected void renderGuiQuad(Object context, int x, int y, int width, int height, int red, int green, int blue, int alpha) { + if (RaisedCompat.isInstalled() && !RaisedCompat.isV3OrLater()) { + y += getRaisedOffset(); + } + + ((DrawContext) context).fill(RenderLayer.getGuiOverlay(), x, y, x + width, y + height, ColorHelper.getArgb(alpha, red, green, blue)); + } +} diff --git a/microdurability-1.21.4/src/main/java/com/github/reviversmc/microdurability/mixins/InGameHudMixin1214.java b/microdurability-1.21.4/src/main/java/com/github/reviversmc/microdurability/mixins/InGameHudMixin1214.java new file mode 100644 index 0000000..446bf3f --- /dev/null +++ b/microdurability-1.21.4/src/main/java/com/github/reviversmc/microdurability/mixins/InGameHudMixin1214.java @@ -0,0 +1,29 @@ +package com.github.reviversmc.microdurability.mixins; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.render.RenderTickCounter; + +import com.github.reviversmc.microdurability.MicroDurability; + +@Mixin(InGameHud.class) +public class InGameHudMixin1214 { + @Shadow + private int ticks; + + @Inject(method = "renderHotbar", at = @At("RETURN")) + private void renderArmorArea(DrawContext context, RenderTickCounter tickCounter, CallbackInfo callbackInfo) { + MicroDurability.renderer.renderArmorArea(context, ticks); + } + + @Inject(method = "renderCrosshair", at = @At("RETURN")) + private void renderHeldItemExclamationMark(DrawContext context, RenderTickCounter tickCounter, CallbackInfo callbackInfo) { + MicroDurability.renderer.renderHeldItemLowDurabilityWarning(context, ticks); + } +} diff --git a/microdurability-1.21.4/src/main/resources/fabric.mod.json b/microdurability-1.21.4/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..670ab37 --- /dev/null +++ b/microdurability-1.21.4/src/main/resources/fabric.mod.json @@ -0,0 +1,32 @@ +{ + "schemaVersion": 1, + "id": "microdurability-compat-1-21-4", + "version": "${version}", + "name": "microDurability 1.21.4 Compat", + "license": "MPL-2.0", + "environment": "client", + "entrypoints": { + "microdurability": [ + "com.github.reviversmc.microdurability.MicroDurability1214" + ], + "modmenu": [ + "com.github.reviversmc.microdurability.compat.mods.ModMenuIntegration" + ] + }, + "mixins": [ + "microdurability1214.mixins.json" + ], + "depends": { + "fabricloader": ">=0.12.9", + "minecraft": ">=1.21.4", + "microdurability-compat-1-20-5": "*" + }, + "custom": { + "modmenu": { + "badges": ["library"], + "parent": { + "id": "microdurability" + } + } + } +} diff --git a/microdurability-1.21.4/src/main/resources/microdurability1214.mixins.json b/microdurability-1.21.4/src/main/resources/microdurability1214.mixins.json new file mode 100644 index 0000000..f27d9f3 --- /dev/null +++ b/microdurability-1.21.4/src/main/resources/microdurability1214.mixins.json @@ -0,0 +1,9 @@ +{ + "required": true, + "package": "com.github.reviversmc.microdurability.mixins", + "compatibilityLevel": "JAVA_21", + "plugin": "com.github.reviversmc.microdurability.MixinProvider1214", + "injectors": { + "defaultRequire": 1 + } +} diff --git a/microdurability-1.21/src/main/java/com/github/reviversmc/microdurability/MicroDurability121.java b/microdurability-1.21/src/main/java/com/github/reviversmc/microdurability/MicroDurability121.java index 27e099c..5af74bd 100644 --- a/microdurability-1.21/src/main/java/com/github/reviversmc/microdurability/MicroDurability121.java +++ b/microdurability-1.21/src/main/java/com/github/reviversmc/microdurability/MicroDurability121.java @@ -6,7 +6,7 @@ import com.github.reviversmc.microdurability.compat.minecraft.McVersionHelper; public class MicroDurability121 extends McVersionCompatInitializer { - static final Supplier IS_COMPATIBLE = () -> McVersionHelper.isWithin("1.21", McVersionHelper.INFINITY); + static final Supplier IS_COMPATIBLE = () -> McVersionHelper.isWithin("1.21", "1.21.3"); @Override public boolean isCompatible() { diff --git a/settings.gradle b/settings.gradle index 75ab8ea..f07aef0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -23,4 +23,5 @@ include 'microdurability-1.19.4' include 'microdurability-1.20' include 'microdurability-1.20.5' include 'microdurability-1.21' +include 'microdurability-1.21.4' include 'microdurability-dev-env-extras'