pub trait RecipeContext {
// Required methods
fn unlock(&self, id: &RecipeId, reason: UnlockReason);
fn lock(&self, id: &RecipeId);
fn has(&self, id: &RecipeId) -> bool;
fn unlocked(&self) -> Vec<RecipeId>;
}Expand description
Per-player recipe-book state.
Plugins use this to grant or revoke recipes for the current player
— the dispatch context’s player. Mutations queue a deferred
response that the game loop translates into the appropriate S2C
recipe-book packet and dispatches RecipeUnlockedEvent /
RecipeLockedEvent after commit.
has and unlocked are synchronous reads against the player’s
KnownRecipes component.
Required Methods§
Sourcefn unlock(&self, id: &RecipeId, reason: UnlockReason)
fn unlock(&self, id: &RecipeId, reason: UnlockReason)
Unlocks the recipe for the current player.
Queues a Recipe Book Add packet, inserts into the player’s
KnownRecipes, and dispatches RecipeUnlockedEvent at Post.
No-op if the recipe is already unlocked.
Sourcefn lock(&self, id: &RecipeId)
fn lock(&self, id: &RecipeId)
Locks the recipe for the current player.
Queues a Recipe Book Remove packet, removes from the player’s
KnownRecipes, and dispatches RecipeLockedEvent at Post.
No-op if the recipe is not currently unlocked.