PocketMine-MP
5.33.2 git-919492bdcad8510eb6606439eb77e1c604f1d1ea
Loading...
Searching...
No Matches
Enchantment.php
1
<?php
2
3
/*
4
*
5
* ____ _ _ __ __ _ __ __ ____
6
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10
*
11
* This program is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU Lesser General Public License as published by
13
* the Free Software Foundation, either version 3 of the License, or
14
* (at your option) any later version.
15
*
16
* @author PocketMine Team
17
* @link http://www.pocketmine.net/
18
*
19
*
20
*/
21
22
declare(strict_types=1);
23
24
namespace
pocketmine\item\enchantment;
25
26
use
pocketmine\lang\Translatable
;
27
use pocketmine\utils\NotCloneable;
28
use pocketmine\utils\NotSerializable;
29
use
pocketmine\utils\Utils
;
30
34
class
Enchantment
{
35
use NotCloneable;
36
use NotSerializable;
37
39
private \Closure $minEnchantingPower;
40
46
public
function
__construct
(
47
private
Translatable
|
string
$name,
48
private
int
$rarity,
49
private
int
$maxLevel,
50
?\Closure $minEnchantingPower =
null
,
51
private
int
$enchantingPowerRange = 50
52
){
53
$this->minEnchantingPower = $minEnchantingPower ?? fn(
int
$level) :
int
=> 1;
54
55
Utils::validateCallableSignature(fn(
int
$level) :
int
=> die(), $this->minEnchantingPower);
56
}
57
61
public
function
getName
() :
Translatable
|string{
62
return $this->name;
63
}
64
68
public
function
getRarity
() : int{
69
return $this->rarity;
70
}
71
75
public
function
getMaxLevel
() : int{
76
return $this->maxLevel;
77
}
78
82
public
function
isCompatibleWith
(
Enchantment
$other) : bool{
83
return
IncompatibleEnchantmentRegistry
::getInstance()->areCompatible($this, $other);
84
}
85
94
public
function
getMinEnchantingPower
(
int
$level) : int{
95
return ($this->minEnchantingPower)($level);
96
}
97
106
public
function
getMaxEnchantingPower
(
int
$level) : int{
107
return $this->getMinEnchantingPower($level) + $this->enchantingPowerRange;
108
}
109
}
pocketmine\item\enchantment\Enchantment
Definition
Enchantment.php:34
pocketmine\item\enchantment\Enchantment\getMaxLevel
getMaxLevel()
Definition
Enchantment.php:75
pocketmine\item\enchantment\Enchantment\isCompatibleWith
isCompatibleWith(Enchantment $other)
Definition
Enchantment.php:82
pocketmine\item\enchantment\Enchantment\__construct
__construct(private Translatable|string $name, private int $rarity, private int $maxLevel, ?\Closure $minEnchantingPower=null, private int $enchantingPowerRange=50)
Definition
Enchantment.php:46
pocketmine\item\enchantment\Enchantment\getMinEnchantingPower
getMinEnchantingPower(int $level)
Definition
Enchantment.php:94
pocketmine\item\enchantment\Enchantment\getRarity
getRarity()
Definition
Enchantment.php:68
pocketmine\item\enchantment\Enchantment\getName
getName()
Definition
Enchantment.php:61
pocketmine\item\enchantment\Enchantment\getMaxEnchantingPower
getMaxEnchantingPower(int $level)
Definition
Enchantment.php:106
pocketmine\item\enchantment\IncompatibleEnchantmentRegistry
Definition
IncompatibleEnchantmentRegistry.php:37
pocketmine\lang\Translatable
Definition
Translatable.php:28
pocketmine\utils\Utils
Definition
Utils.php:105
src
item
enchantment
Enchantment.php
Generated by
1.12.0