From b6b7a678661c0ae51124cdacb90576a7ea547100 Mon Sep 17 00:00:00 2001 From: ffrann <45723631+frqnny@users.noreply.github.com> Date: Fri, 11 Jun 2021 12:08:11 -0400 Subject: [PATCH 1/3] 1.0.7 update :) --- build.gradle | 1 - gradle.properties | 12 ++++++------ .../main/java/draylar/omegaconfig/OmegaConfig.java | 4 ++-- omega-config-base/src/main/resources/fabric.mod.json | 5 +++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 5783048..b203c9f 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,6 @@ import java.nio.charset.StandardCharsets buildscript { repositories { mavenLocal() - jcenter() google() } diff --git a/gradle.properties b/gradle.properties index e4d38b8..79236a2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,13 +2,13 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=21w20a -yarn_mappings=21w20a+build.19 +minecraft_version=1.17 +yarn_mappings=1.17+build.7 loader_version=0.11.3 + +#Fabric api +fabric_version=0.34.10+1.17 # Mod Properties -mod_version=1.0.5 +mod_version=1.0.7 maven_group=draylar archives_base_name=omega-config -# Dependencies -# check this on https://modmuss50.me/fabric.html -fabric_version=0.34.6+1.17 diff --git a/omega-config-base/src/main/java/draylar/omegaconfig/OmegaConfig.java b/omega-config-base/src/main/java/draylar/omegaconfig/OmegaConfig.java index ac292ed..a9c095d 100644 --- a/omega-config-base/src/main/java/draylar/omegaconfig/OmegaConfig.java +++ b/omega-config-base/src/main/java/draylar/omegaconfig/OmegaConfig.java @@ -67,7 +67,7 @@ public class OmegaConfig { // 1. serialize to disk if the config does not already exist // 2. read from disk if it does exist if (!configExists(config)) { - writeConfig(configClass, config); + config.save(); REGISTERED_CONFIGURATIONS.add(config); } else { try { @@ -79,7 +79,7 @@ public class OmegaConfig { T object = GSON.fromJson(res.toString(), configClass); // re-write the config to add new values - writeConfig(configClass, object); + object.save(); REGISTERED_CONFIGURATIONS.add(object); return object; } catch (Exception e) { diff --git a/omega-config-base/src/main/resources/fabric.mod.json b/omega-config-base/src/main/resources/fabric.mod.json index 63c7736..38c817d 100644 --- a/omega-config-base/src/main/resources/fabric.mod.json +++ b/omega-config-base/src/main/resources/fabric.mod.json @@ -1,11 +1,12 @@ { "schemaVersion": 1, "id": "omega-config", - "version": "${version}", + "version": "1.0.7", "name": "OmegaConfig", "description": "The last config solution you will ever use.", "authors": [ - "Draylar" + "Draylar", + "Frqnny" ], "contact": {}, "license": "MIT", From 09658ffee698a9c0a120582304fc6d0230edd12b Mon Sep 17 00:00:00 2001 From: ffrann <45723631+frqnny@users.noreply.github.com> Date: Tue, 15 Jun 2021 23:39:08 -0400 Subject: [PATCH 2/3] Fix mixin compat level being set to JAVA_16 Delete NoValidConstructorException.java (waste of space smh) --- gradle.properties | 2 +- .../src/main/java/draylar/omegaconfig/OmegaConfig.java | 3 +-- .../omegaconfig/exception/NoValidConstructorException.java | 5 ----- omega-config-base/src/main/resources/fabric.mod.json | 2 +- .../src/main/resources/omega-config.mixins.json | 2 +- .../src/main/resources/omega-config-gui.mixins.json | 2 +- 6 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 omega-config-base/src/main/java/draylar/omegaconfig/exception/NoValidConstructorException.java diff --git a/gradle.properties b/gradle.properties index 79236a2..5794d56 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,6 @@ loader_version=0.11.3 #Fabric api fabric_version=0.34.10+1.17 # Mod Properties -mod_version=1.0.7 +mod_version=1.0.8 maven_group=draylar archives_base_name=omega-config diff --git a/omega-config-base/src/main/java/draylar/omegaconfig/OmegaConfig.java b/omega-config-base/src/main/java/draylar/omegaconfig/OmegaConfig.java index a9c095d..40a5bfe 100644 --- a/omega-config-base/src/main/java/draylar/omegaconfig/OmegaConfig.java +++ b/omega-config-base/src/main/java/draylar/omegaconfig/OmegaConfig.java @@ -4,7 +4,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import draylar.omegaconfig.api.Comment; import draylar.omegaconfig.api.Config; -import draylar.omegaconfig.exception.NoValidConstructorException; import draylar.omegaconfig.gson.SyncableExclusionStrategy; import io.netty.buffer.Unpooled; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; @@ -92,7 +91,7 @@ public class OmegaConfig { return config; } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException exception) { exception.printStackTrace(); - throw new NoValidConstructorException(); + throw new RuntimeException("No valid constructor found for: " + configClass.getName()); } } diff --git a/omega-config-base/src/main/java/draylar/omegaconfig/exception/NoValidConstructorException.java b/omega-config-base/src/main/java/draylar/omegaconfig/exception/NoValidConstructorException.java deleted file mode 100644 index 7ce1fc2..0000000 --- a/omega-config-base/src/main/java/draylar/omegaconfig/exception/NoValidConstructorException.java +++ /dev/null @@ -1,5 +0,0 @@ -package draylar.omegaconfig.exception; - -public class NoValidConstructorException extends RuntimeException { - -} diff --git a/omega-config-base/src/main/resources/fabric.mod.json b/omega-config-base/src/main/resources/fabric.mod.json index 38c817d..d3f015e 100644 --- a/omega-config-base/src/main/resources/fabric.mod.json +++ b/omega-config-base/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "omega-config", - "version": "1.0.7", + "version": "1.0.8", "name": "OmegaConfig", "description": "The last config solution you will ever use.", "authors": [ diff --git a/omega-config-base/src/main/resources/omega-config.mixins.json b/omega-config-base/src/main/resources/omega-config.mixins.json index 2860eda..d0f5058 100644 --- a/omega-config-base/src/main/resources/omega-config.mixins.json +++ b/omega-config-base/src/main/resources/omega-config.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "draylar.omegaconfig.mixin", - "compatibilityLevel": "JAVA_8", + "compatibilityLevel": "JAVA_16", "mixins": [ ], "client": [ diff --git a/omega-config-gui/src/main/resources/omega-config-gui.mixins.json b/omega-config-gui/src/main/resources/omega-config-gui.mixins.json index 15b69a5..c70436c 100644 --- a/omega-config-gui/src/main/resources/omega-config-gui.mixins.json +++ b/omega-config-gui/src/main/resources/omega-config-gui.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "draylar.omegaconfiggui.mixin", - "compatibilityLevel": "JAVA_8", + "compatibilityLevel": "JAVA_16", "mixins": [ "ClickableWidgetInvoker", "ModMenuAccessor" From 6099b30f3daac0af299a430921072d33910e2366 Mon Sep 17 00:00:00 2001 From: ffrann <45723631+frqnny@users.noreply.github.com> Date: Tue, 15 Jun 2021 23:48:09 -0400 Subject: [PATCH 3/3] Add new mo structures as test --- .../config/StructureConfigEntry.java | 42 +++++ .../config/StructuresConfigTest.java | 143 +++++------------- 2 files changed, 77 insertions(+), 108 deletions(-) create mode 100644 src/testmod/java/draylar/omegatest/config/StructureConfigEntry.java diff --git a/src/testmod/java/draylar/omegatest/config/StructureConfigEntry.java b/src/testmod/java/draylar/omegatest/config/StructureConfigEntry.java new file mode 100644 index 0000000..a96356c --- /dev/null +++ b/src/testmod/java/draylar/omegatest/config/StructureConfigEntry.java @@ -0,0 +1,42 @@ +package draylar.omegatest.config; + +import java.util.Map; + +public class StructureConfigEntry { + + public final boolean activated; + public final int separation; + public final int spacing; + public final int salt; + + private StructureConfigEntry(int separation, int spacing, int salt) { + this.activated = true; + this.spacing = spacing; + this.separation = separation; + this.salt = salt; + } + + public static StructureConfigEntry of(int separation, int spacing, int salt) { + return new StructureConfigEntry(separation, spacing, salt); + } + + + public static void computeConfigMap(Map map) { + map.computeIfAbsent("abandoned_church", (id) -> of(14, 38, 66996840)); + map.computeIfAbsent("barn_house", (id) -> of(8, 38, 165757306)); + map.computeIfAbsent("big_pyramid", (id) -> of(5, 25, 239284294)); + map.computeIfAbsent("jungle_pyramid", (id) -> of(5, 25, 312178642)); + map.computeIfAbsent("the_castle_in_the_sky", (id) -> of(8, 30, 423494938)); + map.computeIfAbsent("killer_bunny_castle", (id) -> of(25, 45, 48123900)); + map.computeIfAbsent("villager_tower", (id) -> of(16, 34, 550292492)); + map.computeIfAbsent("villager_market", (id) -> of(16, 36, 784939542)); + map.computeIfAbsent("pillager_factory", (id) -> of(16, 36, 839204924)); + map.computeIfAbsent("ice_tower", (id) -> of(8, 28, 964058305)); + map.computeIfAbsent("tavern", (id) -> of(12, 32, 19296726)); + map.computeIfAbsent("pirate_ship", (id) -> of(16, 40, 583957395)); + map.computeIfAbsent("lighthouse", (id) -> of(16, 32, 29502322)); + map.computeIfAbsent("volcanic_vent", (id) -> of(4, 8, 84981094)); + map.computeIfAbsent("moai", (id) -> of(4, 8, 12994829)); + map.computeIfAbsent("air_balloon", (id) -> of(1, 6, 29483148)); + } +} diff --git a/src/testmod/java/draylar/omegatest/config/StructuresConfigTest.java b/src/testmod/java/draylar/omegatest/config/StructuresConfigTest.java index d4238fa..aadac90 100644 --- a/src/testmod/java/draylar/omegatest/config/StructuresConfigTest.java +++ b/src/testmod/java/draylar/omegatest/config/StructuresConfigTest.java @@ -2,19 +2,30 @@ package draylar.omegatest.config; import draylar.omegaconfig.api.Comment; import draylar.omegaconfig.api.Config; +import net.minecraft.util.Identifier; +import java.util.HashMap; +import java.util.Map; + + +//taken straight out of Mo' Structures public class StructuresConfigTest implements Config { - @Comment("Mo' Structures feature toggles.") - public Features features = new Features(); - @Comment("Chances are once per the number of chunks. A Chance 500 makes a feature spawn every 500 chunks. Affected by biomes it spawns in and the chunk, so not all are proportional.") - public FeatureChances feature_chances = new FeatureChances(); - - @Comment("Structure toggles. These do not have chances, but in the future they may. ") - public Structures structures = new Structures(); - - @Comment("Structure chances. Seperation is the least amount of chunks that a structure will spawn from itself. Spacing is the maximum amount of chunks, and both are used to randomly spawn structures and can be tweaked.") - public StructureChances structureChances = new StructureChances(); + @Comment(""" + Welcome to Mo'Structures Config! + // + // Here, you can turn off structures, change their chance, and also change their salt. + // + // To turn off a structure, simply go to the corresponding entry and set `activated` to false. + // + // Mo' Structures uses the vanilla structure spawning system. That is- + // - Seperation is the minimum chunks between structures + // - Spacing is the average chunks between structures + // + // Salt is a special field that gives structures unique spawning positions. DO NOT TOUCH IT, ONLY ADVANCED TROUBLESHOOTING! + + """) + public final Map structureConfigEntries = new HashMap<>(17); @Override public String getName() { @@ -26,106 +37,22 @@ public class StructuresConfigTest implements Config { return "json5"; } - public static class Features { - @Comment("Airplanes & Air Balloons") - public boolean air_features = true; - @Comment("Fallen Trees") - public boolean fallen_trees = true; - @Comment("Desert Features") - public boolean desert_features = true; - @Comment("Ruins") - public boolean ruins = true; - @Comment("Lamppost") - public boolean lamppost = true; - @Comment("Boulder") - public boolean boulder = true; - @Comment("Volcanic Vent") - public boolean volcanic_vent = true; - @Comment("Beach Features") - public boolean beach_features = true; - @Comment("Boats") - public boolean boats = true; + public StructureConfigEntry get(Identifier id) { + + + for (Map.Entry entry : structureConfigEntries.entrySet()) { + if (entry.getKey().equals(id.getPath())) { + return entry.getValue(); + } + } + + throw new NullPointerException("Tried StructureConfigEntry with id: " + id + ", but it was null!"); } - public static class FeatureChances { - @Comment("Airplanes & Air Balloons") - public int air_feature_chance = 4600; - @Comment("Fallen Trees") - public int fallen_trees_chance = 17; - @Comment("Desert Features") - public int desert_features_chance = 555; - @Comment("Ruins") - public int ruins_chance = 3500; - @Comment("Lamppost") - public int lamppost_chance = 100; - @Comment("Boulder") - public int boulder_chance = 4000; - @Comment("Volcanic Vent") - public int volcanic_vent_chance = 85; - @Comment("Beach Features") - public int beach_features_chance = 75; - @Comment("Boats") - public int boats_chance = 4000; - } - public static class Structures { - @Comment("Barnhouse") - public boolean barn_house = true; - @Comment("Jungle Pyramid") - public boolean jungle_pyramid = true; - @Comment("Big Pyramid") - public boolean big_pyramid = true; - @Comment("The Castle In The Sky") - public boolean the_castle_in_the_sky = true; - @Comment("Villager Tower") - public boolean villager_tower = true; - @Comment("Abandoned Churches") - public boolean abandoned_churches = true; - @Comment("Villager Market") - public boolean villager_market = true; - @Comment("Pillager Factory") - public boolean pillager_factory = true; - @Comment("Ice Tower") - public boolean ice_tower = true; - @Comment("Boar Hat Tavern") - public boolean tavern = true; - @Comment("Killer Bunny Castle") - public boolean killer_bunny_castle = true; - } - - public static class StructureChances { - @Comment("Barn House") - public int barn_house_seperation = 16; - public int barn_house_spacing = 40; - @Comment("Big Pyramid") - public int big_pyramid_seperation = 5; - public int big_pyramid_spacing = 25; - @Comment("Jungle Pyramid") - public int jungle_pyramid_seperation = 5; - public int jungle_pyramid_spacing = 25; - @Comment("The Castle In The Sky") - public int the_castle_in_the_sky_seperation = 8; - public int the_castle_in_the_sky_spacing = 32; - @Comment("Villager Tower") - public int villager_tower_seperation = 16; - public int villager_tower_spacing = 40; - @Comment("Abandoned Church") - public int abandoned_church_seperation = 16; - public int abandoned_church_spacing = 40; - @Comment("Villager Market") - public int villager_market_seperation = 27; - public int villager_market_spacing = 50; - @Comment("Pillager Factory") - public int pillager_factory_seperation = 27; - public int pillager_factory_spacing = 50; - @Comment("Ice Tower") - public int ice_tower_seperation = 8; - public int ice_tower_spacing = 32; - @Comment("Boar Hat Tavern") - public int tavern_seperation = 16; - public int tavern_spacing = 46; - @Comment("Killer Bunny Castle") - public int killer_bunny_castle_seperation = 25; - public int killer_bunny_castle_spacing = 50; + @Override + public void save() { + StructureConfigEntry.computeConfigMap(structureConfigEntries); + Config.super.save(); } } \ No newline at end of file