mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 07:39:42 +00:00
phpdoc armageddon for master, pass 1
This commit is contained in:
@@ -220,27 +220,15 @@ class Enchantment{
|
||||
|
||||
/**
|
||||
* Registers an enchantment type.
|
||||
*
|
||||
* @param Enchantment $enchantment
|
||||
*/
|
||||
public static function register(Enchantment $enchantment) : void{
|
||||
self::$enchantments[$enchantment->getId()] = clone $enchantment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return Enchantment|null
|
||||
*/
|
||||
public static function get(int $id) : ?Enchantment{
|
||||
return self::$enchantments[$id] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return Enchantment|null
|
||||
*/
|
||||
public static function fromString(string $name) : ?Enchantment{
|
||||
$const = Enchantment::class . "::" . strtoupper($name);
|
||||
if(defined($const)){
|
||||
@@ -262,14 +250,6 @@ class Enchantment{
|
||||
/** @var int */
|
||||
private $maxLevel;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
* @param int $rarity
|
||||
* @param int $primaryItemFlags
|
||||
* @param int $secondaryItemFlags
|
||||
* @param int $maxLevel
|
||||
*/
|
||||
public function __construct(int $id, string $name, int $rarity, int $primaryItemFlags, int $secondaryItemFlags, int $maxLevel){
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
@@ -281,7 +261,6 @@ class Enchantment{
|
||||
|
||||
/**
|
||||
* Returns the ID of this enchantment as per Minecraft PE
|
||||
* @return int
|
||||
*/
|
||||
public function getId() : int{
|
||||
return $this->id;
|
||||
@@ -289,7 +268,6 @@ class Enchantment{
|
||||
|
||||
/**
|
||||
* Returns a translation key for this enchantment's name.
|
||||
* @return string
|
||||
*/
|
||||
public function getName() : string{
|
||||
return $this->name;
|
||||
@@ -297,7 +275,6 @@ class Enchantment{
|
||||
|
||||
/**
|
||||
* Returns an int constant indicating how rare this enchantment type is.
|
||||
* @return int
|
||||
*/
|
||||
public function getRarity() : int{
|
||||
return $this->rarity;
|
||||
@@ -305,8 +282,6 @@ class Enchantment{
|
||||
|
||||
/**
|
||||
* Returns a bitset indicating what item types can have this item applied from an enchanting table.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPrimaryItemFlags() : int{
|
||||
return $this->primaryItemFlags;
|
||||
@@ -315,8 +290,6 @@ class Enchantment{
|
||||
/**
|
||||
* Returns a bitset indicating what item types cannot have this item applied from an enchanting table, but can from
|
||||
* an anvil.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSecondaryItemFlags() : int{
|
||||
return $this->secondaryItemFlags;
|
||||
@@ -324,10 +297,6 @@ class Enchantment{
|
||||
|
||||
/**
|
||||
* Returns whether this enchantment can apply to the item type from an enchanting table.
|
||||
*
|
||||
* @param int $flag
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPrimaryItemType(int $flag) : bool{
|
||||
return ($this->primaryItemFlags & $flag) !== 0;
|
||||
@@ -335,10 +304,6 @@ class Enchantment{
|
||||
|
||||
/**
|
||||
* Returns whether this enchantment can apply to the item type from an anvil, if it is not a primary item.
|
||||
*
|
||||
* @param int $flag
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasSecondaryItemType(int $flag) : bool{
|
||||
return ($this->secondaryItemFlags & $flag) !== 0;
|
||||
@@ -346,7 +311,6 @@ class Enchantment{
|
||||
|
||||
/**
|
||||
* Returns the maximum level of this enchantment that can be found on an enchantment table.
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxLevel() : int{
|
||||
return $this->maxLevel;
|
||||
|
@@ -35,8 +35,6 @@ class EnchantmentEntry{
|
||||
|
||||
/**
|
||||
* @param Enchantment[] $enchantments
|
||||
* @param int $cost
|
||||
* @param string $randomName
|
||||
*/
|
||||
public function __construct(array $enchantments, int $cost, string $randomName){
|
||||
$this->enchantments = $enchantments;
|
||||
|
@@ -47,7 +47,6 @@ final class EnchantmentInstance{
|
||||
|
||||
/**
|
||||
* Returns the type of this enchantment.
|
||||
* @return Enchantment
|
||||
*/
|
||||
public function getType() : Enchantment{
|
||||
return $this->enchantment;
|
||||
@@ -55,7 +54,6 @@ final class EnchantmentInstance{
|
||||
|
||||
/**
|
||||
* Returns the type identifier of this enchantment instance.
|
||||
* @return int
|
||||
*/
|
||||
public function getId() : int{
|
||||
return $this->enchantment->getId();
|
||||
@@ -63,7 +61,6 @@ final class EnchantmentInstance{
|
||||
|
||||
/**
|
||||
* Returns the level of the enchantment.
|
||||
* @return int
|
||||
*/
|
||||
public function getLevel() : int{
|
||||
return $this->level;
|
||||
|
@@ -33,19 +33,10 @@ class EnchantmentList{
|
||||
$this->enchantments = new \SplFixedArray($size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $slot
|
||||
* @param EnchantmentEntry $entry
|
||||
*/
|
||||
public function setSlot(int $slot, EnchantmentEntry $entry) : void{
|
||||
$this->enchantments[$slot] = $entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $slot
|
||||
*
|
||||
* @return EnchantmentEntry
|
||||
*/
|
||||
public function getSlot(int $slot) : EnchantmentEntry{
|
||||
return $this->enchantments[$slot];
|
||||
}
|
||||
|
@@ -34,28 +34,16 @@ abstract class MeleeWeaponEnchantment extends Enchantment{
|
||||
/**
|
||||
* Returns whether this melee enchantment has an effect on the target entity. For example, Smite only applies to
|
||||
* undead mobs.
|
||||
*
|
||||
* @param Entity $victim
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function isApplicableTo(Entity $victim) : bool;
|
||||
|
||||
/**
|
||||
* Returns the amount of additional damage caused by this enchantment to applicable targets.
|
||||
*
|
||||
* @param int $enchantmentLevel
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
abstract public function getDamageBonus(int $enchantmentLevel) : float;
|
||||
|
||||
/**
|
||||
* Called after damaging the entity to apply any post damage effects to the target.
|
||||
*
|
||||
* @param Entity $attacker
|
||||
* @param Entity $victim
|
||||
* @param int $enchantmentLevel
|
||||
*/
|
||||
public function onPostAttack(Entity $attacker, Entity $victim, int $enchantmentLevel) : void{
|
||||
|
||||
|
@@ -36,13 +36,6 @@ class ProtectionEnchantment extends Enchantment{
|
||||
/**
|
||||
* ProtectionEnchantment constructor.
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
* @param int $rarity
|
||||
* @param int $primaryItemFlags
|
||||
* @param int $secondaryItemFlags
|
||||
* @param int $maxLevel
|
||||
* @param float $typeModifier
|
||||
* @param int[]|null $applicableDamageTypes EntityDamageEvent::CAUSE_* constants which this enchantment type applies to, or null if it applies to all types of damage.
|
||||
*/
|
||||
public function __construct(int $id, string $name, int $rarity, int $primaryItemFlags, int $secondaryItemFlags, int $maxLevel, float $typeModifier, ?array $applicableDamageTypes){
|
||||
@@ -56,7 +49,6 @@ class ProtectionEnchantment extends Enchantment{
|
||||
|
||||
/**
|
||||
* Returns the multiplier by which this enchantment type's EPF increases with each enchantment level.
|
||||
* @return float
|
||||
*/
|
||||
public function getTypeModifier() : float{
|
||||
return $this->typeModifier;
|
||||
@@ -64,10 +56,6 @@ class ProtectionEnchantment extends Enchantment{
|
||||
|
||||
/**
|
||||
* Returns the base EPF this enchantment type offers for the given enchantment level.
|
||||
*
|
||||
* @param int $level
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getProtectionFactor(int $level) : int{
|
||||
return (int) floor((6 + $level ** 2) * $this->typeModifier / 3);
|
||||
@@ -75,10 +63,6 @@ class ProtectionEnchantment extends Enchantment{
|
||||
|
||||
/**
|
||||
* Returns whether this enchantment type offers protection from the specified damage source's cause.
|
||||
*
|
||||
* @param EntityDamageEvent $event
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isApplicable(EntityDamageEvent $event) : bool{
|
||||
return $this->applicableDamageTypes === null or isset($this->applicableDamageTypes[$event->getCause()]);
|
||||
|
Reference in New Issue
Block a user