Skip to content

Commit

Permalink
fix: world gen features now respect config file settings
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTJP committed Apr 12, 2024
1 parent 84c9793 commit f625fcd
Show file tree
Hide file tree
Showing 15 changed files with 501 additions and 406 deletions.
48 changes: 23 additions & 25 deletions core/src/main/java/mrtjp/projectred/core/Configurator.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import codechicken.lib.config.ConfigFile;

import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

import static mrtjp.projectred.core.ProjectRedCore.MOD_ID;

Expand All @@ -27,19 +29,21 @@ public class Configurator {
public static boolean fabulousLights = true;

/* World Gen */
public static String rubyOreKey = "ruby_ore";
public static String sapphireOreKey = "sapphire_ore";
public static String peridotOreKey = "peridot_ore";
public static String tinOreKey = "tin_ore";
public static String silverOreKey = "silver_ore";
public static String electrotineOreKey = "electrotine_ore";
public static String marbleCaveKey = "marble_cave";
public static boolean gen_MarbleCave = true;
public static boolean gen_Ruby = true;
public static int gen_RubyVeinSize = 8;
public static boolean gen_Sapphire = true;
public static int gen_SapphireVeinSize = 8;
public static boolean gen_Peridot = true;
public static int gen_PeridotVeinSize = 10;
public static boolean gen_Tin = true;
public static int gen_TinVeinSize = 8;
public static boolean gen_Silver = true;
public static int gen_SilverVeinSize = 9;
public static boolean gen_Electrotine = true;
public static int gen_ElectrotineVeinSize = 8;
public static Map<String, Boolean> worldFeatures = new HashMap<>();

/* Compatibility */
public static boolean compat_CCBundledCable = true;
Expand All @@ -54,6 +58,12 @@ public static void load() {
config.save();
}

private static boolean loadAndStoreFeature(ConfigCategory gen, String key, boolean def) {
boolean value = gen.getValue(key).setDefaultBoolean(def).getBoolean();
worldFeatures.put(key, value);
return value;
}

private static void loadValues(ConfigCategory config) {

//TODO remove later
Expand All @@ -77,19 +87,13 @@ private static void loadValues(ConfigCategory config) {
fabulousLights = rendering.getValue("fabulous_lights").setDefaultBoolean(fabulousLights).setComment("Use fabulous shader pipeline for lights when on Fabulous Graphics mode").getBoolean();

ConfigCategory gen = config.getCategory("world_gen").setComment("World gen settings");
gen_Ruby = gen.getValue("ruby_ore").setDefaultBoolean(gen_Ruby).setComment("Enable Ruby Ore generation").getBoolean();
gen_RubyVeinSize = gen.getValue("ruby_ore_vein_size").setDefaultInt(gen_RubyVeinSize).setComment("Ruby Ore vein size").getInt();
gen_Sapphire = gen.getValue("sapphire_ore").setDefaultBoolean(gen_Sapphire).setComment("Enable Sapphire Ore generation").getBoolean();
gen_SapphireVeinSize = gen.getValue("sapphire_ore_vein_size").setDefaultInt(gen_SapphireVeinSize).setComment("Sapphire Ore vein size").getInt();
gen_Peridot = gen.getValue("peridot_ore").setDefaultBoolean(gen_Peridot).setComment("Enable Peridot Ore generation").getBoolean();
gen_PeridotVeinSize = gen.getValue("peridot_ore_vein_size").setDefaultInt(gen_PeridotVeinSize).setComment("Peridot Ore vein size").getInt();
gen_Tin = gen.getValue("tin_ore").setDefaultBoolean(gen_Tin).setComment("Enable Tin Ore generation").getBoolean();
gen_TinVeinSize = gen.getValue("tin_ore_vein_size").setDefaultInt(gen_TinVeinSize).setComment("Tin Ore vein size").getInt();
gen_Silver = gen.getValue("silver_ore").setDefaultBoolean(gen_Silver).setComment("Enable Silver Ore generation").getBoolean();
gen_SilverVeinSize = gen.getValue("silver_ore_vein_size").setDefaultInt(gen_SilverVeinSize).setComment("Silver Ore vein size").getInt();
gen_Electrotine = gen.getValue("electrotine_ore").setDefaultBoolean(gen_Electrotine).setComment("Enable Electrotine Ore generation").getBoolean();
gen_ElectrotineVeinSize = gen.getValue("electrotine_ore_vein_size").setDefaultInt(gen_ElectrotineVeinSize).setComment("Electrotine Ore vein size").getInt();
gen_MarbleCave = gen.getValue("marble_cave").setDefaultBoolean(gen_MarbleCave).setComment("Enable Marble Cave generation").getBoolean();
gen_Ruby = loadAndStoreFeature(gen, rubyOreKey, true);
gen_Sapphire = loadAndStoreFeature(gen, sapphireOreKey, true);
gen_Peridot = loadAndStoreFeature(gen, peridotOreKey, true);
gen_Tin = loadAndStoreFeature(gen, tinOreKey, true);
gen_Silver = loadAndStoreFeature(gen, silverOreKey, true);
gen_Electrotine = loadAndStoreFeature(gen, electrotineOreKey, true);
gen_MarbleCave = loadAndStoreFeature(gen, marbleCaveKey, true);

ConfigCategory compat = config.getCategory("compatibility").setComment("Control the loading of various compatibility hooks. These settings are ignored unless the Compatibility module is installed.");
compat_CCBundledCable = compat.getValue("computercraft").setDefaultBoolean(compat_CCBundledCable).setComment("This allows computers to connect to bundled cables with the RS API.").getBoolean();
Expand Down Expand Up @@ -123,17 +127,11 @@ private static void loadAndDeleteLegacyValues(ConfigCategory config) {

ConfigCategory gen = config.getCategory("World Gen");
gen_Ruby = gen.getValue("Ruby Ore").setDefaultBoolean(gen_Ruby).getBoolean();
gen_RubyVeinSize = gen.getValue("Ruby Ore vein size").setDefaultInt(gen_RubyVeinSize).getInt();
gen_Sapphire = gen.getValue("Sapphire Ore").setDefaultBoolean(gen_Sapphire).getBoolean();
gen_SapphireVeinSize = gen.getValue("Sapphire Ore vein size").setDefaultInt(gen_SapphireVeinSize).getInt();
gen_Peridot = gen.getValue("Peridot Ore").setDefaultBoolean(gen_Peridot).getBoolean();
gen_PeridotVeinSize = gen.getValue("Peridot Ore vein size").setDefaultInt(gen_PeridotVeinSize).getInt();
gen_Tin = gen.getValue("Tin Ore").setDefaultBoolean(gen_Tin).getBoolean();
gen_TinVeinSize = gen.getValue("Tin Ore vein size").setDefaultInt(gen_TinVeinSize).getInt();
gen_Silver = gen.getValue("Silver Ore").setDefaultBoolean(gen_Silver).getBoolean();
gen_SilverVeinSize = gen.getValue("Silver Ore vein size").setDefaultInt(gen_SilverVeinSize).getInt();
gen_Electrotine = gen.getValue("Electrotine Ore").setDefaultBoolean(gen_Electrotine).getBoolean();
gen_ElectrotineVeinSize = gen.getValue("Electrotine Ore vein size").setDefaultInt(gen_ElectrotineVeinSize).getInt();
gen_MarbleCave = gen.getValue("Marble Caves").setDefaultBoolean(gen_MarbleCave).getBoolean();

ConfigCategory compat = config.getCategory("Compatibility");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// 1.19.2 2024-03-04T11:32:53.74826 forge/biome_modifier generator for projectred_exploration
d945627f6efcd004553c4907dafa754afd32182e data/projectred_exploration/forge/biome_modifier/add_overworld_carvers.json
867d7ebae686f787cde12b48c638e594733e28ae data/projectred_exploration/forge/biome_modifier/add_overworld_ores.json
// 1.19.2 2024-04-12T12:50:48.118367 forge/biome_modifier generator for projectred_exploration
a9ee4e4ea7ce9d6a5e98587da776a55196704fa2 data/projectred_exploration/forge/biome_modifier/add_electrotine_ore_to_overworld.json
b040a155acc4c4c41dadb18f3a2a8d514cf7cd22 data/projectred_exploration/forge/biome_modifier/add_marble_cave_to_overworld.json
d44596fde99ef0bd30d0ead290049c629e8b74b1 data/projectred_exploration/forge/biome_modifier/add_peridot_ore_to_overworld.json
bdc09c896ef2863532a7ef17a2e3567274819eef data/projectred_exploration/forge/biome_modifier/add_ruby_ore_to_overworld.json
691f03827983499ee1547931cc06a5cfbecb3349 data/projectred_exploration/forge/biome_modifier/add_sapphire_ore_to_overworld.json
05ade71ce944b91d3b8309ba9b396cef7377b64a data/projectred_exploration/forge/biome_modifier/add_silver_ore_to_overworld.json
c4f8a9b2d88c1b62f59e68aca1d58249ffe5c0cf data/projectred_exploration/forge/biome_modifier/add_tin_ore_to_overworld.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"type": "projectred_exploration:add_features",
"biomes": "#minecraft:is_overworld",
"configKey": "electrotine_ore",
"features": {
"feature": {
"type": "minecraft:ore",
"config": {
"discard_chance_on_air_exposure": 0.0,
"size": 8,
"targets": [
{
"state": {
"Name": "projectred_exploration:electrotine_ore",
"Properties": {
"lit": "false"
}
},
"target": {
"predicate_type": "minecraft:tag_match",
"tag": "minecraft:stone_ore_replaceables"
}
},
{
"state": {
"Name": "projectred_exploration:deepslate_electrotine_ore",
"Properties": {
"lit": "false"
}
},
"target": {
"predicate_type": "minecraft:tag_match",
"tag": "minecraft:deepslate_ore_replaceables"
}
}
]
}
},
"placement": [
{
"type": "minecraft:count",
"count": 4
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:trapezoid",
"max_inclusive": {
"absolute": 32
},
"min_inclusive": {
"absolute": -32
}
}
}
]
},
"step": "underground_ores"
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@
}
}
},
"configKey": "marble_cave",
"step": "air"
}
Loading

0 comments on commit f625fcd

Please sign in to comment.