Posted December 2, 20222 yr So I am trying to generate crop blockstate.json files by using BlockStateProvider. I'm not finding a method in the class handling crops. I guess it has to be done with the VariantBuilder from getVariantBuilder(BLOCK).forAllStates(state -> ...), from what I understand the function takes returns ConfiguredModel[] but how I am supposed to add definitions for each variant? Documentation is not very clear, can someone briefly explain how does this work. I'm using Forge 40.1.86 for 1.18.2. Generated JSON's should look like this: { "variants": { "age=0": { "model": "examplemod:block/example_crop_stage0" }, "age=1": { "model": "examplemod:block/example_crop_stage0" }, "age=2": { "model": "examplemod:block/example_crop_stage1" }, "age=3": { "model": "examplemod:block/example_crop_stage1" }, "age=4": { "model": "examplemod:block/example_crop_stage2" }, "age=5": { "model": "examplemod:block/example_crop_stage2" }, "age=6": { "model": "examplemod:block/example_crop_stage2" }, "age=7": { "model": "examplemod:block/example_crop_stage3" } } }
December 2, 20222 yr 27 minutes ago, Darkorg69 said: Documentation is not very clear, can someone briefly explain how does this work. Could you please show what you currently have and explain what is unclear about the documentation?
December 2, 20222 yr Author It's my bad I forgot about the online docs, I meant there was not enough documentation in the IDE when looking through the classes. I got it to work now. public class ModBlockStateProvider extends BlockStateProvider { public ModBlockStateProvider(DataGenerator gen, String modid, ExistingFileHelper exFileHelper) { super(gen, modid, exFileHelper); } @Override protected void registerStatesAndModels() { addCropBlock(ModBlocks.TOMATOES.get()); } public void addCropBlock(Block pBlock) { this.getVariantBuilder(pBlock) .forAllStates(state -> ConfiguredModel.builder() .modelFile( models().getExistingFile( modLoc(pBlock.getRegistryName().getPath() + "_stage" + state.getValue(((CropBlock) pBlock).getAgeProperty())) ) ) .build() ); } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.