vanobotrevan

Create a Minecraft 1.21.1 mod where any item can be smelted in Furnace, Blast Furnace, or Smoker into a randomly assigned item. The same input always gives the same output. Any item can also be used as fuel like coal. (Optional) make smelting speed 2x faster than before

Kodari AI
KodariAug 22 at 7:25 am 2

Plan:

  1. Create a Fabric 1.21.11 Gradle project with common/client source sets and metadata.

  2. Add deterministic item-to-item smelting behavior for furnace, blast furnace, and smoker, plus universal fuel handling.

  3. Add the optional 2× smelting-speed behavior and required mixin/resource files.

Created the Fabric 1.21.11 project.

  • Any non-empty item can be smelted in furnaces, blast furnaces, and smokers.

  • Each input item deterministically maps to the same output based on its item ID.

  • Every item can act as furnace fuel, with a 1,600-tick burn time.

  • Smelting completes twice as fast.

  • Added Fabric Loom setup, split source sets, mod metadata, mixin configuration, and Java 21 settings.

vanobotrevan

The compilation failed with this error:

code
Compilation failed with 4 error(s):

ERROR in src/main/java/com/kodari/universalsmelting/mixin/AbstractFurnaceBlockEntityMixin.java at line 31: cannot find symbol
            RecipeManager.MatchGetter<?, ?> matcher,
                         ^
  symbol: class MatchGetter
  location: interface RecipeManager

ERROR in src/main/java/com/kodari/universalsmelting/mixin/AbstractFurnaceBlockEntityMixin.java at line 36: cannot find symbol
        if (input.getSize() != 1) {
                 ^
  symbol: method getSize()
  location: variable input of type RecipeInput

ERROR in   src/main/java/com/kodari/universalsmelting/mixin/AbstractFurnaceBlockEntityMixin.java at line 31: cannot find symbol
              RecipeManager.MatchGetter<?, ?> matcher,
                           ^
  symbol: class MatchGetter
  location: interface RecipeManager

ERROR in   src/main/java/com/kodari/universalsmelting/mixin/AbstractFurnaceBlockEntityMixin.java at line 36: cannot find symbol
          if (input.getSize() != 1) {
                   ^
  symbol: method getSize()
  location: variable input of type RecipeInput


=== COMPILATION ERROR ANALYSIS ===

MISSING CLASSES:
  - MatchGetter
ACTION: Create these classes or check imports

MISSING METHODS:
  - getSize()
ACTION: Check method names and signatures

FILES TO INVESTIGATE:
  - src/main/java/com/kodari/universalsmelting/mixin/AbstractFurnaceBlockEntityMixin.java
  -   src/main/java/com/kodari/universalsmelting/mixin/AbstractFurnaceBlockEntityMixin.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariAug 22 at 7:27 am 1
  1. Replace the removed RecipeManager.MatchGetter hook with the 1.21.11 RecipeManager.getFirstMatch(...) invocation.

  2. Change RecipeInput.getSize() to RecipeInput.size() and preserve the original lookup arguments on fallback.

Fixed AbstractFurnaceBlockEntityMixin.java:

  • Replaced the removed RecipeManager.MatchGetter target with RecipeManager.getFirstMatch(...).

  • Added the RecipeType receiver argument.

  • Changed input.getSize() to input.size().

  • Updated fallback calls to pass all required arguments.

  • Added the RecipeType import.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
7 251
src/main/java/com/kodari/universalsmelting/UniversalSmeltingMod.java
package com.kodari.universalsmelting;

import net.fabricmc.api.ModInitializer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.recipe.SmeltingRecipe;
import net.minecraft.recipe.book.CookingRecipeCategory;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class UniversalSmeltingMod implements ModInitializer {
    public static final String MOD_ID = "universal_smelting";
    private static volatile List<Item> outputItems;

    @Override
    public void onInitialize() {
    }

    public static RecipeEntry<SmeltingRecipe> createRecipe(Item input) {
        Identifier inputId = Registries.ITEM.getId(input);
        Identifier recipeId = Identifier.of(
                MOD_ID,
                "universal/" + inputId.getNamespace() + "/" + inputId.getPath()
        );

        SmeltingRecipe recipe = new SmeltingRecipe(
                "",
                CookingRecipeCategory.MISC,
                Ingredient.ofItems(input),
                new ItemStack(selectOutput(input)),
                0.0F,
                200
        );
        RegistryKey<net.minecraft.recipe.Recipe<?>> key = RegistryKey.of(RegistryKeys.RECIPE, recipeId);
        return new RecipeEntry<>(key, recipe);
    }

    private static Item selectOutput(Item input) {
        List<Item> candidates = getOutputItems();
        Identifier inputId = Registries.ITEM.getId(input);
        long hash = 0xcbf29ce484222325L;
        String key = inputId.toString();
        for (int index = 0; index < key.length(); index++) {
            hash ^= key.charAt(index);
            hash *= 0x100000001b3L;
        }

        int outputIndex = (int) Math.floorMod(hash, (long) candidates.size());
        return candidates.get(outputIndex);
    }

    private static List<Item> getOutputItems() {
        List<Item> cached = outputItems;
        if (cached != null) {
            return cached;
        }

        synchronized (UniversalSmeltingMod.class) {
            if (outputItems == null) {
                List<Item> items = new ArrayList<>();
                for (Item item : Registries.ITEM) {
                    if (item != Items.AIR) {
                        items.add(item);
                    }
                }
                items.sort(Comparator.comparing(item -> Registries.ITEM.getId(item).toString()));
                outputItems = List.copyOf(items);
            }
            return outputItems;
        }
    }
}