// 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/init/ModPotions.java
// @Mod.EventBusSubscriber(modid = ScalingHealth.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
// public enum ModPotions {
//     BANDAGED(BandagedEffect::new);
// 
//     private final Lazy<Effect> potion;
// 
//     ModPotions(Supplier<Effect> factory) {
//         this.potion = Lazy.of(factory);
//     }
// 
//     public Effect get() {
//         return potion.get();
//     }
// 
//     public String getName() {
//         return name().toLowerCase(Locale.ROOT);
//     }
// 
//     @SubscribeEvent
//     public static void registerAll(RegistryEvent.Register<Effect> event) {
//         for (ModPotions potion : values()) {
//             register(potion.getName(), potion.get());
//         }
//     }
// 
//     private static void register(String name, Effect potion) {
//         ResourceLocation registryName = ScalingHealth.getId(name);
//         potion.setRegistryName(registryName);
//         ForgeRegistries.POTIONS.register(potion);
//     }
// }


import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.UseAction;
import net.minecraft.potion.EffectInstance;
import net.minecraft.stats.Stats;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.silentchaos512.scalinghealth.ScalingHealth;
import net.silentchaos512.scalinghealth.init.ModPotions;
import javax.annotation.Nullable;
import java.util.List;

    @Override
    public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity player, Hand hand) {
        ItemStack stack = player.getHeldItem(hand);
        if (player.getHealth() < player.getMaxHealth() && !player.isPotionActive(ModPotions.BANDAGED.get())) {
            player.setActiveHand(hand);
            return ActionResult.newResult(ActionResultType.SUCCESS, stack);
        }
        return ActionResult.newResult(ActionResultType.FAIL, stack);
    }

    @Override
    public ItemStack onItemUseFinish(ItemStack stack, World world, LivingEntity entityLiving) {
        if (!world.isRemote) {
            entityLiving.addPotionEffect(new EffectInstance(ModPotions.BANDAGED.get(),
                    this.effectDuration, this.healSpeed, false, false));
            stack.shrink(1);

            if (entityLiving instanceof PlayerEntity) {
                PlayerEntity player = (PlayerEntity) entityLiving;
                player.addStat(Stats.ITEM_USED.get(this));
            }
        }
        return stack;
    }

    @Override
    public void onUsingTick(ItemStack stack, LivingEntity player, int count) {
        if (count % 10 == 0) {
            player.playSound(SoundEvents.ITEM_ARMOR_EQUIP_LEATHER,
// 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/init/ModPotions.java
// @Mod.EventBusSubscriber(modid = ScalingHealth.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
// public enum ModPotions {
//     BANDAGED(BandagedEffect::new);
// 
//     private final Lazy<Effect> potion;
// 
//     ModPotions(Supplier<Effect> factory) {
//         this.potion = Lazy.of(factory);
//     }
// 
//     public Effect get() {
//         return potion.get();
//     }
// 
//     public String getName() {
//         return name().toLowerCase(Locale.ROOT);
//     }
// 
//     @SubscribeEvent
//     public static void registerAll(RegistryEvent.Register<Effect> event) {
//         for (ModPotions potion : values()) {
//             register(potion.getName(), potion.get());
//         }
//     }
// 
//     private static void register(String name, Effect potion) {
//         ResourceLocation registryName = ScalingHealth.getId(name);
//         potion.setRegistryName(registryName);
//         ForgeRegistries.POTIONS.register(potion);
//     }
// }


// Path: src/main/java/net/silentchaos512/scalinghealth/item/HealingItem.java
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.UseAction;
import net.minecraft.potion.EffectInstance;
import net.minecraft.stats.Stats;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.silentchaos512.scalinghealth.ScalingHealth;
import net.silentchaos512.scalinghealth.init.ModPotions;
import javax.annotation.Nullable;
import java.util.List;


    @Override
    public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity player, Hand hand) {
        ItemStack stack = player.getHeldItem(hand);
        if (player.getHealth() < player.getMaxHealth() && !player.isPotionActive(ModPotions.BANDAGED.get())) {
            player.setActiveHand(hand);
            return ActionResult.newResult(ActionResultType.SUCCESS, stack);
        }
        return ActionResult.newResult(ActionResultType.FAIL, stack);
    }

    @Override
    public ItemStack onItemUseFinish(ItemStack stack, World world, LivingEntity entityLiving) {
        if (!world.isRemote) {
            entityLiving.addPotionEffect(new EffectInstance(ModPotions.BANDAGED.get(),
                    this.effectDuration, this.healSpeed, false, false));
            stack.shrink(1);

            if (entityLiving instanceof PlayerEntity) {
                PlayerEntity player = (PlayerEntity) entityLiving;
                player.addStat(Stats.ITEM_USED.get(this));
            }
        }
        return stack;
    }

    @Override
    public void onUsingTick(ItemStack stack, LivingEntity player, int count) {
        if (count % 10 == 0) {
            player.playSound(SoundEvents.ITEM_ARMOR_EQUIP_LEATHER,
                    1.25f, (float) (1.1f + 0.05f * ScalingHealth.random.nextGaussian()));