Skip to content

Enchantment ​

class · pocketmine\item\enchantment\Enchantment · source

Manages enchantment type data.

Methods ​

__construct() ​

php
public function __construct(\pocketmine\lang\Translatable|string $name, int $rarity, int $primaryItemFlags, int $secondaryItemFlags, int $maxLevel, ?\Closure $minEnchantingPower = null, int $enchantingPowerRange = 50)

getMaxEnchantingPower() ​

php
public function getMaxEnchantingPower(int $level) : int

Returns the maximum enchanting power value allowed for the particular level of the enchantment to be available in an enchanting table.

Enchanting power is a random value based on the number of bookshelves around an enchanting table and the enchantability of the item being enchanted. It is only used when determining the available enchantments for the enchantment options.

getMaxLevel() ​

php
public function getMaxLevel() : int

Returns the maximum level of this enchantment that can be found on an enchantment table.

getMinEnchantingPower() ​

php
public function getMinEnchantingPower(int $level) : int

Returns the minimum enchanting power value required for the particular level of the enchantment to be available in an enchanting table.

Enchanting power is a random value based on the number of bookshelves around an enchanting table and the enchantability of the item being enchanted. It is only used when determining the available enchantments for the enchantment options.

getName() ​

php
public function getName() : \pocketmine\lang\Translatable|string

Returns a translation key for this enchantment's name.

getPrimaryItemFlags() ​

php
public function getPrimaryItemFlags() : int

Deprecated

Deprecated.

Returns a bitset indicating what item types can have this item applied from an enchanting table.

getRarity() ​

php
public function getRarity() : int

Returns an int constant indicating how rare this enchantment type is.

getSecondaryItemFlags() ​

php
public function getSecondaryItemFlags() : int

Deprecated

Deprecated.

Returns a bitset indicating what item types cannot have this item applied from an enchanting table, but can from an anvil.

hasPrimaryItemType() ​

php
public function hasPrimaryItemType(int $flag) : bool

Deprecated

Deprecated.

Returns whether this enchantment can apply to the item type from an enchanting table.

hasSecondaryItemType() ​

php
public function hasSecondaryItemType(int $flag) : bool

Deprecated

Deprecated.

Returns whether this enchantment can apply to the item type from an anvil, if it is not a primary item.

isCompatibleWith() ​

php
public function isCompatibleWith(\pocketmine\item\enchantment\Enchantment $other) : bool

Returns whether this enchantment can be applied to the item along with the given enchantment.

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.