Lazily load models in data generators

Fixes #701 (well, hopefully). Our BlockModelProvider is created when
running other mods' data generators (thought not run), which causes
issues as none of the models are considered as "existing files".
This commit is contained in:
Jonathan Coates 2021-02-13 13:02:24 +00:00
parent 975a994581
commit 1825f67eee
1 changed files with 5 additions and 4 deletions

View File

@ -21,14 +21,12 @@
public class BlockModelProvider extends BlockStateProvider
{
private final ModelFile monitorBase;
private final ModelFile orientable;
private ModelFile monitorBase;
private ModelFile orientable;
public BlockModelProvider( DataGenerator generator, ExistingFileHelper existingFileHelper )
{
super( generator, ComputerCraft.MOD_ID, existingFileHelper );
monitorBase = models().getExistingFile( new ResourceLocation( ComputerCraft.MOD_ID, "block/monitor_base" ) );
orientable = models().getExistingFile( new ResourceLocation( "block/orientable" ) );
}
@Nonnull
@ -41,6 +39,9 @@ public String getName()
@Override
protected void registerStatesAndModels()
{
monitorBase = models().getExistingFile( new ResourceLocation( ComputerCraft.MOD_ID, "block/monitor_base" ) );
orientable = models().getExistingFile( new ResourceLocation( "block/orientable" ) );
registerMonitors( Registry.ModBlocks.MONITOR_NORMAL.get() );
registerMonitors( Registry.ModBlocks.MONITOR_ADVANCED.get() );