Jump to content

[1.16.3]BlockStateProvider


Mightydanp

Recommended Posts

I am trying to generate items models and block states.
I am having problems with my blockstateprovider not passing in debug
here is my eventhandler
https://github.com/mightydanp/IndustrialTech/blob/master/src/main/java/mightydanp/industrialtech/api/common/handler/DataGenEventHandler.java
i put a breaking point on 34 https://github.com/mightydanp/IndustrialTech/blob/master/src/main/java/mightydanp/industrialtech/api/common/datagen/BlockStates.java#L34
but it doesnt pass it.


. i am trying to get my blockstates to look like so

{
  "variants": {
    "": {"model": "industrialtech:block/ore/stone_normal_ore"}
  }
}

and my item modes to look like so 

{
   "parent": "industrialtech:block/ore/stone_normal_ore",
   "display": {
        "gui": {
            "rotation": [ 30, 225, 0 ],
            "translation": [ 0, 0, 0],
            "scale":[ 0.625, 0.625, 0.625 ]
        },
        "ground": {
            "rotation": [ 0, 0, 0 ],
            "translation": [ 0, 3, 0],
            "scale":[ 0.25, 0.25, 0.25 ]
        },
        "fixed": {
            "rotation": [ 0, 0, 0 ],
            "translation": [ 0, 0, 0],
            "scale":[ 0.5, 0.5, 0.5 ]
        },
        "thirdperson_righthand": {
            "rotation": [ 75, 45, 0 ],
            "translation": [ 0, 2.5, 0],
            "scale": [ 0.375, 0.375, 0.375 ]
        },
        "firstperson_righthand": {
            "rotation": [ 0, 45, 0 ],
            "translation": [ 0, 0, 0 ],
            "scale": [ 0.40, 0.40, 0.40 ]
        },
        "firstperson_lefthand": {
            "rotation": [ 0, 225, 0 ],
            "translation": [ 0, 0, 0 ],
            "scale": [ 0.40, 0.40, 0.40 ]
        }
    }
}

 

Edited by Mightydanp
Link to comment
Share on other sites

This code looks problematic for a number of reasons:

For one, I don't see how the event will run.

Two, do you have the build.gradle setup?

Three, you're using unchecked model files meaning you don't have anything really set up correctly.

Four, don't iterate through an entire block list if you're just looking for a specific case.

Five, I think you need to review how the builder works.

Six, there's already a simple block state provider that will generate the required block.

Seven, you never generate an item for the block.

 

Link to comment
Share on other sites

1. When i put a debug point  on line 22 it gets cause but a debug point on line 34 https://github.com/mightydanp/IndustrialTech/blob/master/src/main/java/mightydanp/industrialtech/api/common/datagen/BlockStates.java#L34  doesnt catch. So what do you mean by that.

2. It is set up here on line 63

https://github.com/mightydanp/IndustrialTech/blob/master/build.gradle#L63

3.it was the onlything i could find inside modelfile that i though would mean get model by adress. Alot of the other just say parent

4. The only reason why im going throw a full list is because i dong want to make 114 lines of code of (matertialHandlerHelper)

5.i have no idea how the builder works most tutorials just throw there version of code at you without explaining what they did.

6. Thank you i didnt know that

7.i was just trying to get the block to generate. You can get the item to generate in the blockstate class ?

Link to comment
Share on other sites

4 minutes ago, Mightydanp said:

doesnt catch.

If a line of code never gets caught by a breakpoint, it means that it's either never called from either no entries or not registering the event.

5 minutes ago, Mightydanp said:

that i though would mean get model by adress. Alot of the other just say parent

Yes. You can give a model a parent that it will borrow a structure from. Most blocks parent block/block if anything.

6 minutes ago, Mightydanp said:

The only reason why im going throw a full list is because i dong want to make 114 lines of code of

Fair enough.

6 minutes ago, Mightydanp said:

i have no idea how the builder works most tutorials just throw there version of code at you without explaining what they did.

Here's a list of every method documented in states/models.

8 minutes ago, Mightydanp said:

You can get the item to generate in the blockstate class

That's what you need to do. The block state provider gives you the ability to create a state parser, block model, and item model from the class. Otherwise, it will most likely throw an error if you make a separate item model provider.

Link to comment
Share on other sites

@Mod.EventBusSubscriber(bus = Bus.MOD)
public class DataGenEventHandler {
    @SubscribeEvent
    public static void gatherData(GatherDataEvent event) {
        DataGenerator gen = event.getGenerator();

        if (event.includeClient())
        {
            gen.addProvider(new BlockStates(gen, event.getExistingFileHelper()));
        }
        if (event.includeServer()){
        }
    }
}

i have it set up like so
also what in modelfile  do i use use existing model i dont really need to use a parent in my blockstate

Link to comment
Share on other sites

And I quote from the EventBusSubscriber javadocs for the modid parameter 'only necessary if this annotation is not on the same class that has a @Mod annotation.'

5 minutes ago, Mightydanp said:

do i use use existing model

You should always use existing model.

5 minutes ago, Mightydanp said:

i dont really need to use a parent in my blockstate

The parent is for your block model, not the block state. Which reminds me, you don't ever show what you want your block model to look like.

Link to comment
Share on other sites

so now i have 

