Mass removal of useless @param/@return PHPDoc annotations, pass 1

This commit is contained in:
Dylan K. Taylor
2020-01-21 15:10:18 +00:00
parent 7532c609fb
commit c4793241f5
322 changed files with 0 additions and 5360 deletions

View File

@ -43,7 +43,6 @@ abstract class Armor extends Durable{
/**
* Returns the dyed colour of this armour piece. This generally only applies to leather armour.
* @return Color|null
*/
public function getCustomColor() : ?Color{
if($this->getNamedTag()->hasTag(self::TAG_CUSTOM_COLOR, IntTag::class)){
@ -55,8 +54,6 @@ abstract class Armor extends Durable{
/**
* Sets the dyed colour of this armour piece. This generally only applies to leather armour.
*
* @param Color $color
*/
public function setCustomColor(Color $color) : void{
$this->setNamedTagEntry(new IntTag(self::TAG_CUSTOM_COLOR, Binary::signInt($color->toARGB())));
@ -65,10 +62,6 @@ abstract class Armor extends Durable{
/**
* Returns the total enchantment protection factor this armour piece offers from all applicable protection
* enchantments on the item.
*
* @param EntityDamageEvent $event
*
* @return int
*/
public function getEnchantmentProtectionFactor(EntityDamageEvent $event) : int{
$epf = 0;

View File

@ -52,8 +52,6 @@ class Banner extends Item{
/**
* Returns the color of the banner base.
*
* @return int
*/
public function getBaseColor() : int{
return $this->getNamedTag()->getInt(self::TAG_BASE, 0);
@ -62,8 +60,6 @@ class Banner extends Item{
/**
* Sets the color of the banner base.
* Banner items have to be resent to see the changes in the inventory.
*
* @param int $color
*/
public function setBaseColor(int $color) : void{
$namedTag = $this->getNamedTag();
@ -75,9 +71,6 @@ class Banner extends Item{
* Applies a new pattern on the banner with the given color.
* Banner items have to be resent to see the changes in the inventory.
*
* @param string $pattern
* @param int $color
*
* @return int ID of pattern.
*/
public function addPattern(string $pattern, int $color) : int{
@ -96,10 +89,6 @@ class Banner extends Item{
/**
* Returns whether a pattern with the given ID exists on the banner or not.
*
* @param int $patternId
*
* @return bool
*/
public function patternExists(int $patternId) : bool{
$this->correctNBT();
@ -108,10 +97,6 @@ class Banner extends Item{
/**
* Returns the data of a pattern with the given ID.
*
* @param int $patternId
*
* @return array
*/
public function getPatternData(int $patternId) : array{
if(!$this->patternExists($patternId)){
@ -133,10 +118,6 @@ class Banner extends Item{
* Changes the pattern of a previously existing pattern.
* Banner items have to be resent to see the changes in the inventory.
*
* @param int $patternId
* @param string $pattern
* @param int $color
*
* @return bool indicating success.
*/
public function changePattern(int $patternId, string $pattern, int $color) : bool{
@ -160,8 +141,6 @@ class Banner extends Item{
* Deletes a pattern from the banner with the given ID.
* Banner items have to be resent to see the changes in the inventory.
*
* @param int $patternId
*
* @return bool indicating whether the pattern existed or not.
*/
public function deletePattern(int $patternId) : bool{
@ -200,8 +179,6 @@ class Banner extends Item{
/**
* Returns the total count of patterns on this banner.
*
* @return int
*/
public function getPatternCount() : int{
return $this->getNamedTag()->getListTag(self::TAG_PATTERNS)->count();

View File

@ -48,8 +48,6 @@ interface Consumable{
/**
* Called when this Consumable is consumed by mob, after standard resulting effects have been applied.
*
* @param Living $consumer
*
* @return void
*/
public function onConsume(Living $consumer);

View File

@ -32,7 +32,6 @@ abstract class Durable extends Item{
/**
* Returns whether this item will take damage when used.
* @return bool
*/
public function isUnbreakable() : bool{
return $this->getNamedTag()->getByte("Unbreakable", 0) !== 0;
@ -41,8 +40,6 @@ abstract class Durable extends Item{
/**
* Sets whether the item will take damage when used.
*
* @param bool $value
*
* @return void
*/
public function setUnbreakable(bool $value = true){
@ -52,8 +49,6 @@ abstract class Durable extends Item{
/**
* Applies damage to the item.
*
* @param int $amount
*
* @return bool if any damage was applied to the item
*/
public function applyDamage(int $amount) : bool{
@ -97,14 +92,11 @@ abstract class Durable extends Item{
/**
* Returns the maximum amount of damage this item can take before it breaks.
*
* @return int
*/
abstract public function getMaxDurability() : int;
/**
* Returns whether the item is broken.
* @return bool
*/
public function isBroken() : bool{
return $this->meta >= $this->getMaxDurability();

View File

@ -34,7 +34,6 @@ interface FoodSource extends Consumable{
/**
* Returns whether a Human eating this FoodSource must have a non-full hunger bar.
* @return bool
*/
public function requiresHunger() : bool;
}

View File

@ -94,12 +94,7 @@ class Item implements ItemIds, \JsonSerializable{
*
* This function redirects to {@link ItemFactory#get}.
*
* @param int $id
* @param int $meta
* @param int $count
* @param CompoundTag|string $tags
*
* @return Item
*/
public static function get(int $id, int $meta = 0, int $count = 1, $tags = "") : Item{
return ItemFactory::get($id, $meta, $count, $tags);
@ -110,9 +105,6 @@ class Item implements ItemIds, \JsonSerializable{
*
* This function redirects to {@link ItemFactory#fromString}.
*
* @param string $str
* @param bool $multiple
*
* @return Item[]|Item
*/
public static function fromString(string $str, bool $multiple = false){
@ -158,8 +150,6 @@ class Item implements ItemIds, \JsonSerializable{
* Adds an item to the creative menu.
* Note: Players who are already online when this is called will not see this change.
*
* @param Item $item
*
* @return void
*/
public static function addCreativeItem(Item $item){
@ -170,8 +160,6 @@ class Item implements ItemIds, \JsonSerializable{
* Removes an item from the creative menu.
* Note: Players who are already online when this is called will not see this change.
*
* @param Item $item
*
* @return void
*/
public static function removeCreativeItem(Item $item){
@ -186,8 +174,6 @@ class Item implements ItemIds, \JsonSerializable{
}
/**
* @param int $index
*
* @return Item|null
*/
public static function getCreativeItem(int $index){
@ -223,10 +209,6 @@ class Item implements ItemIds, \JsonSerializable{
*
* NOTE: This should NOT BE USED for creating items to set into an inventory. Use {@link ItemFactory#get} for that
* purpose.
*
* @param int $id
* @param int $meta
* @param string $name
*/
public function __construct(int $id, int $meta = 0, string $name = "Unknown"){
if($id < -0x8000 or $id > 0x7fff){ //signed short range
@ -260,7 +242,6 @@ class Item implements ItemIds, \JsonSerializable{
* @see Item::getNamedTag()
*
* Returns the serialized NBT of the Item
* @return string
*/
public function getCompoundTag() : string{
return $this->tags;
@ -268,15 +249,11 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Returns whether this Item has a non-empty NBT.
* @return bool
*/
public function hasCompoundTag() : bool{
return $this->tags !== "";
}
/**
* @return bool
*/
public function hasCustomBlockData() : bool{
return $this->getNamedTagEntry(self::TAG_BLOCK_ENTITY_TAG) instanceof CompoundTag;
}
@ -290,8 +267,6 @@ class Item implements ItemIds, \JsonSerializable{
}
/**
* @param CompoundTag $compound
*
* @return $this
*/
public function setCustomBlockData(CompoundTag $compound) : Item{
@ -302,27 +277,15 @@ class Item implements ItemIds, \JsonSerializable{
return $this;
}
/**
* @return CompoundTag|null
*/
public function getCustomBlockData() : ?CompoundTag{
$tag = $this->getNamedTagEntry(self::TAG_BLOCK_ENTITY_TAG);
return $tag instanceof CompoundTag ? $tag : null;
}
/**
* @return bool
*/
public function hasEnchantments() : bool{
return $this->getNamedTagEntry(self::TAG_ENCH) instanceof ListTag;
}
/**
* @param int $id
* @param int $level
*
* @return bool
*/
public function hasEnchantment(int $id, int $level = -1) : bool{
$ench = $this->getNamedTagEntry(self::TAG_ENCH);
if(!($ench instanceof ListTag)){
@ -339,11 +302,6 @@ class Item implements ItemIds, \JsonSerializable{
return false;
}
/**
* @param int $id
*
* @return EnchantmentInstance|null
*/
public function getEnchantment(int $id) : ?EnchantmentInstance{
$ench = $this->getNamedTagEntry(self::TAG_ENCH);
if(!($ench instanceof ListTag)){
@ -363,10 +321,6 @@ class Item implements ItemIds, \JsonSerializable{
return null;
}
/**
* @param int $id
* @param int $level
*/
public function removeEnchantment(int $id, int $level = -1) : void{
$ench = $this->getNamedTagEntry(self::TAG_ENCH);
if(!($ench instanceof ListTag)){
@ -388,9 +342,6 @@ class Item implements ItemIds, \JsonSerializable{
$this->removeNamedTagEntry(self::TAG_ENCH);
}
/**
* @param EnchantmentInstance $enchantment
*/
public function addEnchantment(EnchantmentInstance $enchantment) : void{
$found = false;
@ -445,10 +396,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Returns the level of the enchantment on this item with the specified ID, or 0 if the item does not have the
* enchantment.
*
* @param int $enchantmentId
*
* @return int
*/
public function getEnchantmentLevel(int $enchantmentId) : int{
$ench = $this->getNamedTag()->getListTag(self::TAG_ENCH);
@ -464,9 +411,6 @@ class Item implements ItemIds, \JsonSerializable{
return 0;
}
/**
* @return bool
*/
public function hasCustomName() : bool{
$display = $this->getNamedTagEntry(self::TAG_DISPLAY);
if($display instanceof CompoundTag){
@ -476,9 +420,6 @@ class Item implements ItemIds, \JsonSerializable{
return false;
}
/**
* @return string
*/
public function getCustomName() : string{
$display = $this->getNamedTagEntry(self::TAG_DISPLAY);
if($display instanceof CompoundTag){
@ -489,8 +430,6 @@ class Item implements ItemIds, \JsonSerializable{
}
/**
* @param string $name
*
* @return $this
*/
public function setCustomName(string $name) : Item{
@ -560,11 +499,6 @@ class Item implements ItemIds, \JsonSerializable{
return $this;
}
/**
* @param string $name
*
* @return NamedTag|null
*/
public function getNamedTagEntry(string $name) : ?NamedTag{
return $this->getNamedTag()->getTag($name);
}
@ -584,8 +518,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Returns a tree of Tag objects representing the Item's NBT. If the item does not have any NBT, an empty CompoundTag
* object is returned to allow the caller to manipulate and apply back to the item.
*
* @return CompoundTag
*/
public function getNamedTag() : CompoundTag{
if(!$this->hasCompoundTag() and $this->cachedNBT === null){
@ -598,8 +530,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Sets the Item's NBT from the supplied CompoundTag object.
*
* @param CompoundTag $tag
*
* @return $this
*/
public function setNamedTag(CompoundTag $tag) : Item{
@ -621,16 +551,11 @@ class Item implements ItemIds, \JsonSerializable{
return $this->setCompoundTag("");
}
/**
* @return int
*/
public function getCount() : int{
return $this->count;
}
/**
* @param int $count
*
* @return $this
*/
public function setCount(int $count) : Item{
@ -642,8 +567,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Pops an item from the stack and returns it, decreasing the stack count of this item stack by one.
*
* @param int $count
*
* @return $this
* @throws \InvalidArgumentException if trying to pop more items than are on the stack
*/
@ -666,7 +589,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Returns the name of the item, or the custom name if it is set.
* @return string
*/
final public function getName() : string{
return $this->hasCustomName() ? $this->getCustomName() : $this->getVanillaName();
@ -674,44 +596,31 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Returns the vanilla name of the item, disregarding custom names.
* @return string
*/
public function getVanillaName() : string{
return $this->name;
}
/**
* @return bool
*/
final public function canBePlaced() : bool{
return $this->getBlock()->canBePlaced();
}
/**
* Returns the block corresponding to this Item.
* @return Block
*/
public function getBlock() : Block{
return BlockFactory::get(self::AIR);
}
/**
* @return int
*/
final public function getId() : int{
return $this->id;
}
/**
* @return int
*/
final public function getDamage() : int{
return $this->meta;
}
/**
* @param int $meta
*
* @return $this
*/
public function setDamage(int $meta) : Item{
@ -723,8 +632,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Returns whether this item can match any item with an equivalent ID with any meta value.
* Used in crafting recipes which accept multiple variants of the same item, for example crafting tables recipes.
*
* @return bool
*/
public function hasAnyDamageValue() : bool{
return $this->meta === -1;
@ -732,7 +639,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Returns the highest amount of this item which will fit into one inventory slot.
* @return int
*/
public function getMaxStackSize() : int{
return 64;
@ -740,7 +646,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Returns the time in ticks which the item will fuel a furnace for.
* @return int
*/
public function getFuelTime() : int{
return 0;
@ -748,7 +653,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Returns how many points of damage this item will deal to an entity when used as a weapon.
* @return int
*/
public function getAttackPoints() : int{
return 1;
@ -756,7 +660,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Returns how many armor points can be gained by wearing this item.
* @return int
*/
public function getDefensePoints() : int{
return 0;
@ -765,8 +668,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Returns what type of block-breaking tool this is. Blocks requiring the same tool type as the item will break
* faster (except for blocks requiring no tool, which break at the same speed regardless of the tool used)
*
* @return int
*/
public function getBlockToolType() : int{
return BlockToolType::TYPE_NONE;
@ -778,8 +679,6 @@ class Item implements ItemIds, \JsonSerializable{
* This should return 1 for non-tiered tools, and the tool tier for tiered tools.
*
* @see Block::getToolHarvestLevel()
*
* @return int
*/
public function getBlockToolHarvestLevel() : int{
return 0;
@ -791,14 +690,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Called when a player uses this item on a block.
*
* @param Player $player
* @param Block $blockReplace
* @param Block $blockClicked
* @param int $face
* @param Vector3 $clickVector
*
* @return bool
*/
public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : bool{
return false;
@ -807,11 +698,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Called when a player uses the item on air, for example throwing a projectile.
* Returns whether the item was changed, for example count decrease or durability change.
*
* @param Player $player
* @param Vector3 $directionVector
*
* @return bool
*/
public function onClickAir(Player $player, Vector3 $directionVector) : bool{
return false;
@ -820,10 +706,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Called when a player is using this item and releases it. Used to handle bow shoot actions.
* Returns whether the item was changed, for example count decrease or durability change.
*
* @param Player $player
*
* @return bool
*/
public function onReleaseUsing(Player $player) : bool{
return false;
@ -831,10 +713,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Called when this item is used to destroy a block. Usually used to update durability.
*
* @param Block $block
*
* @return bool
*/
public function onDestroyBlock(Block $block) : bool{
return false;
@ -842,10 +720,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Called when this item is used to attack an entity. Usually used to update durability.
*
* @param Entity $victim
*
* @return bool
*/
public function onAttackEntity(Entity $victim) : bool{
return false;
@ -853,8 +727,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Returns the number of ticks a player must wait before activating this item again.
*
* @return int
*/
public function getCooldownTicks() : int{
return 0;
@ -863,11 +735,8 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Compares an Item to this Item and check if they match.
*
* @param Item $item
* @param bool $checkDamage Whether to verify that the damage values match.
* @param bool $checkCompound Whether to verify that the items' NBT match.
*
* @return bool
*/
final public function equals(Item $item, bool $checkDamage = true, bool $checkCompound = true) : bool{
if($this->id === $item->getId() and (!$checkDamage or $this->getDamage() === $item->getDamage())){
@ -888,26 +757,17 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Returns whether the specified item stack has the same ID, damage, NBT and count as this item stack.
*
* @param Item $other
*
* @return bool
*/
final public function equalsExact(Item $other) : bool{
return $this->equals($other, true, true) and $this->count === $other->count;
}
/**
* @return string
*/
final public function __toString() : string{
return "Item " . $this->name . " (" . $this->id . ":" . ($this->hasAnyDamageValue() ? "?" : $this->meta) . ")x" . $this->count . ($this->hasCompoundTag() ? " tags:" . base64_encode($this->getCompoundTag()) : "");
}
/**
* Returns an array of item stack properties that can be serialized to json.
*
* @return array
*/
final public function jsonSerialize() : array{
$data = [
@ -931,10 +791,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Returns an Item from properties created in an array by {@link Item#jsonSerialize}
*
* @param array $data
*
* @return Item
*/
final public static function jsonDeserialize(array $data) : Item{
$nbt = "";
@ -960,8 +816,6 @@ class Item implements ItemIds, \JsonSerializable{
*
* @param int $slot optional, the inventory slot of the item
* @param string $tagName the name to assign to the CompoundTag object
*
* @return CompoundTag
*/
public function nbtSerialize(int $slot = -1, string $tagName = "") : CompoundTag{
$result = new CompoundTag($tagName, [
@ -985,10 +839,6 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Deserializes an Item from an NBT CompoundTag
*
* @param CompoundTag $tag
*
* @return Item
*/
public static function nbtDeserialize(CompoundTag $tag) : Item{
if(!$tag->hasTag("id") or !$tag->hasTag("Count")){

View File

@ -34,9 +34,7 @@ class ItemBlock extends Item{
protected $blockId;
/**
* @param int $blockId
* @param int $meta usually 0-15 (placed blocks may only have meta values 0-15)
* @param int|null $itemId
*/
public function __construct(int $blockId, int $meta = 0, int $itemId = null){
$this->blockId = $blockId;

View File

@ -285,9 +285,6 @@ class ItemFactory{
* NOTE: If you are registering a new item type, you will need to add it to the creative inventory yourself - it
* will not automatically appear there.
*
* @param Item $item
* @param bool $override
*
* @return void
* @throws \RuntimeException if something attempted to override an already-registered item without specifying the
* $override parameter.
@ -304,12 +301,8 @@ class ItemFactory{
/**
* Returns an instance of the Item with the specified id, meta, count and NBT.
*
* @param int $id
* @param int $meta
* @param int $count
* @param CompoundTag|string|null $tags
*
* @return Item
* @throws \TypeError
*/
public static function get(int $id, int $meta = 0, int $count = 1, $tags = null) : Item{
@ -350,9 +343,6 @@ class ItemFactory{
* If multiple item instances are to be created, their identifiers must be comma-separated, for example:
* `diamond_pickaxe,wooden_shovel:18,iron_ingot`
*
* @param string $str
* @param bool $multiple
*
* @return Item[]|Item
*
* @throws \InvalidArgumentException if the given string cannot be parsed as an item identifier
@ -389,9 +379,6 @@ class ItemFactory{
/**
* Returns whether the specified item ID is already registered in the item factory.
*
* @param int $id
* @return bool
*/
public static function isRegistered(int $id) : bool{
if($id < 256){

View File

@ -70,8 +70,6 @@ class Potion extends Item implements Consumable{
/**
* Returns a list of effects applied by potions with the specified ID.
*
* @param int $id
*
* @return EffectInstance[]
*/
public static function getPotionEffectsById(int $id) : array{

View File

@ -40,8 +40,6 @@ abstract class ProjectileItem extends Item{
/**
* Helper function to apply extra NBT tags to pass to the created projectile.
*
* @param CompoundTag $tag
*/
protected function addExtraTags(CompoundTag $tag) : void{

View File

@ -40,10 +40,6 @@ class WritableBook extends Item{
/**
* Returns whether the given page exists in this book.
*
* @param int $pageId
*
* @return bool
*/
public function pageExists(int $pageId) : bool{
return $this->getPagesTag()->isset($pageId);
@ -51,10 +47,6 @@ class WritableBook extends Item{
/**
* Returns a string containing the content of a page (which could be empty), or null if the page doesn't exist.
*
* @param int $pageId
*
* @return string|null
*/
public function getPageText(int $pageId) : ?string{
$pages = $this->getNamedTag()->getListTag(self::TAG_PAGES);
@ -73,9 +65,6 @@ class WritableBook extends Item{
/**
* Sets the text of a page in the book. Adds the page if the page does not yet exist.
*
* @param int $pageId
* @param string $pageText
*
* @return bool indicating whether the page was created or not.
*/
public function setPageText(int $pageId, string $pageText) : bool{
@ -99,8 +88,6 @@ class WritableBook extends Item{
/**
* Adds a new page with the given page ID.
* Creates a new page for every page between the given ID and existing pages that doesn't yet exist.
*
* @param int $pageId
*/
public function addPage(int $pageId) : void{
if($pageId < 0){
@ -122,8 +109,6 @@ class WritableBook extends Item{
/**
* Deletes an existing page with the given page ID.
*
* @param int $pageId
*
* @return bool indicating success
*/
public function deletePage(int $pageId) : bool{
@ -137,9 +122,6 @@ class WritableBook extends Item{
/**
* Inserts a new page with the given text and moves other pages upwards.
*
* @param int $pageId
* @param string $pageText
*
* @return bool indicating success
*/
public function insertPage(int $pageId, string $pageText = "") : bool{
@ -158,9 +140,6 @@ class WritableBook extends Item{
/**
* Switches the text of two pages with each other.
*
* @param int $pageId1
* @param int $pageId2
*
* @return bool indicating success
*/
public function swapPages(int $pageId1, int $pageId2) : bool{

View File

@ -45,8 +45,6 @@ class WrittenBook extends WritableBook{
/**
* Returns the generation of the book.
* Generations higher than 1 can not be copied.
*
* @return int
*/
public function getGeneration() : int{
return $this->getNamedTag()->getInt(self::TAG_GENERATION, -1);
@ -54,8 +52,6 @@ class WrittenBook extends WritableBook{
/**
* Sets the generation of a book.
*
* @param int $generation
*/
public function setGeneration(int $generation) : void{
if($generation < 0 or $generation > 3){
@ -70,8 +66,6 @@ class WrittenBook extends WritableBook{
* Returns the author of this book.
* This is not a reliable way to get the name of the player who signed this book.
* The author can be set to anything when signing a book.
*
* @return string
*/
public function getAuthor() : string{
return $this->getNamedTag()->getString(self::TAG_AUTHOR, "");
@ -79,8 +73,6 @@ class WrittenBook extends WritableBook{
/**
* Sets the author of this book.
*
* @param string $authorName
*/
public function setAuthor(string $authorName) : void{
$namedTag = $this->getNamedTag();
@ -90,8 +82,6 @@ class WrittenBook extends WritableBook{
/**
* Returns the title of this book.
*
* @return string
*/
public function getTitle() : string{
return $this->getNamedTag()->getString(self::TAG_TITLE, "");
@ -99,8 +89,6 @@ class WrittenBook extends WritableBook{
/**
* Sets the author of this book.
*
* @param string $title
*/
public function setTitle(string $title) : void{
$namedTag = $this->getNamedTag();

View File

@ -142,18 +142,11 @@ class Enchantment{
/**
* Registers an enchantment type.
*
* @param Enchantment $enchantment
*/
public static function registerEnchantment(Enchantment $enchantment) : void{
self::$enchantments[$enchantment->getId()] = clone $enchantment;
}
/**
* @param int $id
*
* @return Enchantment|null
*/
public static function getEnchantment(int $id) : ?Enchantment{
if($id < 0 or $id >= self::$enchantments->getSize()){
return null;
@ -161,11 +154,6 @@ class Enchantment{
return self::$enchantments[$id] ?? null;
}
/**
* @param string $name
*
* @return Enchantment|null
*/
public static function getEnchantmentByName(string $name) : ?Enchantment{
$const = Enchantment::class . "::" . strtoupper($name);
if(defined($const)){
@ -187,14 +175,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;
@ -206,7 +186,6 @@ class Enchantment{
/**
* Returns the ID of this enchantment as per Minecraft PE
* @return int
*/
public function getId() : int{
return $this->id;
@ -214,7 +193,6 @@ class Enchantment{
/**
* Returns a translation key for this enchantment's name.
* @return string
*/
public function getName() : string{
return $this->name;
@ -222,7 +200,6 @@ class Enchantment{
/**
* Returns an int constant indicating how rare this enchantment type is.
* @return int
*/
public function getRarity() : int{
return $this->rarity;
@ -230,8 +207,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;
@ -240,8 +215,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;
@ -249,10 +222,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;
@ -260,10 +229,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;
@ -271,7 +236,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;

View File

@ -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;

View File

@ -45,7 +45,6 @@ class EnchantmentInstance{
/**
* Returns the type of this enchantment.
* @return Enchantment
*/
public function getType() : Enchantment{
return $this->enchantment;
@ -53,7 +52,6 @@ class EnchantmentInstance{
/**
* Returns the type identifier of this enchantment instance.
* @return int
*/
public function getId() : int{
return $this->enchantment->getId();
@ -61,7 +59,6 @@ class EnchantmentInstance{
/**
* Returns the level of the enchantment.
* @return int
*/
public function getLevel() : int{
return $this->level;
@ -70,8 +67,6 @@ class EnchantmentInstance{
/**
* Sets the level of the enchantment.
*
* @param int $level
*
* @return $this
*/
public function setLevel(int $level){

View File

@ -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];
}

View File

@ -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{

View File

@ -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()]);