package xyz.illuc.neuralgiacore.mixin.PrototypePain;

import com.lumintorious.tfcambiental.capability.TemperatureCapability;
import net.adinvas.prototype_pain.limbs.PlayerHealthData;
import net.minecraft.world.entity.player.Player;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(PlayerHealthData.class)
public class MixinAmbientTemperature {

    @Shadow
    private float temperature;

    /**
     * @author illuc
     * @reason replaces the temperature system with the tfc ambiental second ones
     */
    @Overwrite(remap = false)
    public void updateTemperature(@NotNull Player player){

        //var bodyTemp = player.getCapability(TemperatureCapability.CAPABILITY, null).orElseThrow(IllegalStateException::new).temperature;
        player.getCapability(TemperatureCapability.CAPABILITY).ifPresent(h->{
            var bodyTemp = h.temperature;
            var tempcalc = (float) (28F + (bodyTemp/3));
            this.temperature = tempcalc;
        });
    }
}
