package xyz.illuc.neuralgiacore.mixin.PrototypePain;

import net.adinvas.prototype_pain.limbs.PlayerHealthData;
import net.minecraft.server.level.ServerPlayer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import xyz.illuc.neuralgiacore.interfaces.IPlayerHealthDataAccessor;

@Mixin(PlayerHealthData.class)
public class MixinSickness {
    @Inject(method = "tickUpdate", at = @At(value = "INVOKE", target = "Ljava/lang/Math;max(FF)F", ordinal = 5, shift = At.Shift.AFTER), remap = false)
    private void updateSickness(ServerPlayer player, CallbackInfo ci) {
        IPlayerHealthDataAccessor accessor = (IPlayerHealthDataAccessor) this;
        float sicknessRemoval = -0.001F;

        accessor.setSickness(Math.max(0, Math.min(100, ((accessor.getSickness() + sicknessRemoval)))));
    }
}
