Skip to content

GT-IMPACT/RecipeTweaker

Repository files navigation

RecipeTweaker

Latest Release


TODO

  • Adding Vanilla Shaped and Shapeless Recipes
  • Global caching ItemStacks for recipes
  • Adding Furnace Recipes
  • Removing all vanilla recipes (crafting, smelting, etc.)
  • Java and Kotlin support
  • Checking for recipe collisions
  • Removing recipes by input or output
  • Saving recipes to SQLite .db files
  • In-Game Recipe Management: Adding, Removing, and Modifying

About the Caching Feature

RecipeTweaker.cfg -> B:isEnabledRecipeCaching=true

Controls whether item caching is enabled. When enabled, items used in recipes, such as ItemStack(Items.apple), are cached to avoid creating multiple instances. A single instance is reused from the cache, unless the stack size, metadata, or NBT data differ, in which case a new instance is created. When disabled, a new instance is created every time an item is used in a recipe.

How It Works:

Using mixins, each recipe is intercepted, and every instance of ItemStack within it is processed through RecipeItemStackCacheManager. This ensures that identical item stacks are reused rather than creating new instances, reducing memory usage and improving performance.

About the Removing all vanilla recipes Feature

RecipeTweaker.cfg -> B:isEnabledRecipeDisabling=true

Controls whether recipe addition to the smelting, crafting, etc. table is disabled. When enabled, it prevents any vanilla recipes from being added to the furnace or crafting table. However, recipes can still be added using the RecipeManager of this mod.

Adding Recipes – Usage Guide

Java:

import com.google.common.collect.ImmutableList;
import net.minecraft.init.Items;
import space.accident.recipe_tweaker.managers.RecipeManager;
import space.accident.recipe_tweaker.utils.models.McVanillaRecipe;
import space.accident.recipe_tweaker.utils.models.McSmeltingRecipe;
import space.accident.recipe_tweaker.utils.models.OreDictStack;

// Valid Shaped Recipe by OreDictionary and ItemStacks
McVanillaRecipe recipe = RecipeManager.addShape(
        ImmutableList.of(" W ", " S ", "AAA"),
        ImmutableList.of(
                RecipeManager.of("W", new ItemStack(Items.apple)),
                RecipeManager.of("S", new ItemStack(Items.iron_ingot)),
                RecipeManager.of("A", new OreDictStack("plankWood"))
        ),
        new ItemStack(Items.diamond)
);
RecipeManager.registerCrafting(recipe);

// Valid Shaped Recipe by ItemStacks
McVanillaRecipe recipe = RecipeManager.addShape(
        ImmutableList.of("W ", " S"),
        ImmutableList.of(
                RecipeManager.of("W", new ItemStack(Items.apple)),
                RecipeManager.of("S", new ItemStack(Items.iron_ingot))
        ),
        new ItemStack(Items.diamond)
);
RecipeManager.registerCrafting(recipe);

// Valid Shapeless Recipe by ItemStack
McVanillaRecipe recipe = RecipeManager.addShapeless(
        new ItemStack(Items.redstone, 10),
        new ItemStack(Items.apple, 10)
);
RecipeManager.registerCrafting(recipe);

// Valid Shapeless Recipe by OreDictionary
McVanillaRecipe recipe = RecipeManager.addShapelessAny(
        "plankWood",
        new ItemStack(Items.apple)
);
RecipeManager.registerCrafting(recipe);

// Valid Shapeless Recipe by OreDictionary
McVanillaRecipe recipe = RecipeManager.addShapelessAny(
        new OreDictStack("plankWood"),
        new ItemStack(Items.apple, 2)
);
RecipeManager.registerCrafting(recipe);

// Invalid Shapeless Recipe by not register OreDictionary
McVanillaRecipe recipe = RecipeManager.addShapelessAny(
        "testInvalidOreDict",
        new ItemStack(Items.diamond_pickaxe, 4)
);
RecipeManager.registerCrafting(recipe);

// Invalid Shapeless Recipe by not register OreDictionary and ItemStack
McVanillaRecipe recipe = RecipeManager.addShapelessAny(
        ImmutableList.of(
                new OreDictStack("testInvalidOreDict"),
                new ItemStack(Items.iron_ingot)
        ),
        new ItemStack(Items.diamond_pickaxe, 4)
);
RecipeManager.registerCrafting(recipe);

