From 6787bbef92e8d8044850e1bc24743ad31c1d5669 Mon Sep 17 00:00:00 2001 From: tildejustin Date: Mon, 8 Jan 2024 15:35:52 -0500 Subject: [PATCH 1/4] update fabric loader dependency and target version --- gradle.properties | 2 +- src/main/resources/fabric.mod.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 80482367..56a7e1ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ org.gradle.jvmargs=-Xmx1G minecraft_version=1.16.1 minecraft_version_code=1.16.1 yarn_mappings=1.16.1+build.21 -loader_version=0.14.17 +loader_version=0.14.25 # Mod Properties mod_version=14.0 diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a0b0a43c..82725310 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -33,7 +33,7 @@ ], "depends": { - "fabricloader": ">=0.12.2", + "fabricloader": ">=0.14.20", "minecraft": "{{MC_VERSION}}" }, From 90f5237d7370f92e49ecd4c1e99140ba453cafe0 Mon Sep 17 00:00:00 2001 From: tildejustin Date: Mon, 8 Jan 2024 15:36:16 -0500 Subject: [PATCH 2/4] update mappings --- build.gradle | 3 ++- gradle.properties | 2 +- .../com/redlimerl/speedrunigt/mixins/MinecraftClientMixin.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index bb9fc8e8..42dee48a 100644 --- a/build.gradle +++ b/build.gradle @@ -18,12 +18,13 @@ repositories { // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. // See https://docs.gradle.org/current/userguide/declaring_repositories.html // for more information about repositories. + maven { url "https://jitpack.io" } } dependencies { // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + mappings "com.github.redlime:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. diff --git a/gradle.properties b/gradle.properties index 56a7e1ce..d1a1a513 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/versions.html minecraft_version=1.16.1 minecraft_version_code=1.16.1 -yarn_mappings=1.16.1+build.21 +yarn_mappings=1.16.1.build.19 loader_version=0.14.25 # Mod Properties diff --git a/src/main/java/com/redlimerl/speedrunigt/mixins/MinecraftClientMixin.java b/src/main/java/com/redlimerl/speedrunigt/mixins/MinecraftClientMixin.java index 50b5032d..5659c955 100644 --- a/src/main/java/com/redlimerl/speedrunigt/mixins/MinecraftClientMixin.java +++ b/src/main/java/com/redlimerl/speedrunigt/mixins/MinecraftClientMixin.java @@ -72,7 +72,7 @@ public abstract class MinecraftClientMixin { @Shadow @Final private Window window; private boolean disconnectCheck = false; - @Inject(at = @At("HEAD"), method = "method_29607(Ljava/lang/String;Lnet/minecraft/world/level/LevelInfo;Lnet/minecraft/util/registry/RegistryTracker$Modifiable;Lnet/minecraft/world/gen/GeneratorOptions;)V") + @Inject(at = @At("HEAD"), method = "createWorld") public void onCreate(String worldName, LevelInfo levelInfo, RegistryTracker.Modifiable registryTracker, GeneratorOptions generatorOptions, CallbackInfo ci) { RunCategory category = SpeedRunOption.getOption(SpeedRunOptions.TIMER_CATEGORY); if (category.isAutoStart()) InGameTimer.start(worldName, RunType.fromBoolean(InGameTimerUtils.IS_SET_SEED)); From 56b2c871148d7ab639897cf8ced143e6d48ec90c Mon Sep 17 00:00:00 2001 From: tildejustin Date: Mon, 8 Jan 2024 15:37:27 -0500 Subject: [PATCH 3/4] optimize translation loading impl (fixes quilt incompatibility) --- .../translate/TranslationStorageMixin.java | 12 +++++-- .../speedrunigt/utils/TranslateHelper.java | 31 ------------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/redlimerl/speedrunigt/mixins/translate/TranslationStorageMixin.java b/src/main/java/com/redlimerl/speedrunigt/mixins/translate/TranslationStorageMixin.java index 4995c47b..916d02fc 100644 --- a/src/main/java/com/redlimerl/speedrunigt/mixins/translate/TranslationStorageMixin.java +++ b/src/main/java/com/redlimerl/speedrunigt/mixins/translate/TranslationStorageMixin.java @@ -2,9 +2,10 @@ import com.redlimerl.speedrunigt.option.SpeedRunOption; import com.redlimerl.speedrunigt.option.SpeedRunOptions; -import com.redlimerl.speedrunigt.utils.TranslateHelper; +import com.redlimerl.speedrunigt.utils.ResourcesHelper; import net.minecraft.client.resource.language.TranslationStorage; import net.minecraft.resource.Resource; +import net.minecraft.util.Language; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -12,12 +13,19 @@ import java.util.List; import java.util.Map; +import java.util.Optional; @Mixin(TranslationStorage.class) public class TranslationStorageMixin { @Inject(method = "load(Ljava/util/List;Ljava/util/Map;)V", at = @At("RETURN")) private static void onLoad(List resources, Map translationMap, CallbackInfo ci) { - TranslateHelper.setup(resources, translationMap::put, SpeedRunOption.getOption(SpeedRunOptions.ALWAYS_ENGLISH_TRANSLATIONS)); + resources.forEach(resource -> { + // minecraft always loads en_us as a backup, if using only english translations just skip loading the other attempts + if (SpeedRunOption.getOption(SpeedRunOptions.ALWAYS_ENGLISH_TRANSLATIONS) && !resource.getId().getPath().equalsIgnoreCase("lang/en_us.json")) + return; + Optional.ofNullable(ResourcesHelper.toStream("/assets/speedrunigt/" + resource.getId().getPath())) + .ifPresent(langStream -> Language.load(langStream, translationMap::put)); + }); } } diff --git a/src/main/java/com/redlimerl/speedrunigt/utils/TranslateHelper.java b/src/main/java/com/redlimerl/speedrunigt/utils/TranslateHelper.java index 7f0901d3..10787569 100644 --- a/src/main/java/com/redlimerl/speedrunigt/utils/TranslateHelper.java +++ b/src/main/java/com/redlimerl/speedrunigt/utils/TranslateHelper.java @@ -1,39 +1,8 @@ package com.redlimerl.speedrunigt.utils; import net.minecraft.client.MinecraftClient; -import net.minecraft.resource.Resource; -import net.minecraft.util.Language; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URISyntaxException; -import java.util.List; -import java.util.function.BiConsumer; public class TranslateHelper { - public static String[] getLangFileNames() throws IOException, URISyntaxException { - return ResourcesHelper.getResourceChildren("lang"); - } - - public static void setup(List resources, BiConsumer biConsumer, boolean englishOnly) { - try { - for (String langFileName : getLangFileNames()) { - if (englishOnly && !langFileName.endsWith("en_us.json")) continue; - - for (Resource resource : resources) { - if (!langFileName.endsWith(resource.getId().getPath())) continue; - - InputStream inputStream = TranslateHelper.class.getResourceAsStream(langFileName); - if (inputStream != null) { - Language.load(inputStream, biConsumer); - } - } - } - } catch (IOException | URISyntaxException e) { - e.printStackTrace(); - } - } - public static void reload() { MinecraftClient.getInstance().reloadResources(); } From ce84691459a354129a1dc1e9a07b2261beb5a58a Mon Sep 17 00:00:00 2001 From: tildejustin Date: Mon, 8 Jan 2024 15:37:38 -0500 Subject: [PATCH 4/4] move translation files to their proper location --- src/main/resources/{ => assets/speedrunigt}/lang/ar_sa.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/bg_bg.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/de_de.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/en_us.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/es_es.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/fi_fi.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/fil_ph.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/fr_fr.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/he_il.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/is_is.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/it_it.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/ja_jp.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/ko_kr.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/lol_us.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/pl_pl.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/pt_br.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/ru_ru.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/sv_se.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/tok.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/tr_tr.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/uk_ua.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/vi_vn.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/zh_cn.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/zh_hk.json | 0 src/main/resources/{ => assets/speedrunigt}/lang/zh_tw.json | 0 25 files changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/{ => assets/speedrunigt}/lang/ar_sa.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/bg_bg.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/de_de.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/en_us.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/es_es.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/fi_fi.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/fil_ph.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/fr_fr.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/he_il.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/is_is.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/it_it.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/ja_jp.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/ko_kr.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/lol_us.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/pl_pl.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/pt_br.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/ru_ru.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/sv_se.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/tok.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/tr_tr.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/uk_ua.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/vi_vn.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/zh_cn.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/zh_hk.json (100%) rename src/main/resources/{ => assets/speedrunigt}/lang/zh_tw.json (100%) diff --git a/src/main/resources/lang/ar_sa.json b/src/main/resources/assets/speedrunigt/lang/ar_sa.json similarity index 100% rename from src/main/resources/lang/ar_sa.json rename to src/main/resources/assets/speedrunigt/lang/ar_sa.json diff --git a/src/main/resources/lang/bg_bg.json b/src/main/resources/assets/speedrunigt/lang/bg_bg.json similarity index 100% rename from src/main/resources/lang/bg_bg.json rename to src/main/resources/assets/speedrunigt/lang/bg_bg.json diff --git a/src/main/resources/lang/de_de.json b/src/main/resources/assets/speedrunigt/lang/de_de.json similarity index 100% rename from src/main/resources/lang/de_de.json rename to src/main/resources/assets/speedrunigt/lang/de_de.json diff --git a/src/main/resources/lang/en_us.json b/src/main/resources/assets/speedrunigt/lang/en_us.json similarity index 100% rename from src/main/resources/lang/en_us.json rename to src/main/resources/assets/speedrunigt/lang/en_us.json diff --git a/src/main/resources/lang/es_es.json b/src/main/resources/assets/speedrunigt/lang/es_es.json similarity index 100% rename from src/main/resources/lang/es_es.json rename to src/main/resources/assets/speedrunigt/lang/es_es.json diff --git a/src/main/resources/lang/fi_fi.json b/src/main/resources/assets/speedrunigt/lang/fi_fi.json similarity index 100% rename from src/main/resources/lang/fi_fi.json rename to src/main/resources/assets/speedrunigt/lang/fi_fi.json diff --git a/src/main/resources/lang/fil_ph.json b/src/main/resources/assets/speedrunigt/lang/fil_ph.json similarity index 100% rename from src/main/resources/lang/fil_ph.json rename to src/main/resources/assets/speedrunigt/lang/fil_ph.json diff --git a/src/main/resources/lang/fr_fr.json b/src/main/resources/assets/speedrunigt/lang/fr_fr.json similarity index 100% rename from src/main/resources/lang/fr_fr.json rename to src/main/resources/assets/speedrunigt/lang/fr_fr.json diff --git a/src/main/resources/lang/he_il.json b/src/main/resources/assets/speedrunigt/lang/he_il.json similarity index 100% rename from src/main/resources/lang/he_il.json rename to src/main/resources/assets/speedrunigt/lang/he_il.json diff --git a/src/main/resources/lang/is_is.json b/src/main/resources/assets/speedrunigt/lang/is_is.json similarity index 100% rename from src/main/resources/lang/is_is.json rename to src/main/resources/assets/speedrunigt/lang/is_is.json diff --git a/src/main/resources/lang/it_it.json b/src/main/resources/assets/speedrunigt/lang/it_it.json similarity index 100% rename from src/main/resources/lang/it_it.json rename to src/main/resources/assets/speedrunigt/lang/it_it.json diff --git a/src/main/resources/lang/ja_jp.json b/src/main/resources/assets/speedrunigt/lang/ja_jp.json similarity index 100% rename from src/main/resources/lang/ja_jp.json rename to src/main/resources/assets/speedrunigt/lang/ja_jp.json diff --git a/src/main/resources/lang/ko_kr.json b/src/main/resources/assets/speedrunigt/lang/ko_kr.json similarity index 100% rename from src/main/resources/lang/ko_kr.json rename to src/main/resources/assets/speedrunigt/lang/ko_kr.json diff --git a/src/main/resources/lang/lol_us.json b/src/main/resources/assets/speedrunigt/lang/lol_us.json similarity index 100% rename from src/main/resources/lang/lol_us.json rename to src/main/resources/assets/speedrunigt/lang/lol_us.json diff --git a/src/main/resources/lang/pl_pl.json b/src/main/resources/assets/speedrunigt/lang/pl_pl.json similarity index 100% rename from src/main/resources/lang/pl_pl.json rename to src/main/resources/assets/speedrunigt/lang/pl_pl.json diff --git a/src/main/resources/lang/pt_br.json b/src/main/resources/assets/speedrunigt/lang/pt_br.json similarity index 100% rename from src/main/resources/lang/pt_br.json rename to src/main/resources/assets/speedrunigt/lang/pt_br.json diff --git a/src/main/resources/lang/ru_ru.json b/src/main/resources/assets/speedrunigt/lang/ru_ru.json similarity index 100% rename from src/main/resources/lang/ru_ru.json rename to src/main/resources/assets/speedrunigt/lang/ru_ru.json diff --git a/src/main/resources/lang/sv_se.json b/src/main/resources/assets/speedrunigt/lang/sv_se.json similarity index 100% rename from src/main/resources/lang/sv_se.json rename to src/main/resources/assets/speedrunigt/lang/sv_se.json diff --git a/src/main/resources/lang/tok.json b/src/main/resources/assets/speedrunigt/lang/tok.json similarity index 100% rename from src/main/resources/lang/tok.json rename to src/main/resources/assets/speedrunigt/lang/tok.json diff --git a/src/main/resources/lang/tr_tr.json b/src/main/resources/assets/speedrunigt/lang/tr_tr.json similarity index 100% rename from src/main/resources/lang/tr_tr.json rename to src/main/resources/assets/speedrunigt/lang/tr_tr.json diff --git a/src/main/resources/lang/uk_ua.json b/src/main/resources/assets/speedrunigt/lang/uk_ua.json similarity index 100% rename from src/main/resources/lang/uk_ua.json rename to src/main/resources/assets/speedrunigt/lang/uk_ua.json diff --git a/src/main/resources/lang/vi_vn.json b/src/main/resources/assets/speedrunigt/lang/vi_vn.json similarity index 100% rename from src/main/resources/lang/vi_vn.json rename to src/main/resources/assets/speedrunigt/lang/vi_vn.json diff --git a/src/main/resources/lang/zh_cn.json b/src/main/resources/assets/speedrunigt/lang/zh_cn.json similarity index 100% rename from src/main/resources/lang/zh_cn.json rename to src/main/resources/assets/speedrunigt/lang/zh_cn.json diff --git a/src/main/resources/lang/zh_hk.json b/src/main/resources/assets/speedrunigt/lang/zh_hk.json similarity index 100% rename from src/main/resources/lang/zh_hk.json rename to src/main/resources/assets/speedrunigt/lang/zh_hk.json diff --git a/src/main/resources/lang/zh_tw.json b/src/main/resources/assets/speedrunigt/lang/zh_tw.json similarity index 100% rename from src/main/resources/lang/zh_tw.json rename to src/main/resources/assets/speedrunigt/lang/zh_tw.json