Перейти к основному содержанию

Recipes

Module used to manipulate crafting recipes for vanilla and custom workbenches.

Index

Classes

WorkbenchUIHandler

WorkbenchUIHandler:

Class used to simplify creation of custom workbenches.

constructor

deselectCurrentRecipe

  • deselectCurrentRecipe(): void
  • Deselects current recipe (asynchronously).


    Returns void

refresh

  • refresh(): number
  • Refreshes all the recipes in the workbench.


    Returns number

    Amount of recipes displayed.

refreshAsync

  • refreshAsync(): void

setMaximumRecipesToShow

  • setMaximumRecipesToShow(count: number): void
  • Sets workbench recipes displaying limit.


    Parameters

    • count: number

      count of the recipes to show

    Returns void

setOnRefreshListener

  • setOnRefreshListener(listener: { onRefreshCompleted: (count: number) => void; onRefreshStarted: () => void }): void
  • Registers listener to be notified when the workbench starts and completes refreshing.


    Parameters

    • listener: { onRefreshCompleted: (count: number) => void; onRefreshStarted: () => void }

      workbench refresh listener

      • onRefreshCompleted: (count: number) => void
      • onRefreshStarted: () => void

    Returns void

setOnSelectionListener

  • setOnSelectionListener(listener: { onRecipeSelected: (recipe: WorkbenchRecipe) => void }): void
  • Registers listener to be notified when some recipe is selected.


    Parameters

    Returns void

setPrefix

  • setPrefix(prefix: string): void
  • Sets custom workbench prefix.


    Parameters

    • prefix: string

      custom workbench prefix

    Returns void

Interfaces

CraftingFunction

FurnaceRecipe

FurnaceRecipe:

Object representing furnace recipe.

readonlyinData

inData: number

readonlyinId

inId: number

readonlyresData

resData: number

readonlyresId

resId: number

publicclone

  • clone(): any
  • Returns any

publicequals

  • equals(param0: any): boolean
  • Parameters

    • param0: any

    Returns boolean

publicfinalize

  • finalize(): void
  • Returns void

publicgetClass

  • getClass(): Class<any>
  • Returns Class<any>

getInputKey

  • getInputKey(): number
  • Returns number

getPrefix

  • getPrefix(): string

  • Returns string

    Recipe prefix.

getResult

publichashCode

  • hashCode(): number
  • Returns number

isMatchingPrefix

  • isMatchingPrefix(prefix: string): boolean
  • Compares current recipe's prefix with given one.


    Parameters

    • prefix: string

      prefix value to compare with

    Returns boolean

    true, if current recipe's prefix is the same as given one, false otherwise.

isValid

  • isValid(): boolean

  • Returns boolean

    true, if the recipe is valid, false otherwise.

publicnotify

  • notify(): void
  • Returns void

publicnotifyAll

  • notifyAll(): void
  • Returns void

setPrefix

  • setPrefix(prefix: string): void
  • Sets prefix value for the recipe.


    Parameters

    • prefix: string

      new prefix value

    Returns void

publictoString

  • toString(): string
  • Returns string

publicwait

  • wait(): void
  • wait(param0: number): void
  • wait(param0: number, param1: number): void
  • Returns void

RecipeEntry

RecipeEntry:

Crafting recipe entry.

readonlydata

data: number

readonlyid

id: number

getCode

  • getCode(): number
  • Returns number

getCodeByItem

  • getCodeByItem(id: number, data: number): number
  • Parameters

    • id: number
    • data: number

    Returns number

getMask

  • getMask(): string
  • Returns string

isMatching


  • Parameters

    Returns boolean

    true if recipe entry matches the slot.

WorkbenchField

WorkbenchField:

Object representing workbench field.

asScriptableField

getFieldSlot


  • Parameters

    • slot: number

      slot index

    Returns AbstractSlot

    Workbench slot instance by slot index.

getWorkbenchFieldSize

  • getWorkbenchFieldSize(): number
  • @since

    2.2.1b106


    Returns number

WorkbenchFieldAPI

WorkbenchFieldAPI:

Object used to work with workbench field in the craft function.

