Jump to content

Recommended Posts

Posted

I'm posting this here instead of github as this is not something that it broken in forge and you can pretty much do all that is needed yourself but it kinda feels like i'm doing things i'm not suposed to and it's holding back other modders apearently from trying and using it themselfs.

 

So a little information on what i'm exactly doing: The 'final' goal is to eventually have the assembly table recipes (and possibly other machine recipes) defined in json instead of code. This would mean easier integration for other mods as there would be no need to depend on the api, allow recipes to by added by modpack makers and prepare for what looks like server controled recipes in 1.13

 

As a 'stepping stone' so to speak i wanted to try going for something similar to try out how it would work (and as alternative to still defining recipes in code or having about 700 json recipes): defining the recipes for all the pipes with a custom json. Each pipe has an item transport variant, most also have fluid and power versions. To make the item pipes you have a block of glass in the middle and an ingredient to the left and right (gold-glass-gold or wood-glass-diamond for example). The color of the pipe glass depends on the glass you use in crafting (so that is 238 recipes just for item pipes alone, a custom IRecipe/factory is possible but that means it won't show up in the book and not realy the point here)

 

The JSON looks like this: https://github.com/AEnterprise/BuildCraft/blob/12326fab1d0c4f862d1bc8c2d91937eb1b46f8cb/buildcraft_resources/assets/buildcrafttransport/pipes/base/gold.json

Parsing code: https://github.com/AEnterprise/BuildCraft/blob/1.12/common/buildcraft/transport/BCTransportRecipes.java#L78-L179

 

Relatively big issues:

  • Unless you want to read all the mod jars yourselfs to find the files (that Craftinghelper::findFiles already does and it is public) you'll want to use that function, it is however in the interal code of Craftinghelper, making it look like modders are not suposed to use it at all (i did use it for this code as i'm assuming it's ment for public use?)
  • While i'm not exactly sure if this is actally needed or not (but forge does it for crafting recipes and it is pretty much the only example of doing this that i found at this point): Setting the active mod container. This is how the registry keeps track of what mod exactly added the recipe. Not doing this means the recipe will get attributed to the mod parsing instead of adding. This means we lose the tracking feature of the registry. This means that if you want to enable/dissable recipes on a mod basis (and as far as i know that's where the system is going) this will not be possible as they are not linked in the registry to that mod (and i don't think mods should be messing with what the active mod is themselfs). In case this isn't needed would a comment on that part of the code be possible? I've talk to other modders who said that they did not touch it yet as it involves changing the active mod container

 

Things i noticed that are not major but more annoying:

  • Having to loop through all the mods myself for finding and parsing them all, this includes having to use your own reader to get the file from disk (and fixing the path for that end as well). While not the worst thing in the world it might be better mods just get the JSON directly, this way they would not have to do this themselfs (with the risk of messing up, not closing the file again, ...) would also make it more open and easier to use
  • Currently any constants the mod defines for it's regular recipes have to be parsed again but that currently also requires yet another file scan pass but this time on the regular recipes folder again to load those in again (didn't do that in this case), this would lead to some mods supporthing this system doing this, others won't. Factories are available still they are in a static map (maybe but json context per mod in one as well?)

 

If i'm missing things, misundertood things and/or am doing completely wrong here please let me know. I know the breaking changes window is closed but could this still be changed/imroved?

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.