API reference / @jsprismarine/protocol / RecipeIngredient
Class: RecipeIngredient
Defined in: protocol/src/structure/RecipeIngredient.ts:53
One ingredient slot of a recipe: the variant selector, the descriptor's name and fields, then the count.
A named ingredient goes out under name rather than by numeric id, which is what every Bedrock server does here and what keeps a recipe readable against the item registry.
Extends
Constructors
Constructor
new RecipeIngredient(
descriptor?,count?):RecipeIngredient
Defined in: protocol/src/structure/RecipeIngredient.ts:59
Creates a slot.
Parameters
descriptor?
IngredientDescriptor | null = null
What the slot accepts, or null for an empty slot.
count?
number = 0
The stack size.
Returns
RecipeIngredient
Overrides
Properties
count
count:
number=0
Defined in: protocol/src/structure/RecipeIngredient.ts:61
The stack size.
descriptor
descriptor:
IngredientDescriptor|null=null
Defined in: protocol/src/structure/RecipeIngredient.ts:60
What the slot accepts, or null for an empty slot.
Methods
deserialize()
deserialize(
stream):void
Defined in: protocol/src/structure/RecipeIngredient.ts:115
Reads one slot, the mirror of serialize.
Every shape is read, including the ones nothing here produces: an unread shape does not cost that ingredient, it costs the rest of the packet. A molang descriptor is stepped over rather than returned, because IngredientDescriptor has no molang kind.
Parameters
stream
Returns
void
Throws
When the variant or the descriptor name is one this does not know, since either leaves the stream at an offset nothing after it can be read from.
Overrides
serialize()
serialize(
stream):void
Defined in: protocol/src/structure/RecipeIngredient.ts:77
Writes the selector, the descriptor and the count.
Parameters
stream
Returns
void
Overrides
toData()
toData():
RecipeIngredientData
Defined in: protocol/src/structure/RecipeIngredient.ts:72
The plain form, for a payload.
Returns
deserialize()
staticdeserialize<T>(this,stream):T
Defined in: protocol/src/NetworkStructure.ts:28
Deserializes the network structure from a binary stream. The constructor runs with no arguments before the stream is read, so the class must tolerate that.
Type Parameters
T
T extends NetworkStructure
Parameters
this
Constructor<T>
stream
The binary stream to deserialize from.
Returns
T
An instance of the class T.
Inherited from
from()
staticfrom(ingredient):RecipeIngredient
Defined in: protocol/src/structure/RecipeIngredient.ts:67
Builds a slot from the plain form.
Parameters
ingredient
Returns
RecipeIngredient