// Path: src/main/java/net/silentchaos512/scalinghealth/ScalingHealth.java
// @Mod(ScalingHealth.MOD_ID)
// public class ScalingHealth {
//     public static final String MOD_ID = "scalinghealth";
//     public static final String MOD_NAME = "Scaling Health";
//     public static final String VERSION = "2.5.3";
// 
//     public static final Random random = new Random();
// 
//     public static final ItemGroup SH = new ItemGroup(MOD_ID) {
//         @Override
//         public ItemStack createIcon() {
//             return new ItemStack(ModItems.HEART_CRYSTAL.asItem());
//         }
//     };
// 
//     public static final Logger LOGGER = LogManager.getLogger(MOD_NAME);
// 
//     public ScalingHealth() {
//         Config.init();
//         Network.init();
//         ModLoot.init();
// 
//         FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonSetup);
//         FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(GlobalLootModifierSerializer.class, this::registerLootModSerializers);
// 
//         MinecraftForge.EVENT_BUS.addListener(this::serverAboutToStart);
//         MinecraftForge.EVENT_BUS.register(PetEventHandler.INSTANCE);
//         MinecraftForge.EVENT_BUS.register(DamageScaling.INSTANCE);
//     }
// 
//     private void registerLootModSerializers(RegistryEvent.Register<GlobalLootModifierSerializer<?>> event) {
//         event.getRegistry().register(new TableGlobalModifier.Serializer().setRegistryName(getId("table_loot_mod")));
//     }
// 
//     private void commonSetup(FMLCommonSetupEvent event) {
//         DifficultyAffectedCapability.register();
//         DifficultySourceCapability.register();
//         PlayerDataCapability.register();
//         PetHealthCapability.register();
//         DeferredWorkQueue.runLater(SHWorldFeatures::addFeaturesToBiomes);
//     }
// 
//     private void serverAboutToStart(FMLServerAboutToStartEvent event) {
//         ModCommands.registerAll(event.getServer().getCommandManager().getDispatcher());
//     }
// 
//     @Mod.EventBusSubscriber(modid = MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
//     public static class ClientForge {
//         static {
//             MinecraftForge.EVENT_BUS.register(HeartDisplayHandler.INSTANCE);
//             MinecraftForge.EVENT_BUS.register(DifficultyMeter.INSTANCE);
// 
//             DebugOverlay.init();
//         }
// 
//         @SubscribeEvent
//         public static void clientSetup(FMLClientSetupEvent event) {
//             KeyManager.registerBindings();
//         }
//     }
// 
//     public static String getVersion() {
//         return getVersion(false);
//     }
// 
//     public static String getVersion(boolean correctInDev) {
//         Optional<? extends ModContainer> o = ModList.get().getModContainerById(MOD_ID);
//         if (o.isPresent()) {
//             String str = o.get().getModInfo().getVersion().toString();
//             if (correctInDev && "NONE".equals(str))
//                 return VERSION;
//             return str;
//         }
//         return "0.0.0";
//     }
// 
//     public static ResourceLocation getId(String path) {
//         return new ResourceLocation(MOD_ID, path);
//     }
// }
// 
// Path: src/main/java/net/silentchaos512/scalinghealth/lib/EntityGroup.java
// public enum EntityGroup {
//     PEACEFUL,
//     HOSTILE,
//     BOSS,
//     BLIGHT,
//     PLAYER;
// 
//     public static EntityGroup from(String name) {
//         for(EntityGroup group : values()){
//             if(group.name().equalsIgnoreCase(name)){
//                 return group;
//             }
//         }
//         throw new RuntimeException("Could not get an entity group from name: " + name);
//     }
// 
//     public static EntityGroup from(LivingEntity entity) {
//         return from(entity, false);
//     }
// 
//     public static EntityGroup from(LivingEntity entity, boolean ignoreBlightStatus) {
//         if (entity instanceof PlayerEntity)
//             return PLAYER;
//         if (!entity.isNonBoss())
//             return BOSS;
//         if (entity instanceof IMob) {
//         if (!ignoreBlightStatus && SHMobs.isBlight((MobEntity) entity))
//             return BLIGHT;
//         return HOSTILE;
//     }
//         return PEACEFUL;
// }
// 
//     public double getPotionChance() {
//         if (this == PEACEFUL)
//             return SHMobs.passivePotionChance();
//         return SHMobs.hostilePotionChance();
//     }
// 
//     public MobHealthMode getHealthMode() {
//         return SHMobs.healthMode();
//     }
// 
//     public boolean isAffectedByDamageScaling() {
//         switch (this) {
//             case PLAYER:
//                 return EnabledFeatures.playerDamageScalingEnabled();
//             case PEACEFUL:
//                 return Config.GENERAL.damageScaling.affectPeacefuls.get();
//             default:
//                 return Config.GENERAL.damageScaling.affectHostiles.get();
//         }
//     }
// }


