Jump to content

[1.15]Custom Config Complex Data Structures


DrunkBlood

Recommended Posts

Hi,

my mod uses an ore distribution to determine with which block it should replace.

Currently I use as a default this table where each entry in the matrix is probability adding to 100% for each y-lvl except where my mod does not replace the block::stone

y - level | coal | iron | gold | lapis | redstone | diamond

>110     0    0     0     0      0       0

>60      1    0     0     0      0       0

>30     50   50     0     0      0       0

>15     25   50    15     10      0       0

>5      20   40    15     7      13       5

>0       0    0     0     0      0       0

 

For my config I want to be able to edit this matrix where the y-level border is, the blocks and the probability linked to them.

Using nightconfig and ForgeConfigSpec (.define(String path/name, T defaultValue, Predicate<Object> validator))

I would implement my Data Structure T as an

HashMap<Integer,List<HashMap<String,Float>>>

with

HashMap<y-level,List<HashMap<ResourceLocationofBlock,probability>>>

(ResourceLocationofBlock as "namespace:block" like "minecraft:coal_ore")

,a custom Supplier giving the table above and a custom Predicate checking the ResourceLocationofBlock, the probabilty and wether all y-values are coverd.

 

My Questions:

  1. Can I use a HashMap? in other words do I need to use a HashTable for thread safety
  2. Can I use ResourceLocation.isResouceNameValid(String) when my Config loads? (Using CLIENT_BUILDER since @OnlyIn(Dist.CLIENT))
  3. Is there another way to allow an user to add custom blocks to my config? (My way would be an Array/List which is typed in the Config)
  4. Is this ForgeConfigSpec the way to do Config in Forge 1.15?

 

Edit: changed y-level to Integer instead of String

Edited by DrunkBlood
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.