// 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);
//     }
// }


import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.capabilities.*;
import net.minecraftforge.common.util.LazyOptional;
import net.silentchaos512.scalinghealth.ScalingHealth;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Optional;

    @Override
    public void setExempt(boolean exempt){
        this.exempt = exempt;
    }

    @Nonnull
    @Override
    public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
        return INSTANCE.orEmpty(cap, holder);
    }

    @Override
    public CompoundNBT serializeNBT() {
        CompoundNBT nbt = new CompoundNBT();
        nbt.putFloat(NBT_DIFFICULTY, difficulty);
        return nbt;
    }

    @Override
    public void deserializeNBT(CompoundNBT nbt) {
        difficulty = nbt.getFloat(NBT_DIFFICULTY);
    }

    public static boolean canAttachTo(ICapabilityProvider obj) {
        try {
            if (obj.getCapability(INSTANCE).isPresent()) {
                return false;
            }
        } catch (NullPointerException ex) {
// 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/capability/DifficultySourceCapability.java
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.capabilities.*;
import net.minecraftforge.common.util.LazyOptional;
import net.silentchaos512.scalinghealth.ScalingHealth;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Optional;


    @Override
    public void setExempt(boolean exempt){
        this.exempt = exempt;
    }

    @Nonnull
    @Override
    public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
        return INSTANCE.orEmpty(cap, holder);
    }

    @Override
    public CompoundNBT serializeNBT() {
        CompoundNBT nbt = new CompoundNBT();
        nbt.putFloat(NBT_DIFFICULTY, difficulty);
        return nbt;
    }

    @Override
    public void deserializeNBT(CompoundNBT nbt) {
        difficulty = nbt.getFloat(NBT_DIFFICULTY);
    }

    public static boolean canAttachTo(ICapabilityProvider obj) {
        try {
            if (obj.getCapability(INSTANCE).isPresent()) {
                return false;
            }
        } catch (NullPointerException ex) {
            ScalingHealth.LOGGER.error("Failed to get capabilities from {}", obj);