Object RecipeMatchingService
-
public class RecipeMatchingServiceA service providing qol methods for matching against rebar's vanilla recipe replacement.
Minecraft's recipe choice system is incredibly shallow, by default you can only ever match by item type or by exact ItemStack equality. This is okay enough for vanilla & datapacks, but the moment you add "custom" items that use vanilla types, it quickly falls short.
Because of this Rebar replaces vanilla recipe matching with our own FluidOrItemChoice system, allowing for much more flexible and dynamic recipe matching.
The basic logic of which is contained in this class.
Currently supports:
matchCraftingRecipe for crafting tables, crafters, etc.
matchCookingRecipe for furnaces, smokers, campfires, etc.
matchSmithingRecipe for the smithing table.
-
-
Field Summary
Fields Modifier and Type Field Description public final static RecipeMatchingServiceINSTANCE
-
Method Summary
Modifier and Type Method Description final static CraftingRebarRecipematchCraftingRecipe(CraftingInput input, Recipe possibleRecipe, CraftingRebarRecipe lastRecipe)Takes in a CraftingInput and matches it (if possible) to a CraftingRebarRecipe. final static CookingRebarRecipematchCookingRecipe(VanillaRecipeType<out CookingRebarRecipe, DummyCookingRebarRecipe> type, ItemStack input, ItemStack output, CookingRecipe<?> possibleRecipe, CookingRebarRecipe lastRecipe)Takes in an input and output ItemStack and matches it (if possible) to a CookingRebarRecipe of a specific type. final static SmithingRebarRecipematchSmithingRecipe(ItemStack template, ItemStack base, ItemStack addition, Recipe possibleRecipe, SmithingRebarRecipe lastRecipe)Takes in a template and addition and matches them (if possible) to a SmithingRebarRecipe. -
-
Method Detail
-
matchCraftingRecipe
final static CraftingRebarRecipe matchCraftingRecipe(CraftingInput input, Recipe possibleRecipe, CraftingRebarRecipe lastRecipe)
Takes in a CraftingInput and matches it (if possible) to a CraftingRebarRecipe.
possibleRecipe typically comes from PrepareItemCraftEvent.getRecipe or CraftingInventory.getRecipe, It's what Minecraft thinks the correct recipe is, but because RebarItems use vanilla ingredients and RebarRecipes use our custom FluidOrItemChoice, it may not always be correct.
If you are using matchCraftingRecipe for a machine or something similar, storing the last matched recipe and passing it in as lastRecipe can speed up matching significantly, as the same recipe is often used multiple times in a row.
- Parameters:
input- The CraftingInput to match withpossibleRecipe- The possible bukkit Recipe that may or may not match CraftingInput, tried before all other recipeslastRecipe- The last recipe matched if applicable, this will be checked after possibleRecipe but before all others- Returns:
The matched CraftingRebarRecipe or null if none was found
-
matchCookingRecipe
final static CookingRebarRecipe matchCookingRecipe(VanillaRecipeType<out CookingRebarRecipe, DummyCookingRebarRecipe> type, ItemStack input, ItemStack output, CookingRecipe<?> possibleRecipe, CookingRebarRecipe lastRecipe)
Takes in an input and output ItemStack and matches it (if possible) to a CookingRebarRecipe of a specific type. Because cooking blocks have an output buffer slot, we need to make sure the output matches so that it can fit.
possibleRecipe typically comes from FurnaceStartSmeltEvent.getRecipe or BlockCookEvent.getRecipe, It's what Minecraft thinks the correct recipe is, but because RebarItems use vanilla ingredients and RebarRecipes use our custom FluidOrItemChoice, it may not always be correct.
If you are using matchCraftingRecipe for a machine or something similar, storing the last matched recipe and passing it in as lastRecipe can speed up matching significantly, as the same recipe is often used multiple times in a row.
- Parameters:
type- The type of cooking recipe to match against (ex: furnace, smoker, campfire, etc.input- The input ItemStack to match against (ex: the top slot in a furnace)output- The output ItemStack to match against (ex: the right slot in a furnace)possibleRecipe- The possible bukkit Recipe that may or may not match input and output, tried before all other recipeslastRecipe- The last recipe matched if applicable, this will be checked after possibleRecipe but before all others- Returns:
The matched CookingRebarRecipe or null if none was found
-
matchSmithingRecipe
final static SmithingRebarRecipe matchSmithingRecipe(ItemStack template, ItemStack base, ItemStack addition, Recipe possibleRecipe, SmithingRebarRecipe lastRecipe)
Takes in a template and addition and matches them (if possible) to a SmithingRebarRecipe.
possibleRecipe typically comes from SmithingInventory.getRecipe, It's what Minecraft thinks the correct recipe is, but because RebarItems use vanilla ingredients and RebarRecipes use our custom FluidOrItemChoice, it may not always be correct.
If you are using matchCraftingRecipe for a machine or something similar, storing the last matched recipe and passing it in as lastRecipe can speed up matching significantly, as the same recipe is often used multiple times in a row.
- Parameters:
template- The template ItemStack to match against (or null if there isn't one)base- The base ItemStack to match against (or null if there isn't one)addition- The addition ItemStack to match against (or null if there isn't one)possibleRecipe- The possible bukkit Recipe that may or may not match the template, and addition, tried before all other recipeslastRecipe- The last recipe matched if applicable, this will be checked after possibleRecipe but before all others- Returns:
The matched SmithingRebarRecipe or null if none was found
-
-
-
-