decreaseFieldSlot

  • decreaseFieldSlot(slot: number): void
  • Decreases item count in the specified slot, if possible.


    Parameters

    • slot: number

      slot index

    Returns void

getFieldSize

  • getFieldSize(): number
  • @since

    2.2.1b106


    Returns number

getFieldSlot

  • getFieldSlot(slot: number): Slot

  • Parameters

    • slot: number

      slot index

    Returns Slot

    Workbench slot instance by slot index.

isPrevented

  • isPrevented(): boolean

  • Returns boolean

    true, if crafting event was prevented, false otherwise.

prevent

  • prevent(): void
  • Prevents crafting event.


    Returns void

WorkbenchRecipe

WorkbenchRecipe:

Object representing workbench recipe.

addToVanillaWorkbench

  • addToVanillaWorkbench(): void
  • Returns void

publicclone

  • clone(): any
  • Returns any

publicequals

  • equals(param0: any): boolean
  • Parameters

    • param0: any

    Returns boolean

publicfinalize

  • finalize(): void
  • Returns void

getCallback


  • Returns CraftingFunction

    Current crafting function or null if no one was specified.

publicgetClass

  • getClass(): Class<any>
  • Returns Class<any>

getEntry


  • Parameters

    • c: string

      recipe entry character

    Returns RecipeEntry

    Recipe entry by entry character.

getEntryCodes

  • getEntryCodes(): ArrayList<Long>
  • Returns ArrayList<Long>

getEntryCollection

getPrefix

  • getPrefix(): string

  • Returns string

    Recipe prefix.

getRecipeMask

  • getRecipeMask(): string

  • Returns string

    Recipe unique mask identifier.

getRecipeUid

  • getRecipeUid(): number
  • Returns number

getResult

getSortedEntries


  • Returns Array<RecipeEntry>

    All recipe's entries in a java array.

publichashCode

  • hashCode(): number
  • Returns number

isMatchingField


  • Parameters

    Returns boolean

    true if the field contains this recipe, false` otherwise.

isMatchingPrefix

  • isMatchingPrefix(prefix: string): boolean
  • Compares current recipe's prefix with given one.


    Parameters

    • prefix: string

      prefix value to compare with

    Returns boolean

    true, if current recipe's prefix is the same as given one, false otherwise.

isMatchingResult

  • isMatchingResult(id: number, count: number, data: number): boolean

  • Parameters

    • id: number
    • count: number
    • data: number

    Returns boolean

    true if specified item is recipe's result, false otherwise.

isPossibleForInventory

  • isPossibleForInventory(inv: HashMap<Long, Integer>): boolean
  • Parameters

    • inv: HashMap<Long, Integer>

    Returns boolean

isValid

  • isValid(): boolean

  • Returns boolean

    true, if the recipe is valid, false otherwise.

isVanilla

  • isVanilla(): boolean
  • Returns boolean

publicnotify

  • notify(): void
  • Returns void

publicnotifyAll

  • notifyAll(): void
  • Returns void

provideRecipe

provideRecipeForPlayer

putIntoTheField

  • Tries to fill workbench field with current recipe.


    Parameters

    Returns void

setCallback

  • Sets craft function for the recipe.


    Parameters

    Returns void

setEntries

  • setEntries(entries: HashMap<Character, RecipeEntry>): void
  • Parameters

    Returns void

setPrefix

  • setPrefix(prefix: string): void
  • Sets prefix value for the recipe.


    Parameters

    • prefix: string

      new prefix value

    Returns void

setVanilla


  • Parameters

    • isVanilla: boolean

    Returns WorkbenchRecipe

    Reference to itself to be used in sequential calls.

publictoString

  • toString(): string
  • Returns string

publicwait

  • wait(): void
  • wait(param0: number): void
  • wait(param0: number, param1: number): void
  • Returns void

WorkbenchShapedRecipe

WorkbenchShapedRecipe:

Object representing workbench shaped recipe.

addToVanillaWorkbench

  • addToVanillaWorkbench(): void
  • Returns void

addVariants

publicclone

  • clone(): any
  • Returns any

publicequals

  • equals(param0: any): boolean
  • Parameters

    • param0: any

    Returns boolean

publicfinalize

  • finalize(): void
  • Returns void

getCallback


  • Returns CraftingFunction

    Current crafting function or null if no one was specified.

publicgetClass

  • getClass(): Class<any>
  • Returns Class<any>

getEntry


  • Parameters

    • c: string

      recipe entry character

    Returns RecipeEntry

    Recipe entry by entry character.

getEntryCodes

  • getEntryCodes(): ArrayList<Long>
  • Returns ArrayList<Long>

getEntryCollection

  • Returns Collection<RecipeEntry>

getPrefix

  • getPrefix(): string

  • Returns string

    Recipe prefix.

getRecipeMask

  • getRecipeMask(): string

  • Returns string

    Recipe unique mask identifier.

getRecipeUid

  • getRecipeUid(): number
  • Returns number

getResult


  • Returns ItemInstance

    Resulting item instance.

getSortedEntries


  • Returns Array<RecipeEntry>

    All recipe's entries in a java array.

publichashCode

  • hashCode(): number
  • Returns number

isMatchingField


  • Parameters

    Returns boolean

    true if the field contains this recipe, false` otherwise.

