package mezz.jei.fabric.platform;

import mezz.jei.common.platform.IPlatformItemStackHelper;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.List;
import java.util.Map;

public class ItemStackHelper implements IPlatformItemStackHelper {
    private static final Logger LOGGER = LogManager.getLogger();

    @Override
    public int getBurnTime(ItemStack itemStack) {
        Map<Item, Integer> fuels = AbstractFurnaceBlockEntity.getFuel();
        return fuels.getOrDefault(itemStack.getItem(), 0);
    }

    @Override
    public boolean isBookEnchantable(ItemStack stack, ItemStack book) {
        return true;
    }

    @Override
    @Nullable
    public String getCreatorModId(ItemStack stack) {
        return null;
    }

    @Override
    public Collection<CreativeModeTab> getCreativeTabs(ItemStack itemStack) {
        CreativeModeTab creativeTab = itemStack.getItem().getItemCategory();
        if (creativeTab == null) {
            return List.of();
        }
        return List.of(creativeTab);
    }

    @Override
    public List<Component> getTestTooltip(@Nullable Player player, ItemStack itemStack) {
        try {
            return itemStack.getTooltipLines(player, TooltipFlag.Default.NORMAL);
        } catch (LinkageError | RuntimeException e) {
            LOGGER.error("Error while Testing for mod name formatting", e);
        }
        return List.of();
    }
}

@@ -82,24 +82,78 @@
 tackHelper;%0A
+import net.fabricmc.fabric.api.registry.FuelRegistry;%0A
 import net.m
@@ -185,16 +185,16 @@
 ponent;%0A
-
 import n
@@ -287,46 +287,8 @@
 ab;%0A
-import net.minecraft.world.item.Item;%0A
 impo
@@ -375,82 +375,8 @@
 ag;%0A
-import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;%0A
 impo
@@ -568,19 +568,23 @@
 va.util.
-Map
+Objects
 ;%0A%0Apubli
@@ -787,105 +787,66 @@
     
-Map%3CItem, Integer%3E fuels = AbstractFurnaceBlockEntity.getFuel();%0A        return fuels.getOrDefaul
+return Objects.requireNonNullElse(FuelRegistry.INSTANCE.ge
 t(it
@@ -862,16 +862,17 @@
 etItem()
+)
 , 0);%0A  

Improve performance of checking fuels on Fabric (#2997)