Skip to content

RecipeBook 5.47.0 ​

final class · pocketmine\player\RecipeBook · source

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 ​

php
public const TAG_UNLOCKED_RECIPES = "UnlockedRecipes"

Methods ​

__construct() ​

php
public function __construct(\pocketmine\player\Player $player)

canCraft() ​

php
public function canCraft(\pocketmine\crafting\CraftingRecipe $recipe) : bool

Whether 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() ​

php
public function getUnlockedRecipes() : array

Returns the IDs of the recipes the player unlocked (recipes that are always unlocked are not included).

isUnlocked() ​

php
public function isUnlocked(string $recipeId) : bool

isWaitingForWater() ​

php
public function isWaitingForWater() : bool

Whether the player still has recipes that being in water unlocks (boats): the player checks it every second.

unlockRecipes() ​

php
public function unlockRecipes(array $recipeIds) : void

Unlocks recipes by ID (see RecipeUnlockIndex::getRecipeId()); the client shows the "new recipes unlocked" toast for them.

VanillaMine is a fork of PocketMine-MP. Not affiliated with the PMMP team or Mojang.