diff --git a/build.gradle b/build.gradle index bb9fc8e84..42dee48aa 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 804823678..d1a1a513e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,8 +6,8 @@ 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 -loader_version=0.14.17 +yarn_mappings=1.16.1.build.19 +loader_version=0.14.25 # Mod Properties mod_version=14.0 diff --git a/src/main/java/com/redlimerl/speedrunigt/mixins/MinecraftClientMixin.java b/src/main/java/com/redlimerl/speedrunigt/mixins/MinecraftClientMixin.java index 50b5032d1..5659c9554 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)); 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 4995c47b0..916d02fc2 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 7f0901d3d..10787569e 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(); } 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 diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a0b0a43c2..82725310f 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}}" },