Tinkers' Mechworks

Tinkers' Mechworks

18M Downloads

1.14.4: The special model bake event doesn't handle models without variant

raoulvdberge opened this issue ยท 2 comments

commented

Models loaded with ModelLoader.addSpecialModel can have no variant if passing a ResourceLocation instead of ModelResourceLocation. I think the ModelBakeEventListener needs to handle this?

The Forge docs say:

    /*
     * @param rl The model, either {@link ModelResourceLocation} to point to a blockstate variant,
     *           or plain {@link ResourceLocation} to point directly to a json in the models folder. */
    public static void addSpecialModel(ResourceLocation rl) {

Here, you are assuming the registry contains a ModelResourceLocation by checking for #:

https://github.com/SlimeKnights/TinkersMechworks/blob/1.14/src/main/java/slimeknights/tmechworks/common/event/ModelBakeEventListener.java#L39

It's currently crashing with Refined Storage because we're using the special model system.

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(Unknown Source) ~[?:1.8.0_221] {}
	at slimeknights.tmechworks.common.event.ModelBakeEventListener.onModelBake(ModelBakeEventListener.java:39) ~[?:1.14.4-2.0-beta2] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraftforge.eventbus.ASMEventHandler_307_ModelBakeEventListener_onModelBake_ModelBakeEvent.invoke(.dynamic) ~[?:?] {}
	at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80) ~[eventbus-1.0.0-service.jar:?] {}
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258) ~[eventbus-1.0.0-service.jar:?] {}
	at net.minecraftforge.fml.javafmlmod.FMLModContainer.acceptEvent(FMLModContainer.java:168) ~[?:28.1] {re:classloading}
	at net.minecraftforge.fml.ModLoader.lambda$postEvent$30(ModLoader.java:241) ~[?:?] {re:classloading}
	at java.util.HashMap.forEach(Unknown Source) ~[?:1.8.0_221] {}
	at net.minecraftforge.fml.ModList.forEachModContainer(ModList.java:217) ~[?:?] {re:classloading}
	at net.minecraftforge.fml.ModLoader.postEvent(ModLoader.java:241) ~[?:?] {re:classloading}
	at net.minecraftforge.client.ForgeHooksClient.onModelBake(ForgeHooksClient.java:363) ~[?:?] {re:classloading}
	at net.minecraft.client.renderer.model.ModelManager.func_212853_a_(ModelManager.java:58) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.model.ModelManager.func_212853_a_(ModelManager.java:17) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.resources.ReloadListener.func_215269_a(SourceFile:13) ~[?:?] {re:classloading}
	at java.util.concurrent.CompletableFuture.uniAccept(Unknown Source) ~[?:1.8.0_221] {}
	at java.util.concurrent.CompletableFuture$UniAccept.tryFire(Unknown Source) ~[?:1.8.0_221] {}
	at java.util.concurrent.CompletableFuture$Completion.run(Unknown Source) ~[?:1.8.0_221] {}
	at net.minecraft.resources.AsyncReloader.func_219557_a(SourceFile:71) ~[?:?] {re:classloading}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213166_h(SourceFile:144) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.util.concurrent.RecursiveEventLoop.func_213166_h(SourceFile:23) ~[?:?] {re:classloading}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213168_p(SourceFile:118) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213160_bf(SourceFile:103) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:861) ~[?:?] {re:classloading,pl:accesstransformer:B,xf:fml:randompatches:RandomPatches Minecraft Transformer,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:384) ~[?:?] {re:classloading,pl:accesstransformer:B,xf:fml:randompatches:RandomPatches Minecraft Transformer,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(SourceFile:155) ~[1.14.4.jar:?] {re:classloading}
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] {}
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] {}
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] {}
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_221] {}
	at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:56) ~[forge-1.14.4-28.1.44.jar:28.1] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-4.0.0.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-4.0.0.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-4.0.0.jar:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-4.0.0.jar:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-4.0.0.jar:?] {}
commented

Thank you for the quickfix, that fixed it.

commented

Fixed, please try with v2.0-beta.3