Created classes for holding override data. Updated config to generate the list of override items.
This commit is contained in:
@ -2,8 +2,10 @@ package dev.micle.xptools.config;
|
||||
|
||||
import dev.micle.xptools.XpTools;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -47,16 +49,17 @@ public final class Config {
|
||||
}
|
||||
|
||||
public static class Server {
|
||||
public static ForgeConfigSpec.BooleanValue BLOCK_BREAK_DEFAULT_NO_XP;
|
||||
public static ForgeConfigSpec.ConfigValue<List<String>> BLOCK_BREAK_OVERRIDES;
|
||||
public static ForgeConfigSpec.BooleanValue blockBreakDefaultNoXp;
|
||||
private static ForgeConfigSpec.ConfigValue<List<? extends String>> blockBreakOverridesRaw;
|
||||
public static List<OverrideItem> blockBreakOverrideItems;
|
||||
|
||||
Server(ForgeConfigSpec.Builder builder) {
|
||||
builder.comment("Settings for block breaking").push("block_breaking");
|
||||
BLOCK_BREAK_DEFAULT_NO_XP = builder
|
||||
blockBreakDefaultNoXp = builder
|
||||
.comment("Should all blocks drop 0 XP by default?")
|
||||
.comment("(This makes multipliers not have any effect)")
|
||||
.define("blockBreakXpDisabled", false);
|
||||
BLOCK_BREAK_OVERRIDES = builder
|
||||
blockBreakOverridesRaw = builder
|
||||
.comment("List of all overrides. Format: '[block_id/tag],[multi/val],[min],[max]'")
|
||||
.comment("Examples:")
|
||||
.comment("'minecraft:dirt,val,2,2' - Makes minecraft's dirt blocks drop 2 XP")
|
||||
@ -64,5 +67,15 @@ public final class Config {
|
||||
.define("blockBreakOverrides", new ArrayList<>());
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onServerConfigReload(ModConfigEvent event) {
|
||||
if (event.getConfig().getSpec() == SERVER_SPEC) {
|
||||
blockBreakOverrideItems = new ArrayList<>();
|
||||
for (String s : blockBreakOverridesRaw.get()) {
|
||||
blockBreakOverrideItems.add(new OverrideItem(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user