Ost Overhaul

Ost Overhaul

47.2k Downloads

Breaks other mods with custom biome music

unascribed opened this issue ยท 1 comments

commented

registerDataStuff in OstOverhaul attempts to register every sound event defined in the configuration file. As OstOverhaul scans the biome registry to generate its default config, this means that if it loads before another mod (e.g. because the mod's name starts with y) then it will prematurely register the mod's sounds, causing a very confusing explosion later on once that mod tries to register its own sounds.

There is a check in the registration loop for if the sound is already registered, but since your mod may load before others, this is insufficient.

Relevant stack traces from a debugger I wrote due to someone having this issue (which was nearly impossible to trace back to this mod, by the way):

[23:43:00] [Render thread/ERROR]: Could not register yttr:memorandum in minecraft:sound_event from MEMORANDUM - current registration: 1343 yttr:memorandum SoundEvent[yttr:memorandum]@7ff9aeb3 - we wanted to register SoundEvent[yttr:memorandum]@5ceeb7
java.lang.RuntimeException: Attempted to register ID ResourceKey[minecraft:sound_event / yttr:memorandum] at different raw IDs (-1, 1421)! If you're trying to override an item, use .set(), not .register()!
	at Not Enough Crashes deobfuscated stack trace.(1.18.2+build.4) ~[?:?]
	at net.minecraft.util.registry.SimpleRegistry.handler$caf000$setPre(SimpleRegistry:1160) ~[?:?]
	at net.minecraft.util.registry.SimpleRegistry.set(SimpleRegistry) ~[?:?]
	at net.minecraft.util.registry.SimpleRegistry.set(SimpleRegistry:86) ~[?:?]
	at net.minecraft.util.registry.SimpleRegistry.add(SimpleRegistry:134) ~[?:?]
	at net.minecraft.util.registry.Registry.register(Registry:471) ~[?:?]
	at net.minecraft.util.registry.Registry.register(Registry:467) ~[?:?]
	at com.unascribed.yttr.Yttr.lambda$autoRegister$9(Yttr.java:354) ~[yttr-6.537-dirty.jar:?]
	at com.unascribed.yttr.Yttr.eachRegisterableField(Yttr.java:336) ~[yttr-6.537-dirty.jar:?]
	at com.unascribed.yttr.Yttr.autoRegister(Yttr.java:351) ~[yttr-6.537-dirty.jar:?]
	at com.unascribed.yttr.init.YSounds.init(YSounds.java:131) ~[yttr-6.537-dirty.jar:?]
	at com.unascribed.yttr.Yttr.onInitialize(Yttr.java:185) ~[yttr-6.537-dirty.jar:?]
	at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:47) ~[fabric-loader-0.14.8.jar:?]
	at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke(EntrypointUtils.java:35) ~[fabric-loader-0.14.8.jar:?]
	at net.fabricmc.loader.impl.game.minecraft.Hooks.startClient(Hooks.java:52) ~[fabric-loader-0.14.8.jar:?]
	at fudge.notenoughcrashes.fabric.mixinhandlers.ModLoaders.fabricEntrypoints(ModLoaders.java:9) ~[notenoughcrashes-4.1.6+1.18.2-fabric.jar:?]
	at net.minecraft.client.MinecraftClient.redirect$cpl000$catchFabricInit(MinecraftClient:15453) ~[?:?]
	at net.minecraft.client.MinecraftClient.<init>(MinecraftClient:452) ~[?:?]
	at net.minecraft.client.main.Main.main(Main:197) [client-intermediary.jar:?]
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:461) [fabric-loader-0.14.8.jar:?]
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) [fabric-loader-0.14.8.jar:?]
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) [fabric-loader-0.14.8.jar:?]
	at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:577) ~[?:?]
	at org.multimc.impl.OneSixLauncher.invokeMain(OneSixLauncher.java:104) [NewLaunch.jar:?]
	at org.multimc.impl.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:175) [NewLaunch.jar:?]
	at org.multimc.impl.OneSixLauncher.launch(OneSixLauncher.java:185) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.listen(EntryPoint.java:127) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.main(EntryPoint.java:57) [NewLaunch.jar:?]
