Skip to content

ItemEnchantmentHandlingTrait ​

trait · pocketmine\item\ItemEnchantmentHandlingTrait · source

This trait encapsulates all enchantment handling needed for itemstacks. The primary purpose of this trait is providing scope isolation for the methods it contains.

Properties ​

$enchantments protected ​

php
protected array $enchantments

Methods ​

addEnchantment() ​

php
public function addEnchantment(\pocketmine\item\enchantment\EnchantmentInstance $enchantment) : self

getEnchantment() ​

php
public function getEnchantment(\pocketmine\item\enchantment\Enchantment $enchantment) : ?\pocketmine\item\enchantment\EnchantmentInstance

getEnchantmentLevel() ​

php
public function getEnchantmentLevel(\pocketmine\item\enchantment\Enchantment $enchantment) : int

Returns the level of the enchantment on this item with the specified ID, or 0 if the item does not have the enchantment.

getEnchantments() ​

php
public function getEnchantments() : array

hasEnchantment() ​

php
public function hasEnchantment(\pocketmine\item\enchantment\Enchantment $enchantment, int $level = -1) : bool

hasEnchantments() ​

php
public function hasEnchantments() : bool

removeEnchantment() ​

php
public function removeEnchantment(\pocketmine\item\enchantment\Enchantment $enchantment, int $level = -1) : self

removeEnchantments() ​

php
public function removeEnchantments() : self

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