isMatchingPrefix

  • isMatchingPrefix(prefix: string): boolean
  • Compares current recipe's prefix with given one.


    Parameters

    • prefix: string

      prefix value to compare with

    Returns boolean

    true, if current recipe's prefix is the same as given one, false otherwise.

isMatchingResult

  • isMatchingResult(id: number, count: number, data: number): boolean

  • Parameters

    • id: number
    • count: number
    • data: number

    Returns boolean

    true if specified item is recipe's result, false otherwise.

isPossibleForInventory

  • isPossibleForInventory(inv: HashMap<Long, Integer>): boolean
  • Parameters

    • inv: HashMap<Long, Integer>

    Returns boolean

isValid

  • isValid(): boolean

  • Returns boolean

    true, if the recipe is valid, false otherwise.

isVanilla

  • isVanilla(): boolean
  • Returns boolean

publicnotify

  • notify(): void
  • Returns void

publicnotifyAll

  • notifyAll(): void
  • Returns void

provideRecipe

provideRecipeForPlayer

putIntoTheField

  • Tries to fill workbench field with current recipe.


    Parameters

    Returns void

setCallback

  • Sets craft function for the recipe.


    Parameters

    Returns void

setEntries

  • setEntries(entries: HashMap<Character, RecipeEntry>): void
  • Parameters

    Returns void

setPattern

  • setPattern(pattern: string[]): void
  • setPattern(pattern: RecipeEntry[][]): void
  • Parameters

    • pattern: string[]

    Returns void

setPrefix

  • setPrefix(prefix: string): void
  • Sets prefix value for the recipe.


    Parameters

    • prefix: string

      new prefix value

    Returns void

setVanilla


  • Parameters

    • isVanilla: boolean

    Returns WorkbenchRecipe

    Reference to itself to be used in sequential calls.

publictoString

  • toString(): string
  • Returns string

publicwait

  • wait(): void
  • wait(param0: number): void
  • wait(param0: number, param1: number): void
  • Returns void

WorkbenchShapelessRecipe

WorkbenchShapelessRecipe:

Object representing workbench shapeless recipe.

addToVanillaWorkbench

  • addToVanillaWorkbench(): void
  • Returns void

addVariants

publicclone

  • clone(): any
  • Returns any

publicequals

  • equals(param0: any): boolean
  • Parameters

    • param0: any

    Returns boolean

publicfinalize

  • finalize(): void
  • Returns void

getCallback


  • Returns CraftingFunction

    Current crafting function or null if no one was specified.

publicgetClass

  • getClass(): Class<any>
  • Returns Class<any>

getEntry


  • Parameters

    • c: string

      recipe entry character

    Returns RecipeEntry

    Recipe entry by entry character.

getEntryCodes

  • getEntryCodes(): ArrayList<Long>
  • Returns ArrayList<Long>

getEntryCollection

  • Returns Collection<RecipeEntry>

getPrefix

  • getPrefix(): string

  • Returns string

    Recipe prefix.

getRecipeMask

  • getRecipeMask(): string

  • Returns string

    Recipe unique mask identifier.

getRecipeUid

  • getRecipeUid(): number
  • Returns number

