From bdf1a5baa2aee125728d3f81c6bee11fd89b601d Mon Sep 17 00:00:00 2001 From: Micle Date: Sat, 24 May 2025 20:28:48 +0100 Subject: [PATCH] Changed config option for no xp to a global operations list. --- .../java/dev/micle/xptools/config/Config.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/java/dev/micle/xptools/config/Config.java b/src/main/java/dev/micle/xptools/config/Config.java index 1f2116b..d532a1e 100644 --- a/src/main/java/dev/micle/xptools/config/Config.java +++ b/src/main/java/dev/micle/xptools/config/Config.java @@ -65,19 +65,23 @@ public final class Config { } public static class Server { - public static ForgeConfigSpec.BooleanValue blockBreakDefaultNoXp; + private static ForgeConfigSpec.ConfigValue> blockBreakGlobalOperationsRaw; + public static List blockBreakGlobalOperationItems; private static ForgeConfigSpec.ConfigValue> blockBreakOperationsRaw; public static List blockBreakOperationItems; Server(ForgeConfigSpec.Builder builder) { + builder.comment("Available operations: " + Arrays.toString(OperationType.values())); + builder.comment("Settings for block breaking").push("block_breaking"); - blockBreakDefaultNoXp = builder - .comment("Should all blocks drop 0 XP by default?") - .comment("(This makes multipliers not have any effect)") - .define("blockBreakDefaultNoXp", false); + blockBreakGlobalOperationsRaw = builder + .comment("List of global operations. Format: '[operation],[min],[max],[priority]'") + .comment("Global operations are run before any unique operations.") + .comment("Examples:") + .comment("'set,0,0,0' - Sets the xp of all blocks to 0.") + .define("blockBreakGlobalOperations", new ArrayList<>()); blockBreakOperationsRaw = builder - .comment("List of all overrides. Format: '[block_id/tag],[operation],[min],[max],[priority],[is_last]'") - .comment("Available operations: " + Arrays.toString(OperationType.values())) + .comment("List of unique operations. Format: '[block_id/tag_id],[operation],[min],[max],[priority],[is_last]'") .comment("Examples:") .comment("'minecraft:dirt,set,2,2,0,true' - Sets the xp drop of the dirt block to 2, takes highest priority and stops any additional operations.") .comment("'#forge:ores,multiply,1,2,1,false' - Multiplies xp drop of all blocks tagged forge:ores by 1-2, allows additional operations.") @@ -86,6 +90,13 @@ public final class Config { } private static void onConfigReload() { + // Parse all block break global operations + blockBreakGlobalOperationItems = new ArrayList<>(); + for (String s : blockBreakGlobalOperationsRaw.get()) { + blockBreakOperationItems.add(GlobalOperationItem.fromConfig(s)); + } + + // Parse all block break unique operations blockBreakOperationItems = new ArrayList<>(); for (String s : blockBreakOperationsRaw.get()) { blockBreakOperationItems.add(OperationItem.fromConfig(s));