for(RegistryObject<Block> blockRegistered : material.blockOre) {
    Block oreBlock = blockRegistered.get();
    VariantBlockStateBuilder builder = getVariantBuilder(oreBlock);
    String modId = oreBlock.getRegistryName().toString().split(":")[0];
    String oreName = oreBlock.getRegistryName().toString().split(":")[1];
    String stoneVariant = oreBlock.getRegistryName().toString().split(":")[1].split("_")[0];
    ModelFile ore = models().withExistingParent(oreName, "block/ore/" + stoneVariant + "_ore");
    builder.forAllStates(state -> ConfiguredModel.builder().modelFile(ore).build());
    simpleBlock(oreBlock , ore);
    simpleBlockItem(oreBlock, ore);
}

also i have 

@Mod.EventBusSubscriber(bus = Bus.MOD)

because its outside the main mod class that has @Mod

i put a line 
BlockStates class on line 29 and the breaking point hits but its not hitting inside registerStatesAndModels

Edited by Mightydanp
Link to comment
Share on other sites

rebuilding runs fix the problem 
my only problem atm is i have a 
IndustrialTech\src\main\resources\assets\industrialtech\models\block\ore\stone_ore.json

and i get Caused by: java.lang.IllegalStateException: Model at industrialtech:block/ore/stone_ore does not exist

 

i have it setup like so 

ModelFile ore = models().withExistingParent(oreName, modId + ":block/ore/" + stoneVariant + "_ore");

i have 
 

data {
            workingDirectory project.file('run')

            // Recommended logging data for a userdev environment
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            // Recommended logging level for the console
            property 'forge.logging.console.level', 'debug'

            args '--mod', 'industrialtech', '--all', '--output', file('src/generated/resources/')

            mods {
                industrialtech {
                    source sourceSets.main
                }
            }
        }

 

Edited by Mightydanp
Link to comment
Share on other sites

7 minutes ago, Mightydanp said:

src/main/resources/industrialcraft

That is within 'src/main/resources'. I was saying for generated files it wouldn't be counted as they are saved to 'src/generated/resources' as specified in your code above which is not within 'main/resources'.

Edited by ChampionAsh5357
Link to comment
Share on other sites

sweet i got it to find my file but i get a crash on line 51 so i am doing something wrong

 https://github.com/mightydanp/IndustrialTech/blob/master/src/main/java/mightydanp/industrialtech/api/common/datagen/BlockStates.java#L51
 

[23:13:38] [main/INFO] [minecraft/DataGenerator]: Starting provider: Block States: industrialtech
Exception in thread "main" [23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
[23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:39)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at cpw.mods.modlauncher.Launcher.run(Launcher.java:81)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at cpw.mods.modlauncher.Launcher.main(Launcher.java:65)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: Caused by: java.lang.reflect.InvocationTargetException
[23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: 	at java.lang.reflect.Method.invoke(Method.java:498)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: 	at net.minecraftforge.userdev.FMLUserdevDataLaunchProvider.lambda$launchService$0(FMLUserdevDataLaunchProvider.java:51)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: 	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: 	... 5 more
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: Caused by: java.lang.IllegalArgumentException: Cannot set models for a state that has already been configured: 
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:191)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at net.minecraftforge.client.model.generators.VariantBlockStateBuilder.setModels(VariantBlockStateBuilder.java:146)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at net.minecraftforge.client.model.generators.VariantBlockStateBuilder$PartialBlockstate.setModels(VariantBlockStateBuilder.java:249)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at net.minecraftforge.client.model.generators.BlockStateProvider.simpleBlock(BlockStateProvider.java:193)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at net.minecraftforge.client.model.generators.BlockStateProvider.simpleBlock(BlockStateProvider.java:184)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at mightydanp.industrialtech.api.common.datagen.BlockStates.materialHandlerHelper(BlockStates.java:51)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at mightydanp.industrialtech.api.common.datagen.BlockStates.registerStatesAndModels(BlockStates.java:36)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at net.minecraftforge.client.model.generators.BlockStateProvider.act(BlockStateProvider.java:108)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at net.minecraft.data.DataGenerator.run(DataGenerator.java:53)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at net.minecraftforge.fml.event.lifecycle.GatherDataEvent$DataGeneratorConfig.lambda$runAll$0(GatherDataEvent.java:111)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at cpw.mods.modlauncher.api.LamdbaExceptionUtils.lambda$rethrowConsumer$0(LamdbaExceptionUtils.java:34)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at java.util.HashMap$Values.forEach(HashMap.java:980)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at net.minecraftforge.fml.event.lifecycle.GatherDataEvent$DataGeneratorConfig.runAll(GatherDataEvent.java:107)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at net.minecraftforge.fml.DatagenModLoader.begin(DatagenModLoader.java:51)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	at net.minecraft.data.Main.main(Main.java:41)
[23:14:00] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: 	... 11 more
Disconnected from the target VM, address: '127.0.0.1:12041', transport: 'socket'

Process finished with exit code 1

 

Edited by Mightydanp
Link to comment
Share on other sites

i just figured that out. i got it to generate almost all files correctly it generates a \industrialtech\models\block\ore\andesite_ore.json aswell for some reason that i dont know. What part of my could do i chance to generate a model file for andesite_ore.

Also is there not a way to get models/item instead of generating everyting there generate it in models/items/ore? atm i dont know how to classify where the resource location is for a block or item

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.