import com.electronwill.nightconfig.core.CommentedConfig;
import com.electronwill.nightconfig.core.ConfigSpec;
import net.minecraft.entity.LivingEntity;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.ForgeRegistries;
import net.silentchaos512.lib.util.TimeUtils;
import net.silentchaos512.scalinghealth.ScalingHealth;
import net.silentchaos512.scalinghealth.lib.EntityGroup;
import net.silentchaos512.utils.Lazy;
import net.silentchaos512.utils.MathUtils;
import net.silentchaos512.utils.config.ConfigSpecWrapper;
import net.silentchaos512.utils.config.ConfigValue;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
package net.silentchaos512.scalinghealth.config;



public class MobPotionConfig {
    private static final Marker MARKER = MarkerManager.getMarker("MobPotionConfig");
    private Lazy<List<EffectEntry>> potions;
    private final List<EffectEntry> temp = new ArrayList<>();

    public void tryApply(LivingEntity entity, double difficulty) {
        double chance = EntityGroup.from(entity).getPotionChance();
        if (!MathUtils.tryPercentage(chance)) return;

        temp.clear();
// Path: src/main/java/net/silentchaos512/scalinghealth/ScalingHealth.java
// @Mod(ScalingHealth.MOD_ID)
// public class ScalingHealth {
//     public static final String MOD_ID = "scalinghealth";
//     public static final String MOD_NAME = "Scaling Health";
//     public static final String VERSION = "2.5.3";
// 
//     public static final Random random = new Random();
// 
//     public static final ItemGroup SH = new ItemGroup(MOD_ID) {
//         @Override
//         public ItemStack createIcon() {
//             return new ItemStack(ModItems.HEART_CRYSTAL.asItem());
//         }
//     };
// 
//     public static final Logger LOGGER = LogManager.getLogger(MOD_NAME);
// 
//     public ScalingHealth() {
//         Config.init();
//         Network.init();
//         ModLoot.init();
// 
//         FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonSetup);
//         FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(GlobalLootModifierSerializer.class, this::registerLootModSerializers);
// 
//         MinecraftForge.EVENT_BUS.addListener(this::serverAboutToStart);
//         MinecraftForge.EVENT_BUS.register(PetEventHandler.INSTANCE);
//         MinecraftForge.EVENT_BUS.register(DamageScaling.INSTANCE);
//     }
// 
//     private void registerLootModSerializers(RegistryEvent.Register<GlobalLootModifierSerializer<?>> event) {
//         event.getRegistry().register(new TableGlobalModifier.Serializer().setRegistryName(getId("table_loot_mod")));
//     }
// 
//     private void commonSetup(FMLCommonSetupEvent event) {
//         DifficultyAffectedCapability.register();
//         DifficultySourceCapability.register();
//         PlayerDataCapability.register();
//         PetHealthCapability.register();
//         DeferredWorkQueue.runLater(SHWorldFeatures::addFeaturesToBiomes);
//     }
// 
//     private void serverAboutToStart(FMLServerAboutToStartEvent event) {
//         ModCommands.registerAll(event.getServer().getCommandManager().getDispatcher());
//     }
// 
//     @Mod.EventBusSubscriber(modid = MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
//     public static class ClientForge {
//         static {
//             MinecraftForge.EVENT_BUS.register(HeartDisplayHandler.INSTANCE);
//             MinecraftForge.EVENT_BUS.register(DifficultyMeter.INSTANCE);
// 
//             DebugOverlay.init();
//         }
// 
//         @SubscribeEvent
//         public static void clientSetup(FMLClientSetupEvent event) {
//             KeyManager.registerBindings();
//         }
//     }
// 
//     public static String getVersion() {
//         return getVersion(false);
//     }
// 
//     public static String getVersion(boolean correctInDev) {
//         Optional<? extends ModContainer> o = ModList.get().getModContainerById(MOD_ID);
//         if (o.isPresent()) {
//             String str = o.get().getModInfo().getVersion().toString();
//             if (correctInDev && "NONE".equals(str))
//                 return VERSION;
//             return str;
//         }
//         return "0.0.0";
//     }
// 
//     public static ResourceLocation getId(String path) {
//         return new ResourceLocation(MOD_ID, path);
//     }
// }
// 
// Path: src/main/java/net/silentchaos512/scalinghealth/lib/EntityGroup.java
// public enum EntityGroup {
//     PEACEFUL,
//     HOSTILE,
//     BOSS,
//     BLIGHT,
//     PLAYER;
// 
//     public static EntityGroup from(String name) {
//         for(EntityGroup group : values()){
//             if(group.name().equalsIgnoreCase(name)){
//                 return group;
//             }
//         }
//         throw new RuntimeException("Could not get an entity group from name: " + name);
//     }
// 
//     public static EntityGroup from(LivingEntity entity) {
//         return from(entity, false);
//     }
// 
//     public static EntityGroup from(LivingEntity entity, boolean ignoreBlightStatus) {
//         if (entity instanceof PlayerEntity)
//             return PLAYER;
//         if (!entity.isNonBoss())
//             return BOSS;
//         if (entity instanceof IMob) {
//         if (!ignoreBlightStatus && SHMobs.isBlight((MobEntity) entity))
//             return BLIGHT;
//         return HOSTILE;
//     }
//         return PEACEFUL;
// }
// 
//     public double getPotionChance() {
//         if (this == PEACEFUL)
//             return SHMobs.passivePotionChance();
//         return SHMobs.hostilePotionChance();
//     }
// 
//     public MobHealthMode getHealthMode() {
//         return SHMobs.healthMode();
//     }
// 
//     public boolean isAffectedByDamageScaling() {
//         switch (this) {
//             case PLAYER:
//                 return EnabledFeatures.playerDamageScalingEnabled();
//             case PEACEFUL:
//                 return Config.GENERAL.damageScaling.affectPeacefuls.get();
//             default:
//                 return Config.GENERAL.damageScaling.affectHostiles.get();
//         }
//     }
// }


// Path: src/main/java/net/silentchaos512/scalinghealth/config/MobPotionConfig.java
import com.electronwill.nightconfig.core.CommentedConfig;
import com.electronwill.nightconfig.core.ConfigSpec;
import net.minecraft.entity.LivingEntity;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.ForgeRegistries;
import net.silentchaos512.lib.util.TimeUtils;
import net.silentchaos512.scalinghealth.ScalingHealth;
import net.silentchaos512.scalinghealth.lib.EntityGroup;
import net.silentchaos512.utils.Lazy;
import net.silentchaos512.utils.MathUtils;
import net.silentchaos512.utils.config.ConfigSpecWrapper;
import net.silentchaos512.utils.config.ConfigValue;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

package net.silentchaos512.scalinghealth.config;



public class MobPotionConfig {
    private static final Marker MARKER = MarkerManager.getMarker("MobPotionConfig");
    private Lazy<List<EffectEntry>> potions;
    private final List<EffectEntry> temp = new ArrayList<>();

    public void tryApply(LivingEntity entity, double difficulty) {
        double chance = EntityGroup.from(entity).getPotionChance();
        if (!MathUtils.tryPercentage(chance)) return;

        temp.clear();
        for (EffectEntry entry : potions.get()) {