[23:43:00] [Render thread/ERROR]: The interloper's registration stack trace is:
java.lang.Throwable: Object was constructed here
	at Not Enough Crashes deobfuscated stack trace.(1.18.2+build.4) ~[?:?]
	at net.minecraft.sound.SoundEvent.handler$dmf000$onConstruct(SoundEvent:521) ~[?:?]
	at net.minecraft.sound.SoundEvent.<init>(SoundEvent:13) ~[?:?]
	at glowsand.ostoverhaul.OstOverhaul.registerDataStuff(OstOverhaul.java:151) ~[ostOverhaul-0.2.5-1.18.2.jar:?]
	at glowsand.ostoverhaul.OstOverhaul.readDataStuff(OstOverhaul.java:139) ~[ostOverhaul-0.2.5-1.18.2.jar:?]
	at glowsand.ostoverhaul.OstOverhaul.onInitialize(OstOverhaul.java:55) ~[ostOverhaul-0.2.5-1.18.2.jar:?]
	at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:47) ~[fabric-loader-0.14.8.jar:?]
	at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke(EntrypointUtils.java:35) ~[fabric-loader-0.14.8.jar:?]
	at net.fabricmc.loader.impl.game.minecraft.Hooks.startClient(Hooks.java:52) ~[fabric-loader-0.14.8.jar:?]
	at fudge.notenoughcrashes.fabric.mixinhandlers.ModLoaders.fabricEntrypoints(ModLoaders.java:9) ~[notenoughcrashes-4.1.6+1.18.2-fabric.jar:?]
	at net.minecraft.client.MinecraftClient.redirect$cpl000$catchFabricInit(MinecraftClient:15453) ~[?:?]
	at net.minecraft.client.MinecraftClient.<init>(MinecraftClient:452) ~[?:?]
	at net.minecraft.client.main.Main.main(Main:197) [client-intermediary.jar:?]
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:461) [fabric-loader-0.14.8.jar:?]
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) [fabric-loader-0.14.8.jar:?]
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) [fabric-loader-0.14.8.jar:?]
	at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:577) ~[?:?]
	at org.multimc.impl.OneSixLauncher.invokeMain(OneSixLauncher.java:104) [NewLaunch.jar:?]
	at org.multimc.impl.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:175) [NewLaunch.jar:?]
	at org.multimc.impl.OneSixLauncher.launch(OneSixLauncher.java:185) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.listen(EntryPoint.java:127) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.main(EntryPoint.java:57) [NewLaunch.jar:?]
[23:43:00] [Render thread/ERROR]: Our registration stack trace is:
java.lang.Throwable: Object was constructed here
	at Not Enough Crashes deobfuscated stack trace.(1.18.2+build.4) ~[?:?]
	at net.minecraft.sound.SoundEvent.handler$dmf000$onConstruct(SoundEvent:521) ~[?:?]
	at net.minecraft.sound.SoundEvent.<init>(SoundEvent:13) ~[?:?]
	at com.unascribed.yttr.init.YSounds.create(YSounds.java:135) ~[yttr-6.537-dirty.jar:?]
	at com.unascribed.yttr.init.YSounds.<clinit>(YSounds.java:82) ~[yttr-6.537-dirty.jar:?]
	at com.unascribed.yttr.init.YBlocks.<clinit>(YBlocks.java:130) ~[yttr-6.537-dirty.jar:?]
	at net.minecraft.world.gen.surfacebuilder.VanillaSurfaceRules.localvar$eci000$modifyDirtRule(VanillaSurfaceRules:524) ~[?:?]
	at net.minecraft.world.gen.surfacebuilder.VanillaSurfaceRules.createDefaultRule(VanillaSurfaceRules:193) ~[?:?]
	at net.minecraft.world.gen.surfacebuilder.VanillaSurfaceRules.createOverworldSurfaceRule(VanillaSurfaceRules:64) ~[?:?]
	at net.minecraft.world.gen.chunk.ChunkGeneratorSettings.createSurfaceSettings(ChunkGeneratorSettings:131) ~[?:?]
	at net.minecraft.world.gen.chunk.ChunkGeneratorSettings.<clinit>(ChunkGeneratorSettings:81) ~[?:?]
	at net.minecraft.util.registry.BuiltinRegistries.method_30566(BuiltinRegistries:86) ~[?:?]
	at java.util.LinkedHashMap.forEach(LinkedHashMap.java:721) ~[?:?]
	at net.minecraft.util.registry.BuiltinRegistries.<clinit>(BuiltinRegistries:85) ~[?:?]
	at net.minecraft.util.registry.Registry.<clinit>(Registry:291) ~[?:?]
	at net.minecraft.Bootstrap.initialize(Bootstrap:49) ~[?:?]
	at net.minecraft.client.main.Main.main(Main:153) [client-intermediary.jar:?]
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:461) [fabric-loader-0.14.8.jar:?]
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) [fabric-loader-0.14.8.jar:?]
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) [fabric-loader-0.14.8.jar:?]
	at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:577) ~[?:?]
	at org.multimc.impl.OneSixLauncher.invokeMain(OneSixLauncher.java:104) [NewLaunch.jar:?]
	at org.multimc.impl.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:175) [NewLaunch.jar:?]
	at org.multimc.impl.OneSixLauncher.launch(OneSixLauncher.java:185) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.listen(EntryPoint.java:127) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.main(EntryPoint.java:57) [NewLaunch.jar:?]
[23:43:00] [Render thread/ERROR]: Dazed and confused, but trying to continue...

My source is at https://git.sleeping.town/unascribed/Yttr if you'd like to reference it. It's normal SoundEvent/Biome registration with a layer of reflection in between for convenience.


Fabric lacks a proper "post-init" entrypoint like Forge, but you can work around this due to the fact the server and client entrypoints run after main. Yttr uses this to implement its own "postInit" psuedo-entrypoint:

https://git.sleeping.town/unascribed/Yttr/src/branch/1.18.2/src/main/resources/fabric.mod.json#L21-L22

https://git.sleeping.town/unascribed/Yttr/src/branch/1.18.2/src/main/java/com/unascribed/yttr/YttrServer.java

https://git.sleeping.town/unascribed/Yttr/src/branch/1.18.2/src/main/java/com/unascribed/yttr/client/YttrClient.java#L156

I suggest moving your registration to such a method.

commented

Thank you so much for letting me know of this honestly surprised no else caught it earlier

This should be fixed on 0.2.6 which you can get here:
Modrinth
Curseforge