RecipeBook 5.47.0
Implements InventoryListener
The recipes a player has unlocked in the recipe book, saved with the player data like BDS (which keeps them server-side and tells the client with UnlockedRecipesPacket).
Recipes are unlocked when the player gets one of their unlocking ingredients in the inventory, or by context: the crafting table is always unlocked, boats when the player is in water and the chest when the inventory has items in RecipeUnlocking::MANY_ITEMS_SLOTS slots. The client applies the recipesunlock (false: everything unlocked) and showrecipemessages (toasts) game rules itself; doLimitedCrafting is enforced by RecipeBook::canCraft().
Constants
TAG_UNLOCKED_RECIPES
public const TAG_UNLOCKED_RECIPES = "UnlockedRecipes"Methods
__construct()
public function __construct(\pocketmine\player\Player $player)canCraft()
public function canCraft(\pocketmine\crafting\CraftingRecipe $recipe) : boolWhether the player may craft this recipe: with the doLimitedCrafting game rule only unlocked recipes can be crafted (unless recipesunlock is false, which unlocks everything).
getUnlockedRecipes()
public function getUnlockedRecipes() : arrayReturns the IDs of the recipes the player unlocked (recipes that are always unlocked are not included).
isUnlocked()
public function isUnlocked(string $recipeId) : boolisWaitingForWater()
public function isWaitingForWater() : boolWhether the player still has recipes that being in water unlocks (boats): the player checks it every second.
unlockRecipes()
public function unlockRecipes(array $recipeIds) : voidUnlocks recipes by ID (see RecipeUnlockIndex::getRecipeId()); the client shows the "new recipes unlocked" toast for them.
