Failed to load PartialModel
Luncert opened this issue ยท 4 comments
Describe the Bug
I created a FMLClientSetupEvent listener used to create partial model and got following exception:
PartialModel 'robotcontraption:block/shaft_half' loaded after ModelRegistryEvent
.
I checked mod loading order:
[[dependencies.robotcontraption]]
modId="flywheel"
mandatory=true
versionRange="[1.18-0.6.2,)"
ordering="AFTER"
side="CLIENT"
This is how I register the event listener:
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
modEventBus.addListener(EventPriority.HIGHEST, RobotContraption::clientInit);
});
public static void clientInit(final FMLClientSetupEvent event) {
RCBlockPartials.init();
}
Is there anything else I missed to enable flywheel?
Reproduction Steps
1.Clone from Repo
2.Run
...
Expected Result
My custom partial model should be loaded without crash.
Screenshots and Videos
No response
Crash Report or Log
No response
Operating System
Win11
What is your GPU?
GeForce RTX3600
Mod Version
0.6.4
Minecraft Version
1.18.1
Loader Version
Forge 40
Other Mods
No response
Additional Context
No response
FMLClientSetupEvent
runs too late to initialize PartialModel
s. Call the init method like Create does, in the main mod class's constructor and guarded with a DistExecutor
call.
Create also loads the model during FMLClientSetupEvent
, and the documentation said that as well...
/**
* A helper class for loading and accessing json models.
* <br>
* Creating a PartialModel will make the associated modelLocation automatically load.
* PartialModels must be initialized during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent FMLClientSetupEvent}.
* <br>
* Once {@link ModelBakeEvent} finishes, all PartialModels (with valid modelLocations)
* will have their bakedModel fields populated.
* <br>
* Attempting to create a PartialModel after ModelRegistryEvent will cause an error.
*/
public class PartialModel {
Create loads its partial models inside Forge event handling. For me it doesn't work and loading the models in main mod class constructor directly is the way... thanks to SteamPowered.