// === SMELTING ===

McSmeltingRecipe recipe = RecipeManager.addSmelting(
        new ItemStack(Items.apple, 10),
        new ItemStack(Items.iron_ingot, 10)
);
RecipeManager.registerSmelting(recipe);

McSmeltingRecipe recipe = RecipeManager.addSmelting(
        new ItemStack(Items.apple, 10),
        new ItemStack(Items.iron_ingot, 10),
        10f
);
RecipeManager.registerSmelting(recipe);

McSmeltingRecipe recipe = RecipeManager.addSmeltingAny(
        "plankWood",
        new ItemStack(Items.iron_ingot, 10)
);
RecipeManager.registerSmelting(recipe);

McSmeltingRecipe recipe = RecipeManager.addSmeltingAny(
        new OreDictStack("plankWood"),
        new ItemStack(Items.iron_ingot, 10)
);
RecipeManager.registerSmelting(recipe);

Kotlin:

import net.minecraft.init.Items
import net.minecraft.item.ItemStack
import space.accident.recipe_tweaker.managers.RecipeManager
import space.accident.recipe_tweaker.managers.RecipeManager.of
import space.accident.recipe_tweaker.utils.models.OreDictStack

//Register recipe
val recipe: McVanillaRecipe = <code>
RecipeManager.registerCrafting(recipe)

//alternative usage in kotlin
recipe.registerCraftingRecipe()

// Valid Shaped Recipe by OreDictionary and ItemStacks
RecipeManager.addShape(
    grid = listOf(" W ", " S ", "AAA"),
    inputItems = listOf(
        "W" of ItemStack(Items.apple),
        "S" of ItemStack(Items.iron_ingot),
        "A" of OreDictStack("plankWood"),
    ),
    resultItem = ItemStack(Items.diamond)
).registerCraftingRecipe()

// Valid Shaped Recipe by ItemStacks
RecipeManager.addShape(
    grid = listOf("W ", " S"),
    inputItems = listOf(
        "W" of ItemStack(Items.apple),
        "S" of ItemStack(Items.iron_ingot),
    ),
    resultItem = ItemStack(Items.diamond)
).registerCraftingRecipe()

// Valid Shapeless Recipe by ItemStack
RecipeManager.addShapeless(
    inputItem = ItemStack(Items.redstone, 10),
    resultItem = ItemStack(Items.apple, 10)
).registerCraftingRecipe()

// Valid Shapeless Recipe by OreDictionary
RecipeManager.addShapelessAny(
    inputItem = "plankWood",
    resultItem = ItemStack(Items.apple)
).registerCraftingRecipe()

// Valid Shapeless Recipe by OreDictionary
RecipeManager.addShapelessAny(
    inputItem = OreDictStack("plankWood"),
    resultItem = ItemStack(Items.apple, 2)
).registerCraftingRecipe()

// Invalid Shapeless Recipe by not register OreDictionary
RecipeManager.addShapelessAny(
    inputItem = "testInvalidOreDict2",
    resultItem = ItemStack(Items.diamond_pickaxe, 4)
).registerCraftingRecipe()

// Invalid Shapeless Recipe by not register OreDictionary and ItemStack
RecipeManager.addShapelessAny(
    inputItems = listOf(
        OreDictStack("testInvalidOreDict1"),
        ItemStack(Items.iron_ingot),
    ),
    resultItem = ItemStack(Items.apple, 3)
).registerCraftingRecipe()

// === SMELTING ===

//Register recipe
val recipe: McSmeltingRecipe = <code>
RecipeManager.registerSmelting(recipe)

//alternative usage in kotlin
recipe.registerSmeltingRecipe()

RecipeManager.addSmelting(
    ItemStack(Items.apple, 10),
    ItemStack(Items.iron_ingot, 10)
).registerSmeltingRecipe()

RecipeManager.addSmelting(
    ItemStack(Items.apple, 10),
    ItemStack(Items.iron_ingot, 10),
    10f
).registerSmeltingRecipe()

RecipeManager.addSmeltingAny(
    "plankWood",
    ItemStack(Items.iron_ingot, 10)
).registerSmeltingRecipe()

RecipeManager.addSmeltingAny(
    OreDictStack("plankWood"),
    ItemStack(Items.iron_ingot, 10)
).registerSmeltingRecipe()

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published