Jump to content

[1.8] How does Forge Interact with .json Files?


Nephroid

Recommended Posts

Even after reading this and this, I still don't quite get how Forge uses these files, and I couldn't find that much other documentation on the new system.

 

I.e. what is happening when I declare blockstates? How does Forge know what new variant names to look for? What is the actual class that interacts with and parses .json files? And so on.

 

For the people who do know, can you share a link to some resources that you think are helpful?

Link to comment
Share on other sites

Hi

 

You might find this link useful

greyminecraftcoder.blogspot.com.au/p/list-of-topics.html

in particular the topics under Blocks and Items

 

ModelBakery.addVariantName is used to register for variants.  For items you also need to Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register() to tell minecraft that the item renderer should look for the model in ModelManager.

 

Vanilla methods that are particularly relevant:

ModelManager.onResourceManagerReload()

BlockModelShapes.reloadModels()

and especially

ModelBakery.getModelBlockDefinition() is the entry point for parsing JSON files.

ModelBakery.bakeModel()

 

The vanilla code is quite complex and will probably take a while to get your head around.

 

If you just want an example of some working code, this project has some examples of block variants and item variants (examples 3 and 11)

https://github.com/TheGreyGhost/MinecraftByExample

 

-TGG

 

Link to comment
Share on other sites

Thanks. I mainly wanted to see if it was possible to add a "default" tag to the .json files so that you don't have to specify the same thing multiple times (like the default case in a switch statement).

 

For example, for a block, I'd want to have something like this:

{
    "parent": "block/cube",
    "textures": {
        "down": "top_texture",
        "up": "top_texture",
        "default": "side_texture"
    }
}

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.