Jump to content

[1.15.2] Looking for StataMapper replacement


Rikka0_0

Recommended Posts

We may still need StataMappers or its replacement!

 

I'm dealing with blockstates including subtypes(int), facing(Direction) and status(Boolean). Removing subtypes is straightforward. Facing and status controls the appearance of the block. I decided to only keep facing and status in the blockstate, however I encoutered some problems.

 

In 1.12.2, my mod uses StataMapper extensively to avoid writing tons of json files (BlockState json) files and then redirect the loading of variants to my own loader.
In 1.15.2, the StataMapper has been removed and the hardcoded logic in ModelBakery::loadBlockstate(ResourceLocation) suggests that it only accepts JSON files! Which means I have to write a JSON Blockstate file for each block, flattening makes things worse as it increases the number of JSON files required.


I have three solutions, the first is to write a json blockstate file for each block, it points to a json model file, which then tell forge to use my own IModelLoader to load the model. Although it takes a lot of time, but it is still feasible.

The second is to add back the StateMapper, by the MinecraftForge Officials, it will take some effort but I definitely think it is worthwhile. I will be really appreciate if StateMapper is back!

The last one is to use IForgeTileEntity::getModelData, but some of my blocks don't have a tileEntity.

Edited by Rikka0_0

My mod: SimElectricity - High Voltages, Electrical Power Transmission & Distribution

https://github.com/RoyalAliceAcademyOfSciences/SimElectricity

Link to comment
Share on other sites

Hi

I agree with dieSieben, with some caveats:

My own rules of thumb:

The number of blocks should generally match the number of items

1) If you have a modest number of blocks that are present as different items (eg different colours of stone - let's say up to 64 or so), make a json for each one.  Keep the blockstates for placement or state (lit / not lit, waterlogged, etc) information only, as you said in your question

2) If you have a large variety of blocks (eg can be a wide range of colours), and this can be deduced from world information (eg like grass colour which uses a callback during rendering to determine the correct shade of green), then use a custom IBakedModel for your block rendering with IModelData (IForgeBakedModel::getModelData).  You can either use a custom loader, or you can find & replace with your custom IBakedModels during ModelBakeEvent.

3) Otherwise- (eg if your player is not able to hold all the different types of block in their hand and/or place them directly) - use a tileentity.

 

Generating a lot of json can be tedious, I've found Microsoft Excel spreadsheets to be very useful for that- don't even need macros, just formulae with lookups; copy/paste; then export as text.  Much faster!

 

-TGG

 

 

 

 

Link to comment
Share on other sites

You can use the Data Generator system to avoid writing blockstates/model files by hand.

 

There's a discussion of the system and some links to examples here:

 

 

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

2 hours ago, Choonster said:

You can use the Data Generator system to avoid writing blockstates/model files by hand.

 

There's a discussion of the system and some links to examples here:

 

 

How to invoke the DataGenerator? I launched the game, the GatherDataEvent is not fired by MinecraftForge.

https://wiki.mcjty.eu/modding/index.php?title=Tut15_Ep15

My mod: SimElectricity - High Voltages, Electrical Power Transmission & Distribution

https://github.com/RoyalAliceAcademyOfSciences/SimElectricity

Link to comment
Share on other sites

18 hours ago, diesieben07 said:

This is the only proper solution.

I was convinced

 

One more question, it is possible to specify the model loader in the blockstate file?

Edited by Rikka0_0

My mod: SimElectricity - High Voltages, Electrical Power Transmission & Distribution

https://github.com/RoyalAliceAcademyOfSciences/SimElectricity

Link to comment
Share on other sites

5 hours ago, Rikka0_0 said:

How to invoke the DataGenerator? I launched the game, the GatherDataEvent is not fired by MinecraftForge.

https://wiki.mcjty.eu/modding/index.php?title=Tut15_Ep15

 

By default, Forge generates three run configurations for your IDE: runClient, runServer and runData. You need to use runData to run the data generators.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

3 hours ago, TheGreyGhost said:

I don't think so, no.  Based on my testing the 


"loader": "forge:obj",

needs to go in the model file itself

-TGG

Thanks!

As far I as know, this is the only possible way.

 

Also, can anyone confirm that forge blockstate loader has been permanently removed? I put "forge_marker" : 1 but Forge seems to ignore it.

My mod: SimElectricity - High Voltages, Electrical Power Transmission & Distribution

https://github.com/RoyalAliceAcademyOfSciences/SimElectricity

Link to comment
Share on other sites

17 hours ago, Choonster said:

 

By default, Forge generates three run configurations for your IDE: runClient, runServer and runData. You need to use runData to run the data generators.

Thanks!

 

My BlockStateProvider is now working! I will post a link to the repo once I finish cleaning up the code.

My mod: SimElectricity - High Voltages, Electrical Power Transmission & Distribution

https://github.com/RoyalAliceAcademyOfSciences/SimElectricity

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.