public class MDMConfig { public static final ForgeConfigSpec SPEC; public static final MDMConfig CONFIG; public final ForgeConfigSpec.BooleanValue ALWAYS_DROP_XP; public final ForgeConfigSpec.BooleanValue USE_GLOBAL_XP_OVERRIDES; public final ForgeConfigSpec.BooleanValue BABIES_DROP_XP; public final ForgeConfigSpec.IntValue MIN_XP; public final ForgeConfigSpec.IntValue MAX_XP; public final ForgeConfigSpec.DoubleValue BABY_MULTIPLIER; public final ForgeConfigSpec.DoubleValue NOT_KILLED_BY_PLAYER_MULTIPLIER; public final ForgeConfigSpec.BooleanValue DROP_LOOT; public final ForgeConfigSpec.EnumValue LOOT_DROP_MODE; public final ForgeConfigSpec.ConfigValue> MOB_SPECIFIC_OVERRIDES; static { Pair specPair = new ForgeConfigSpec.Builder().configure(MDMConfig::new); SPEC = specPair.getRight(); CONFIG = specPair.getLeft(); } MDMConfig(ForgeConfigSpec.Builder builder) { builder.comment("Config file for Mob Drop Master."); builder.push("Mob Drop Master - Settings").push("Global:"); builder.comment("Whether mobs always drop experience regardless of cause of death."); ALWAYS_DROP_XP = builder.define("ALWAYS_DROP_XP", false); builder.comment("Whether mob experience drops are overriden globally."); USE_GLOBAL_XP_OVERRIDES = builder.define("USE_GLOBAL_XP_OVERRIDES", false); builder.comment("Whether babies will drop experience."); builder.comment("This setting to all baby mobs."); BABIES_DROP_XP = builder.define("BABIES_DROP_XP", false); builder.comment("The minimum experience a mob will drop."); MIN_XP = builder.defineInRange("MIN_XP", 0, 0, Integer.MAX_VALUE); builder.comment("The maximum experience a mob will drop."); MAX_XP = builder.defineInRange("MAX_XP", 0, 0, Integer.MAX_VALUE); builder.comment("Controls the amount of XP dropped when babies are killed."); BABY_MULTIPLIER = builder.defineInRange("BABY_MULTIPLIER", 0.5, 0.0, 99.9); builder.comment("Controls the amount of XP dropped when mobs are not killed by a player."); NOT_KILLED_BY_PLAYER_MULTIPLIER = builder.defineInRange("NOT_KILLED_BY_PLAYER_MULTIPLIER", 1.0, 0.0, 99.9); builder.comment("This setting controls whether mobs drop loot when they die."); DROP_LOOT = builder.define("DROP_LOOT", true); builder.comment("This setting controls whether the killed_by_player loot condition always passes, regardless of whether the entity was killed by a player."); LOOT_DROP_MODE = builder.defineEnum("LOOT_DROP_MODE", lootDropMode.VANILLA); builder.pop(); builder.push("Mob Overrides:"); builder.comment("Format: a:b=c,d,e,f,g,h,k,l"); builder.comment("a: modid"); builder.comment("b: entity"); builder.comment("c: ALWAYS_DROP_XP"); builder.comment("d: BABIES_DROP_XP"); builder.comment("e: MIN_XP"); builder.comment("f: MAX_XP"); builder.comment("g: BABY_MULTIPLIER"); builder.comment("h: NOT_KILLED_BY_PLAYER_MULTIPLIER"); builder.comment("k: DROP_LOOT"); builder.comment("l: LOOT_DROP_MODE"); builder.comment("Example: minecraft:iron_golem=true,true,0,0,0.0,0.0,false,2"); MOB_SPECIFIC_OVERRIDES = builder.defineListAllowEmpty("MOB_SPECIFIC_OVERRIDES", () -> Lists.newArrayList(""), e -> e instanceof String && ((String) e).contains(":") && ((String) e).contains(",")); builder.pop(); } public enum lootDropMode { ALWAYS_AS_PLAYER, NEVER_AS_PLAYER, VANILLA, VANILLA_INVERSE } public Object[] getOverride(String registryName) { for(String s : MOB_SPECIFIC_OVERRIDES.get()) { String[] parts = s.split("=|,|,|,|,|,|,|,"); if (parts.length >= 9) { String name = parts[0]; String alwaysDropXp = parts[1]; String babiesDropXp = parts[2]; String minXp = parts[3]; String maxXp = parts[4]; String babyMultiplier = parts[5]; String multiplier = parts[6]; String shouldMobDropLoot = parts[7]; String mobLootDropCondition = parts[8]; if (name.equalsIgnoreCase(registryName)) { return new Object[]{name, Boolean.parseBoolean(alwaysDropXp), Boolean.parseBoolean(babiesDropXp), Integer.parseInt(minXp), Integer.parseInt(maxXp), Double.parseDouble(babyMultiplier), Double.parseDouble(multiplier), Boolean.parseBoolean(shouldMobDropLoot), Integer.parseInt(mobLootDropCondition)}; } } } return null; } }