CVanillaRecipe
What is CVanillaRecipe
Section titled “What is CVanillaRecipe”CVanillaRecipe is a CRecipe wrapper for vanilla Bukkit Recipe instances.
It allows vanilla crafting recipes to be used as CRecipe, making them compatible with CustomCrafter features such as PartialSearch.
The constructor is internal and cannot be called directly. Use the provided factory methods to create instances.
Factory Methods
Section titled “Factory Methods”fromVanilla()
Section titled “fromVanilla()”Converts a vanilla CraftingRecipe to a CVanillaRecipe.
Dispatches to fromShaped(), fromShapeless(), or fromTransmute() based on the runtime type.
Returns null if the recipe type is not supported.
@JvmStaticfun fromVanilla(recipe: CraftingRecipe): CVanillaRecipe?fromShaped()
Section titled “fromShaped()”Converts a vanilla ShapedRecipe.
@JvmStaticfun fromShaped(recipe: ShapedRecipe): CVanillaRecipeThe recipe shape and ingredient map are converted into a Map<CoordinateComponent, CMatter>.
Each CMatter uses a CMatterPredicate backed by RecipeChoice.test(), so NBT and exact-item choices are respected.
fromShapeless()
Section titled “fromShapeless()”Converts a vanilla ShapelessRecipe.
@JvmStaticfun fromShapeless(recipe: ShapelessRecipe): CVanillaRecipeIngredients are mapped to sequential coordinates via CoordinateComponent.fromIndex().
Each CMatter uses a CMatterPredicate backed by RecipeChoice.test().
fromTransmute()
Section titled “fromTransmute()”Converts a vanilla TransmuteRecipe. Added in 5.0.21.
@JvmStaticfun fromTransmute(recipe: TransmuteRecipe): CVanillaRecipeA TransmuteRecipe is a crafting recipe where a source item (input) has its type changed to result when combined with a catalyst item (material).
The converted CVanillaRecipe is SHAPELESS with two slots — one for the source and one for the catalyst.
The ResultSupplier finds the item matching recipe.input in the crafting grid and returns a copy with the type replaced by recipe.result.type.
// Example: wrap all vanilla transmute recipes and register themBukkit.recipeIterator().asSequence() .filterIsInstance<TransmuteRecipe>() .mapNotNull { CVanillaRecipe.fromTransmute(it) } .forEach { CustomCrafterAPI.registerVanillaRecipe(it) }relateWith()
Section titled “relateWith()”Builds a MappedRelation by pairing this recipe’s slots against the given CraftView in index order.
fun relateWith(view: CraftView): MappedRelation| Condition | Behavior |
|---|---|
Non-air item count in view ≠ recipe slot count | Throws IllegalArgumentException |
| View spans more than 4 columns or 4 rows | Throws IllegalArgumentException |
original
Section titled “original”The original Bukkit Recipe instance is accessible via the original property.
val original: RecipeCVanillaRecipe + PartialSearch
Section titled “CVanillaRecipe + PartialSearch”Because CVanillaRecipe implements CRecipe, it is compatible with PartialSearch.
This enables partial matching for vanilla recipes, which is not available in the Bukkit API.
val vanillaRecipes: List<CVanillaRecipe> = Bukkit.recipeIterator().asSequence() .filterIsInstance<CraftingRecipe>() .mapNotNull { CVanillaRecipe.fromVanilla(it) } .toList()
// Asynchronous partial search against vanilla recipesval result: PartialSearch.PartialSearchResult = PartialSearch.asyncPartialSearch( recipes = vanillaRecipes, view = currentView, query = SearchQuery(asyncContext = ctx)).await()