Guest User

Untitled

a guest
Apr 5th, 2024
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.80 KB | None | 0 0
  1. public class MDMConfig {
  2. public static final ForgeConfigSpec SPEC;
  3. public static final MDMConfig CONFIG;
  4. public final ForgeConfigSpec.BooleanValue ALWAYS_DROP_XP;
  5. public final ForgeConfigSpec.BooleanValue USE_GLOBAL_XP_OVERRIDES;
  6. public final ForgeConfigSpec.BooleanValue BABIES_DROP_XP;
  7. public final ForgeConfigSpec.IntValue MIN_XP;
  8. public final ForgeConfigSpec.IntValue MAX_XP;
  9. public final ForgeConfigSpec.DoubleValue BABY_MULTIPLIER;
  10. public final ForgeConfigSpec.DoubleValue NOT_KILLED_BY_PLAYER_MULTIPLIER;
  11. public final ForgeConfigSpec.BooleanValue DROP_LOOT;
  12. public final ForgeConfigSpec.EnumValue<lootDropMode> LOOT_DROP_MODE;
  13. public final ForgeConfigSpec.ConfigValue<List<? extends String>> MOB_SPECIFIC_OVERRIDES;
  14.  
  15. static {
  16. Pair<MDMConfig, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder().configure(MDMConfig::new);
  17. SPEC = specPair.getRight();
  18. CONFIG = specPair.getLeft();
  19. }
  20.  
  21. MDMConfig(ForgeConfigSpec.Builder builder) {
  22. builder.comment("Config file for Mob Drop Master.");
  23. builder.push("Mob Drop Master - Settings").push("Global:");
  24.  
  25. builder.comment("Whether mobs always drop experience regardless of cause of death.");
  26. ALWAYS_DROP_XP = builder.define("ALWAYS_DROP_XP", false);
  27. builder.comment("Whether mob experience drops are overriden globally.");
  28. USE_GLOBAL_XP_OVERRIDES = builder.define("USE_GLOBAL_XP_OVERRIDES", false);
  29. builder.comment("Whether babies will drop experience.");
  30. builder.comment("This setting to all baby mobs.");
  31. BABIES_DROP_XP = builder.define("BABIES_DROP_XP", false);
  32. builder.comment("The minimum experience a mob will drop.");
  33. MIN_XP = builder.defineInRange("MIN_XP", 0, 0, Integer.MAX_VALUE);
  34. builder.comment("The maximum experience a mob will drop.");
  35. MAX_XP = builder.defineInRange("MAX_XP", 0, 0, Integer.MAX_VALUE);
  36. builder.comment("Controls the amount of XP dropped when babies are killed.");
  37. BABY_MULTIPLIER = builder.defineInRange("BABY_MULTIPLIER", 0.5, 0.0, 99.9);
  38. builder.comment("Controls the amount of XP dropped when mobs are not killed by a player.");
  39. NOT_KILLED_BY_PLAYER_MULTIPLIER = builder.defineInRange("NOT_KILLED_BY_PLAYER_MULTIPLIER", 1.0, 0.0, 99.9);
  40. builder.comment("This setting controls whether mobs drop loot when they die.");
  41. DROP_LOOT = builder.define("DROP_LOOT", true);
  42. builder.comment("This setting controls whether the killed_by_player loot condition always passes, regardless of whether the entity was killed by a player.");
  43. LOOT_DROP_MODE = builder.defineEnum("LOOT_DROP_MODE", lootDropMode.VANILLA);
  44. builder.pop();
  45.  
  46. builder.push("Mob Overrides:");
  47. builder.comment("Format: a:b=c,d,e,f,g,h,k,l");
  48. builder.comment("a: modid");
  49. builder.comment("b: entity");
  50. builder.comment("c: ALWAYS_DROP_XP");
  51. builder.comment("d: BABIES_DROP_XP");
  52. builder.comment("e: MIN_XP");
  53. builder.comment("f: MAX_XP");
  54. builder.comment("g: BABY_MULTIPLIER");
  55. builder.comment("h: NOT_KILLED_BY_PLAYER_MULTIPLIER");
  56. builder.comment("k: DROP_LOOT");
  57. builder.comment("l: LOOT_DROP_MODE");
  58. builder.comment("Example: minecraft:iron_golem=true,true,0,0,0.0,0.0,false,2");
  59. MOB_SPECIFIC_OVERRIDES = builder.defineListAllowEmpty("MOB_SPECIFIC_OVERRIDES", () -> Lists.newArrayList(""), e -> e instanceof String && ((String) e).contains(":") && ((String) e).contains(","));
  60. builder.pop();
  61. }
  62.  
  63. public enum lootDropMode {
  64. ALWAYS_AS_PLAYER,
  65. NEVER_AS_PLAYER,
  66. VANILLA,
  67. VANILLA_INVERSE
  68. }
  69.  
  70. public Object[] getOverride(String registryName) {
  71. for(String s : MOB_SPECIFIC_OVERRIDES.get()) {
  72. String[] parts = s.split("=|,|,|,|,|,|,|,");
  73. if (parts.length >= 9) {
  74. String name = parts[0];
  75. String alwaysDropXp = parts[1];
  76. String babiesDropXp = parts[2];
  77. String minXp = parts[3];
  78. String maxXp = parts[4];
  79. String babyMultiplier = parts[5];
  80. String multiplier = parts[6];
  81. String shouldMobDropLoot = parts[7];
  82. String mobLootDropCondition = parts[8];
  83.  
  84. if (name.equalsIgnoreCase(registryName)) {
  85. 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)};
  86. }
  87. }
  88. }
  89. return null;
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment