OrnitheMC / ornithe-standard-libraries

Apache License 2.0
6 stars 5 forks source link

Resource loader does not load alternate language formats #31

Closed crazysmc closed 2 months ago

crazysmc commented 2 months ago

From what I understand, it is intended that when lang/en_US.lang is not found, lang/en_US.lang, lang/en_us.lang, lang/en_us.json are tried as fallbacks.

I tried to load a lang/en_us.lang instead of lang/en_US.lang in Minecraft 1.10.2 but after getResources in Minecraft's TranslationStorage throws a FileNotFoundException, the this.load(list) call and its WrapOperation handler are skipped. Thus, no alternate paths are loaded.

net.minecraft.client.resource.language.TranslationStorage#load(net.minecraft.client.resource.manager.ResourceManager, java.util.List<java.lang.String>)

// ...
try {
  this.load(resourceManager.getResources(new Identifier(string3, string2)));
} catch (IOException var9) {
}

Also if a following getResources call in the mixin at https://github.com/OrnitheMC/ornithe-standard-libraries/blob/4264a82c7456a71607826237550655514d5704dd/libraries/resource-loader/resource-loader-mc13w26a-mc1.10.2/src/main/java/net/ornithemc/osl/resource/loader/impl/mixin/client/TranslationStorageMixin.java#L45-L50 throws an exception, the rest of the loop is skipped.

The same code appears in other version ranges of the resource-loader library.

As a workaround I could add empty lang/en_US.lang and lang/en_US.json files to my assets and then lang/en_us.lang will be loaded correctly, but I am afraid that this causes problems on case-insensitive filesystems.

SpaceWalkerRS commented 2 months ago

Thanks for the report! This is definitely a flaw in the implementation, it should check whether the resource exists before attempting to load it, or otherwise catch any exceptions for each individual call, so it can try the next path. I reckon this affects pretty much any version range of the Resource Loader...