getResult


  • Returns ItemInstance

    Resulting item instance.

getSortedEntries


  • Returns Array<RecipeEntry>

    All recipe's entries in a java array.

publichashCode

  • hashCode(): number
  • Returns number

isMatchingField


  • Parameters

    Returns boolean

    true if the field contains this recipe, false` otherwise.

isMatchingPrefix

  • isMatchingPrefix(prefix: string): boolean
  • Compares current recipe's prefix with given one.


    Parameters

    • prefix: string

      prefix value to compare with

    Returns boolean

    true, if current recipe's prefix is the same as given one, false otherwise.

isMatchingResult

  • isMatchingResult(id: number, count: number, data: number): boolean

  • Parameters

    • id: number
    • count: number
    • data: number

    Returns boolean

    true if specified item is recipe's result, false otherwise.

isPossibleForInventory

  • isPossibleForInventory(inv: HashMap<Long, Integer>): boolean
  • Parameters

    • inv: HashMap<Long, Integer>

    Returns boolean

isValid

  • isValid(): boolean

  • Returns boolean

    true, if the recipe is valid, false otherwise.

isVanilla

  • isVanilla(): boolean
  • Returns boolean

publicnotify

  • notify(): void
  • Returns void

publicnotifyAll

  • notifyAll(): void
  • Returns void

provideRecipe

provideRecipeForPlayer

putIntoTheField

  • Tries to fill workbench field with current recipe.


    Parameters

    Returns void

setCallback

  • Sets craft function for the recipe.


    Parameters

    Returns void

setEntries

  • setEntries(entries: HashMap<Character, RecipeEntry>): void
  • Parameters

    Returns void

setPrefix

  • setPrefix(prefix: string): void
  • Sets prefix value for the recipe.


    Parameters

    • prefix: string

      new prefix value

    Returns void

setVanilla


  • Parameters

    • isVanilla: boolean

    Returns WorkbenchRecipe

    Reference to itself to be used in sequential calls.

publictoString

  • toString(): string
  • Returns string

publicwait

  • wait(): void
  • wait(param0: number): void
  • wait(param0: number, param1: number): void
  • Returns void

Functions

addFurnace

  • addFurnace(sourceId: number, sourceData: number, resultId: number, resultData: number, prefix?: string): void
  • addFurnace(sourceId: number, resultId: number, resultData: number, prefix?: string): void
  • Adds new furnace recipe.


    Parameters

    • sourceId: number

      source item ID

    • sourceData: number

      source item data

    • resultId: number

      resulting item ID

    • resultData: number

      resulting item data

    • optionalprefix: string

      prefix, used to create recipes for non-vanilla furnaces

    Returns void

addFurnaceFuel

  • addFurnaceFuel(id: number, data: number, time: number): void
  • Adds fuel that can be used in the furnace.


    Parameters

    • id: number

      fuel item ID

    • data: number

      fuel item data

    • time: number

      burning time in ticks

    Returns void

addShaped

  • Adds new shaped crafting recipe.

    @example
    Recipes.addShaped({ id: 264, count: 1, data: 0 }, [
    "ax",
    "xa",
    "ax"
    ], ['x', 265, 0, 'a', 266, 0]);
    @remarks

    Pickaxe recipe should look like this:

    "+++"
    " | "
    " | "

    Do not use empty lines or line endings, if the recipe can be placed within less then three rows or cols; e.g., to craft plates, you can use a shape like this:

    "--"

    Parameters

    • result: ItemInstance

      recipe result item

    • mask: string[]

      recipe shape, up to three string corresponding to the three crafting field rows; each character means one item in the field

    • data: (string | number)[]

      an array explaining the meaning of each character within mask. The array should contain three values for each symbol: the symbol itself, item ID and item data.

    • optionalfunc: CraftingFunction

      function to be called when the craft is processed

    • optionalprefix: string

      recipe prefix. Use a non-empty values to register recipes for custom workbenches

    Returns WorkbenchShapedRecipe

addShaped2

  • Same as Recipes.addShaped, but you can specify result as three separate values corresponding to ID, count and data.


    Parameters

    • id: number
    • count: number
    • aux: number
    • mask: string[]
    • data: (string | number)[]
    • optionalfunc: CraftingFunction
    • optionalprefix: string

    Returns WorkbenchShapedRecipe

addShapedGeneric

addShapedVanilla

addShapeless

  • Adds new shapeless crafting recipe.

    @example
    Recipes.addShapeless({ id: 264, count: 1, data: 0 }, [
    { id: 265, data: 0 }, { id: 265, data: 0 }, { id: 265, data: 0 },
    { id: 266, data: 0 }, { id: 266, data: 0 }, { id: 266, data: 0 }
    ]);

    Parameters

    • result: ItemInstance

      recipe result item

    • data: { data: number; id: number }[]

      crafting ingredients, an array of objects representing item ID and data

    • optionalfunc: CraftingFunction

      function to be called when the craft is processed

    • optionalprefix: string

      recipe prefix; use a non-empty values to register recipes for custom workbenches

    Returns WorkbenchShapelessRecipe

addShapelessGeneric

addShapelessVanilla

deleteRecipe

  • Deletes recipe by it's result.


    Parameters

    Returns void

getAllFurnaceRecipes

  • @since

    2.2.1b96


    Returns java.util.Collection<FurnaceRecipe>

    Collection object with all registered furnace recipes.

getAllWorkbenchRecipes

  • @since

    2.2.1b96


    Returns java.util.Collection<WorkbenchRecipe>

    Collection object with all registered workbench recipes.

getFuelBurnDuration

  • getFuelBurnDuration(id: number, data: number): number

  • Parameters

    • id: number
    • data: number

    Returns number

    Fuel burn duration by fuel item ID and data.

getFurnaceRecipeResult

  • getFurnaceRecipeResult(id: number, data: number, prefix?: string): ItemInstance

  • Parameters

    • id: number
    • data: number
    • optionalprefix: string

      recipe prefix used for non-vanilla furnaces

    Returns ItemInstance

    Furnace recipe resulting item.

getFurnaceRecipesByResult

  • getFurnaceRecipesByResult(resultId: number, resultData: number, prefix: string): java.util.Collection<FurnaceRecipe>
  • Gets furnace recipes by result and custom prefix.


    Parameters

    • resultId: number

      result item ID

    • resultData: number

      result item data

    • prefix: string

      recipe prefix used for non-vanilla furnaces

    Returns java.util.Collection<FurnaceRecipe>

    Collection object with all furnace recipes found by given params.

getRecipeByField

getRecipeResult

  • Gets recipe result item by the field and recipe prefix.


    Parameters

    • field: WorkbenchField

      WorkbenchField object containing crafting field information

    • optionalprefix: string

      recipe prefix, defaults to empty string (vanilla workbench)

    Returns Nullable<ItemInstance>

getWorkbenchRecipesByIngredient

  • getWorkbenchRecipesByIngredient(id: number, data: number): java.util.Collection<WorkbenchRecipe>

getWorkbenchRecipesByResult

  • getWorkbenchRecipesByResult(id: number, count: number, data: number): java.util.Collection<WorkbenchRecipe>
  • Gets all available recipes for the recipe result.


    Parameters

    • id: number
    • count: number
    • data: number

    Returns java.util.Collection<WorkbenchRecipe>

    Collection object containing Recipes.WorkbenchRecipe.

provideRecipe

  • Performs crafting by the field contents and recipe prefix.


    Parameters

    • field: WorkbenchField

      WorkbenchField object containing crafting field information

    • optionalprefix: string

      recipe prefix, defaults to empty string (vanilla workbench)

    Returns Nullable<ItemInstance>

removeFurnaceFuel

  • removeFurnaceFuel(id: number, data: number): void
  • Removes furnace fuel by fuel item ID and data.


    Parameters

    • id: number
    • data: number

    Returns void

removeFurnaceRecipe

  • removeFurnaceRecipe(sourceId: number, sourceData: number): void
  • Removes furnace recipes by source item.


    Parameters

    • sourceId: number

      source item ID

    • sourceData: number

      source item data

    Returns void

removeWorkbenchRecipe

  • removeWorkbenchRecipe(id: number, count: number, data: number): void
  • Removes recipe by result ID, count and data.


    Parameters

    • id: number
    • count: number
    • data: number

    Returns void