Jump to content

[1.19.3] Configurable Ore Generation


Squidsword

Recommended Posts

Hey,

I have a mod that adds a couple of new ores. For 1.19.3, I had to move over the logic to JSON files.

I want the user to be able to change values such as rarity and vein size and have the JSON file change.

Right now, though, all of the JSON files are stuck with the default config values and don't change.

The simplest approach I came up with was updating all the JSON files with the configured values right after startup.

I tried look at the docs, but I am still not sure how to access and modify the configured and placed feature JSON data on runtime. Do I need to use codecs?

I'd appreciate any tips or alternative approaches.

Thanks!

Edited by Squidsword
clarification about what I'm asking for
Link to comment
Share on other sites

Are you trying to have the values changed on startup or when the game/server is already started? Couldn't you just change the values and then restart the game/server to have them updated?

Edited by Naamah

tenor.gif?itemid=27352888

 

Not even gonna lie, I think I have autism

Link to comment
Share on other sites

I want to, but I'm not sure how to change the values. Right now, the JSON data is a static copy of the default values and it's not linked to the config in any way. I want to be able to programmatically adjust the JSON files containing the world generation data based on what people set their config to.

So, the static copies of the default values are here:

configured and placed features

There are values like:

"discard_chance_on_air_exposure": 0.5,

Let's say the user wants the discard chance to be 0.8, so in my mods config file they set it to 0.8. I need to grab that value from the config and relay it over to change it to 

"discard_chance_on_air_exposure": 0.8,

Edited by Squidsword
link
Link to comment
Share on other sites

Those json files are configuration files.

If the user wants to modify them they can use a datapack.

 

If you really want to continue to do this, just search this forum.

This pointless "anti-pattern" has been discussed many times before in various forms.

Configuration files for configuration files? 🙂 

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Quote

If you really want to continue to do this, just search this forum.

I've searched "Editing JSON file during runtime" and "Editing datapack" and I don't seem to get any relevant results. I don't have much experience with terminology, so I'm not exactly sure what keywords to look up. Do you have a link to the relevant threads?

Quote

Configuration files for configuration files? 🙂 

I get what you are saying, but I don't want to put the burden on the user. Especially for my mod, since it's not as simple as just plugging in the values they want into a datapack. Right now, my code will take the rarity that the user sets and generate 3 different placed features that, when summed up, will approximate the rarity they picked. I have the conversion logic in my java code. Before 1.19.3, all the users had to do was set my ore to be say 5x rarer than diamonds, and I could handle the rest of the logic programmatically. I don't want them to have to make 3 different data files and manually compute what values each json file needs to have just to do the same thing. I feel like programmatically setting the JSON values is the only approach to avoid this. Unless you have another approach?

Link to comment
Share on other sites

I assume you are talking about the "count" placement modifier? Typically placed features are configured with multiple placement modifiers one of which is some form "count".

 

You can write your own PlacementModifier (and register it) that takes its value(s) from your configuration file instead of the numbers in the json file.

In 1.19.3 Registries.PLACEMENT_MODIFER_TYPE is the registry key.

 

This approach does at least mean if the end user/mod pack developer doesn't like your way of configuring the ore generation they can create a datapack and replace your placement modifier with their own. Which is Mojang's intended way to do it.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.