mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 12:04:46 +00:00
phpdoc armageddon for master, pass 1
This commit is contained in:
@@ -63,7 +63,6 @@ class Armor extends Durable{
|
||||
|
||||
/**
|
||||
* @see ArmorInventory
|
||||
* @return int
|
||||
*/
|
||||
public function getArmorSlot() : int{
|
||||
return $this->armorInfo->getArmorSlot();
|
||||
@@ -75,7 +74,6 @@ 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{
|
||||
return $this->customColor;
|
||||
@@ -84,8 +82,6 @@ class Armor extends Durable{
|
||||
/**
|
||||
* Sets the dyed colour of this armour piece. This generally only applies to leather armour.
|
||||
*
|
||||
* @param Color $color
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustomColor(Color $color) : self{
|
||||
@@ -96,10 +92,6 @@ 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;
|
||||
|
@@ -38,23 +38,14 @@ class ArmorTypeInfo{
|
||||
$this->armorSlot = $armorSlot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDefensePoints() : int{
|
||||
return $this->defensePoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxDurability() : int{
|
||||
return $this->maxDurability;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getArmorSlot() : int{
|
||||
return $this->armorSlot;
|
||||
}
|
||||
|
@@ -53,9 +53,6 @@ class Banner extends Item{
|
||||
$this->patterns = new Deque();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DyeColor
|
||||
*/
|
||||
public function getColor() : DyeColor{
|
||||
return $this->color;
|
||||
}
|
||||
|
@@ -37,9 +37,6 @@ class Bed extends Item{
|
||||
$this->color = $color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DyeColor
|
||||
*/
|
||||
public function getColor() : DyeColor{
|
||||
return $this->color;
|
||||
}
|
||||
|
@@ -34,9 +34,6 @@ class Boat extends Item{
|
||||
$this->woodType = $woodType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TreeType
|
||||
*/
|
||||
public function getWoodType() : TreeType{
|
||||
return $this->woodType;
|
||||
}
|
||||
|
@@ -47,8 +47,6 @@ interface Consumable{
|
||||
|
||||
/**
|
||||
* Called when this Consumable is consumed by mob, after standard resulting effects have been applied.
|
||||
*
|
||||
* @param Living $consumer
|
||||
*/
|
||||
public function onConsume(Living $consumer) : void;
|
||||
}
|
||||
|
@@ -41,7 +41,6 @@ abstract class Durable extends Item{
|
||||
|
||||
/**
|
||||
* Returns whether this item will take damage when used.
|
||||
* @return bool
|
||||
*/
|
||||
public function isUnbreakable() : bool{
|
||||
return $this->unbreakable;
|
||||
@@ -50,8 +49,6 @@ abstract class Durable extends Item{
|
||||
/**
|
||||
* Sets whether the item will take damage when used.
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUnbreakable(bool $value = true) : self{
|
||||
@@ -62,8 +59,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{
|
||||
@@ -119,14 +114,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->damage >= $this->getMaxDurability();
|
||||
|
@@ -35,9 +35,6 @@ class Dye extends Item{
|
||||
$this->color = $color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DyeColor
|
||||
*/
|
||||
public function getColor() : DyeColor{
|
||||
return $this->color;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -103,10 +103,6 @@ class Item implements \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 $variant
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct(int $id, int $variant = 0, string $name = "Unknown"){
|
||||
if($id < -0x8000 or $id > 0x7fff){ //signed short range
|
||||
@@ -120,9 +116,6 @@ class Item implements \JsonSerializable{
|
||||
$this->canDestroy = new Set();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCustomBlockData() : bool{
|
||||
return $this->blockEntityTag !== null;
|
||||
}
|
||||
@@ -136,8 +129,6 @@ class Item implements \JsonSerializable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CompoundTag $compound
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustomBlockData(CompoundTag $compound) : Item{
|
||||
@@ -146,30 +137,19 @@ class Item implements \JsonSerializable{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CompoundTag|null
|
||||
*/
|
||||
public function getCustomBlockData() : ?CompoundTag{
|
||||
return $this->blockEntityTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCustomName() : bool{
|
||||
return $this->customName !== "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCustomName() : string{
|
||||
return $this->customName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustomName(string $name) : Item{
|
||||
@@ -243,7 +223,6 @@ class Item implements \JsonSerializable{
|
||||
|
||||
/**
|
||||
* Returns whether this Item has a non-empty NBT.
|
||||
* @return bool
|
||||
*/
|
||||
public function hasNamedTag() : bool{
|
||||
return $this->getNamedTag()->count() > 0;
|
||||
@@ -252,8 +231,6 @@ class Item implements \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->nbt === null){
|
||||
@@ -266,8 +243,6 @@ class Item implements \JsonSerializable{
|
||||
/**
|
||||
* Sets the Item's NBT from the supplied CompoundTag object.
|
||||
*
|
||||
* @param CompoundTag $tag
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNamedTag(CompoundTag $tag) : Item{
|
||||
@@ -401,16 +376,11 @@ class Item implements \JsonSerializable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCount() : int{
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $count
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCount(int $count) : Item{
|
||||
@@ -422,8 +392,6 @@ class Item implements \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
|
||||
*/
|
||||
@@ -446,7 +414,6 @@ class Item implements \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();
|
||||
@@ -454,37 +421,26 @@ class Item implements \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 VanillaBlocks::AIR();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
final public function getId() : int{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMeta() : int{
|
||||
return $this->meta;
|
||||
}
|
||||
@@ -492,8 +448,6 @@ class Item implements \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;
|
||||
@@ -501,7 +455,6 @@ class Item implements \JsonSerializable{
|
||||
|
||||
/**
|
||||
* Returns the highest amount of this item which will fit into one inventory slot.
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxStackSize() : int{
|
||||
return 64;
|
||||
@@ -509,7 +462,6 @@ class Item implements \JsonSerializable{
|
||||
|
||||
/**
|
||||
* Returns the time in ticks which the item will fuel a furnace for.
|
||||
* @return int
|
||||
*/
|
||||
public function getFuelTime() : int{
|
||||
return 0;
|
||||
@@ -517,7 +469,6 @@ class Item implements \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;
|
||||
@@ -525,7 +476,6 @@ class Item implements \JsonSerializable{
|
||||
|
||||
/**
|
||||
* Returns how many armor points can be gained by wearing this item.
|
||||
* @return int
|
||||
*/
|
||||
public function getDefensePoints() : int{
|
||||
return 0;
|
||||
@@ -534,8 +484,6 @@ class Item implements \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::NONE;
|
||||
@@ -547,8 +495,6 @@ class Item implements \JsonSerializable{
|
||||
* This should return 1 for non-tiered tools, and the tool tier for tiered tools.
|
||||
*
|
||||
* @see BlockBreakInfo::getToolHarvestLevel()
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBlockToolHarvestLevel() : int{
|
||||
return 0;
|
||||
@@ -560,14 +506,6 @@ class Item implements \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 ItemUseResult
|
||||
*/
|
||||
public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult{
|
||||
return ItemUseResult::NONE();
|
||||
@@ -576,11 +514,6 @@ class Item implements \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 ItemUseResult
|
||||
*/
|
||||
public function onClickAir(Player $player, Vector3 $directionVector) : ItemUseResult{
|
||||
return ItemUseResult::NONE();
|
||||
@@ -589,10 +522,6 @@ class Item implements \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 ItemUseResult
|
||||
*/
|
||||
public function onReleaseUsing(Player $player) : ItemUseResult{
|
||||
return ItemUseResult::NONE();
|
||||
@@ -600,10 +529,6 @@ class Item implements \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;
|
||||
@@ -611,10 +536,6 @@ class Item implements \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;
|
||||
@@ -622,8 +543,6 @@ class Item implements \JsonSerializable{
|
||||
|
||||
/**
|
||||
* Returns the number of ticks a player must wait before activating this item again.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCooldownTicks() : int{
|
||||
return 0;
|
||||
@@ -632,11 +551,8 @@ class Item implements \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{
|
||||
return $this->id === $item->getId() and
|
||||
@@ -646,26 +562,17 @@ class Item implements \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->getMeta()) . ")x" . $this->count . ($this->hasNamedTag() ? " tags:0x" . base64_encode((new LittleEndianNbtSerializer())->write(new TreeRoot($this->getNamedTag()))) : "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of item stack properties that can be serialized to json.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
final public function jsonSerialize() : array{
|
||||
$data = [
|
||||
@@ -690,9 +597,6 @@ class Item implements \JsonSerializable{
|
||||
/**
|
||||
* Returns an Item from properties created in an array by {@link Item#jsonSerialize}
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return Item
|
||||
* @throws NbtDataException
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
@@ -716,8 +620,6 @@ class Item implements \JsonSerializable{
|
||||
* Serializes the item to an NBT CompoundTag
|
||||
*
|
||||
* @param int $slot optional, the inventory slot of the item
|
||||
*
|
||||
* @return CompoundTag
|
||||
*/
|
||||
public function nbtSerialize(int $slot = -1) : CompoundTag{
|
||||
$result = CompoundTag::create()
|
||||
@@ -738,10 +640,6 @@ class Item implements \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")){
|
||||
|
@@ -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){
|
||||
if($blockId < 0){ //extended blocks
|
||||
|
@@ -35,37 +35,20 @@ trait ItemEnchantmentHandlingTrait{
|
||||
/** @var EnchantmentInstance[] */
|
||||
protected $enchantments = [];
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEnchantments() : bool{
|
||||
return !empty($this->enchantments);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Enchantment $enchantment
|
||||
* @param int $level
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEnchantment(Enchantment $enchantment, int $level = -1) : bool{
|
||||
$id = $enchantment->getId();
|
||||
return isset($this->enchantments[$id]) and ($level === -1 or $this->enchantments[$id]->getLevel() === $level);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Enchantment $enchantment
|
||||
*
|
||||
* @return EnchantmentInstance|null
|
||||
*/
|
||||
public function getEnchantment(Enchantment $enchantment) : ?EnchantmentInstance{
|
||||
return $this->enchantments[$enchantment->getId()] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Enchantment $enchantment
|
||||
* @param int $level
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function removeEnchantment(Enchantment $enchantment, int $level = -1) : self{
|
||||
@@ -86,8 +69,6 @@ trait ItemEnchantmentHandlingTrait{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EnchantmentInstance $enchantment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addEnchantment(EnchantmentInstance $enchantment) : self{
|
||||
@@ -105,10 +86,6 @@ trait ItemEnchantmentHandlingTrait{
|
||||
/**
|
||||
* Returns the level of the enchantment on this item with the specified ID, or 0 if the item does not have the
|
||||
* enchantment.
|
||||
*
|
||||
* @param Enchantment $enchantment
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getEnchantmentLevel(Enchantment $enchantment) : int{
|
||||
return ($instance = $this->getEnchantment($enchantment)) !== null ? $instance->getLevel() : 0;
|
||||
|
@@ -381,9 +381,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
|
||||
*
|
||||
* @throws \RuntimeException if something attempted to override an already-registered item without specifying the
|
||||
* $override parameter.
|
||||
*/
|
||||
@@ -401,12 +398,6 @@ 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|null $tags
|
||||
*
|
||||
* @return Item
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function get(int $id, int $meta = 0, int $count = 1, ?CompoundTag $tags = null) : Item{
|
||||
@@ -444,10 +435,6 @@ class ItemFactory{
|
||||
* - `minecraft:string`
|
||||
* - `351:4 (lapis lazuli ID:meta)`
|
||||
*
|
||||
* @param string $str
|
||||
*
|
||||
* @return Item
|
||||
*
|
||||
* @throws \InvalidArgumentException if the given string cannot be parsed as an item identifier
|
||||
*/
|
||||
public static function fromString(string $str) : Item{
|
||||
@@ -477,11 +464,6 @@ class ItemFactory{
|
||||
|
||||
/**
|
||||
* Returns whether the specified item ID is already registered in the item factory.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $variant
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isRegistered(int $id, int $variant = 0) : bool{
|
||||
if($id < 256){
|
||||
|
@@ -75,9 +75,6 @@ class LiquidBucket extends Item{
|
||||
return ItemUseResult::FAIL();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Liquid
|
||||
*/
|
||||
public function getLiquid() : Liquid{
|
||||
return $this->liquid;
|
||||
}
|
||||
|
@@ -110,8 +110,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{
|
||||
|
@@ -45,8 +45,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{
|
||||
|
||||
|
@@ -37,10 +37,6 @@ class SpawnEgg extends Item{
|
||||
private $entityClass;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $variant
|
||||
* @param string $name
|
||||
*
|
||||
* @param string $entityClass instanceof Entity
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
|
@@ -69,30 +69,18 @@ final class ToolTier{
|
||||
$this->baseEfficiency = $baseEfficiency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getHarvestLevel() : int{
|
||||
return $this->harvestLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxDurability() : int{
|
||||
return $this->maxDurability;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBaseAttackPoints() : int{
|
||||
return $this->baseAttackPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBaseEfficiency() : int{
|
||||
return $this->baseEfficiency;
|
||||
}
|
||||
|
@@ -302,11 +302,6 @@ final class VanillaItems{
|
||||
self::_registryRegister($name, $item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return Item
|
||||
*/
|
||||
public static function fromString(string $name) : Item{
|
||||
$result = self::_registryFromString($name);
|
||||
assert($result instanceof Item);
|
||||
|
@@ -47,10 +47,6 @@ abstract class WritableBookBase extends Item{
|
||||
|
||||
/**
|
||||
* Returns whether the given page exists in this book.
|
||||
*
|
||||
* @param int $pageId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function pageExists(int $pageId) : bool{
|
||||
return isset($this->pages[$pageId]);
|
||||
@@ -59,9 +55,6 @@ abstract class WritableBookBase 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
|
||||
* @throws \OutOfRangeException if requesting a nonexisting page
|
||||
*/
|
||||
public function getPageText(int $pageId) : string{
|
||||
@@ -71,9 +64,6 @@ abstract class WritableBookBase 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 $this
|
||||
*/
|
||||
public function setPageText(int $pageId, string $pageText) : self{
|
||||
@@ -89,8 +79,6 @@ abstract class WritableBookBase 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
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addPage(int $pageId) : self{
|
||||
@@ -107,8 +95,6 @@ abstract class WritableBookBase extends Item{
|
||||
/**
|
||||
* Deletes an existing page with the given page ID.
|
||||
*
|
||||
* @param int $pageId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function deletePage(int $pageId) : self{
|
||||
@@ -119,9 +105,6 @@ abstract class WritableBookBase extends Item{
|
||||
/**
|
||||
* Inserts a new page with the given text and moves other pages upwards.
|
||||
*
|
||||
* @param int $pageId
|
||||
* @param string $pageText
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function insertPage(int $pageId, string $pageText = "") : self{
|
||||
@@ -132,9 +115,6 @@ abstract class WritableBookBase extends Item{
|
||||
/**
|
||||
* Switches the text of two pages with each other.
|
||||
*
|
||||
* @param int $pageId1
|
||||
* @param int $pageId2
|
||||
*
|
||||
* @return bool indicating success
|
||||
* @throws \OutOfRangeException if either of the pages does not exist
|
||||
*/
|
||||
|
@@ -39,16 +39,10 @@ class WritableBookPage{
|
||||
$this->photoName = $photoName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getText() : string{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPhotoName() : string{
|
||||
return $this->photoName;
|
||||
}
|
||||
|
@@ -51,8 +51,6 @@ class WrittenBook extends WritableBookBase{
|
||||
/**
|
||||
* Returns the generation of the book.
|
||||
* Generations higher than 1 can not be copied.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getGeneration() : int{
|
||||
return $this->generation;
|
||||
@@ -61,8 +59,6 @@ class WrittenBook extends WritableBookBase{
|
||||
/**
|
||||
* Sets the generation of a book.
|
||||
*
|
||||
* @param int $generation
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setGeneration(int $generation) : self{
|
||||
@@ -78,8 +74,6 @@ class WrittenBook extends WritableBookBase{
|
||||
* 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->author;
|
||||
@@ -88,8 +82,6 @@ class WrittenBook extends WritableBookBase{
|
||||
/**
|
||||
* Sets the author of this book.
|
||||
*
|
||||
* @param string $authorName
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAuthor(string $authorName) : self{
|
||||
@@ -100,8 +92,6 @@ class WrittenBook extends WritableBookBase{
|
||||
|
||||
/**
|
||||
* Returns the title of this book.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() : string{
|
||||
return $this->title;
|
||||
@@ -110,8 +100,6 @@ class WrittenBook extends WritableBookBase{
|
||||
/**
|
||||
* Sets the author of this book.
|
||||
*
|
||||
* @param string $title
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTitle(string $title) : self{
|
||||
|
@@ -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