Flywheel (Legacy)

Flywheel (Legacy)

40M Downloads

Failed to load PartialModel

Luncert opened this issue ยท 4 comments

commented

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

commented

FMLClientSetupEvent runs too late to initialize PartialModels. Call the init method like Create does, in the main mod class's constructor and guarded with a DistExecutor call.

commented

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 {
commented

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.

commented

Strange. I think Create loads the class earlier than the setup event which makes the init call useless. The Flywheel documentation in this case is also incorrect, and should say to use the mod class constructor. This will be fixed soon.