package com.r3944realms.modernlifepatch.mixin.item;

import com.dairymoose.modernlife.items.MotorboatItem;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
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 java.util.List;

@Mixin(MotorboatItem.class)
public class MixinMotorBoat extends Item {
    public MixinMotorBoat(Properties properties) {
        super(properties);
    }

    @Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
    public void appendHoverText(ItemStack itemStack, Level world, List<Component> text, TooltipFlag flag, CallbackInfo ci) {
        float fuelLevel = 1.0F;
        if (itemStack.getTag() != null && itemStack.getTag().contains("FuelLevel")) {
            fuelLevel = itemStack.getTag().getFloat("FuelLevel");
        }
        fuelLevel *= 100.0F;
        text.add(Component.translatable(ModLangKeyValue.MOTORBOAT_HOVER_FIRST.getKey()));
        text.add(Component.translatable(ModLangKeyValue.MOTORBOAT_HOVER_SECOND.getKey(), fuelLevel));
        text.add(Component.translatable(ModLangKeyValue.MOTORBOAT_HOVER_THIRD.getKey()));
        ci.cancel();
    }
}
