API reference / @jsprismarine/prismarine / enchantment/anvil
enchantment/anvil
Interfaces
AnvilAttempt
Defined in: packages/prismarine/src/enchantment/anvil.ts:40
What the anvil was given.
Properties
addition?
readonlyoptionaladdition?:Item
Defined in: packages/prismarine/src/enchantment/anvil.ts:44
Right slot: a repair material, a second copy, or an enchanted book.
base
readonlybase:Item
Defined in: packages/prismarine/src/enchantment/anvil.ts:42
Left slot: the item being worked on.
name?
readonlyoptionalname?:string
Defined in: packages/prismarine/src/enchantment/anvil.ts:46
The name the player typed, or undefined when the field was not touched.
unlimitedMaterials?
readonlyoptionalunlimitedMaterials?:boolean
Defined in: packages/prismarine/src/enchantment/anvil.ts:48
Bookshelf-free, but creative still ignores the ceiling.
AnvilOutcome
Defined in: packages/prismarine/src/enchantment/anvil.ts:95
What a completed anvil use produced.
Properties
cost
readonlycost:number
Defined in: packages/prismarine/src/enchantment/anvil.ts:98
Experience levels actually spent.
materialCost
readonlymaterialCost:number
Defined in: packages/prismarine/src/enchantment/anvil.ts:100
How many of the right stack a material repair consumed.
onlyRenaming
readonlyonlyRenaming:boolean
Defined in: packages/prismarine/src/enchantment/anvil.ts:102
Whether the name was all the anvil changed, which leaves the right stack in place.
stack
readonlystack:Item
Defined in: packages/prismarine/src/enchantment/anvil.ts:96
AnvilPreview
Defined in: packages/prismarine/src/enchantment/anvil.ts:34
What the anvil would make of two stacks, without changing anything.
Extends
Properties
cost
readonlycost:number
Defined in: packages/enchantments/src/anvil.ts:48
Experience levels the player pays.
Inherited from
materialCost
readonlymaterialCost:number
Defined in: packages/enchantments/src/anvil.ts:50
How many of the right stack a material repair consumes.
Inherited from
onlyRenaming
readonlyonlyRenaming:boolean
Defined in: packages/enchantments/src/anvil.ts:52
Whether the only change is the name, which is what lifts the cost ceiling to 39.
Inherited from
output
readonlyoutput:ItemStack|undefined
Defined in: packages/enchantments/src/anvil.ts:46
The result stack, or undefined when the anvil rejects the combination.
Inherited from
stack
readonlystack:Item|undefined
Defined in: packages/prismarine/src/enchantment/anvil.ts:36
The result as this server's stacks, or undefined when the anvil refuses.
AnvilResultViewer
Defined in: packages/prismarine/src/enchantment/anvil.ts:177
Who is shown an anvil's result: the session whose presenter draws it.
Properties
presenter
readonlypresenter:Pick<SessionPresenter,"showAnvilResult">
Defined in: packages/prismarine/src/enchantment/anvil.ts:178
Variables
ANVIL_LEVEL_CEILING
constANVIL_LEVEL_CEILING:40=40
Defined in: packages/prismarine/src/enchantment/anvil.ts:31
Levels at or above which the anvil refuses, unless the player has unlimited materials.
Functions
anvilPreview()
anvilPreview(
registry,attempt):AnvilPreview
Defined in: packages/prismarine/src/enchantment/anvil.ts:80
What the anvil would produce for one attempt.
Nothing changes here: the preview is what the client's own anvil screen would show if it could be trusted to compute it, and it cannot be whenever a server-side enchantment is involved, so the server sends the answer.
Parameters
registry
attempt
Returns
showAnvilResult()
showAnvilResult(
viewer,open,registry,unlimitedMaterials):Promise<void>
Defined in: packages/prismarine/src/enchantment/anvil.ts:192
Works an open anvil's result out from its two inputs and the name the player typed, and shows it with its cost, as vanilla's menu does whenever an input or the name changes. Nothing is shown in the result slot while the left slot is empty or the anvil refuses the two.
Parameters
viewer
Who is shown the result.
open
The open anvil, whose window keeps the inputs and the typed name.
registry
The server's enchantments, which the result is worked out over.
unlimitedMaterials
boolean
Whether the player has infinite materials, who has no level ceiling.
Returns
Promise<void>
Java See
AnvilMenu.createResult
takeFromAnvil()
takeFromAnvil(
registry,player,attempt):AnvilOutcome|undefined
Defined in: packages/prismarine/src/enchantment/anvil.ts:112
Takes the anvil's result and charges for it.
Parameters
registry
player
getExperience
() => ExperienceHolder
attempt
Returns
AnvilOutcome | undefined
Undefined when the anvil refuses the combination, when the cost is at the ceiling, or when the player cannot pay. Nothing is spent in any of those cases.
takeFromAnvilSlots()
takeFromAnvilSlots(
registry,player,inputs,name?,unlimitedMaterials?):AnvilOutcome|undefined
Defined in: packages/prismarine/src/enchantment/anvil.ts:148
Takes the result of an anvil's two slots and spends them as vanilla's anvil does: the left stack always, and the right one by what the result used of it. A material repair uses that many of the stack and leaves the rest, a pure rename leaves the right stack where it is, and anything else uses it up.
Parameters
registry
player
getExperience
() => ExperienceHolder
inputs
(Item | null)[]
The anvil's two slots, left then right, which are written back.
name?
string
The name the player typed, or undefined when the field was not touched.
unlimitedMaterials?
boolean = false
Whether the player has infinite materials, who pays no levels.
Returns
AnvilOutcome | undefined
Undefined, with nothing spent, when takeFromAnvil refuses.
Java Source
AnvilMenu.onTake