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:
@@ -86,14 +86,6 @@ class Attribute{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @param float $minValue
|
||||
* @param float $maxValue
|
||||
* @param float $defaultValue
|
||||
* @param bool $shouldSend
|
||||
*
|
||||
* @return Attribute
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function register(string $id, float $minValue, float $maxValue, float $defaultValue, bool $shouldSend = true) : Attribute{
|
||||
@@ -104,11 +96,6 @@ class Attribute{
|
||||
return self::$attributes[$id] = new Attribute($id, $minValue, $maxValue, $defaultValue, $shouldSend);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*
|
||||
* @return Attribute|null
|
||||
*/
|
||||
public static function get(string $id) : ?Attribute{
|
||||
return isset(self::$attributes[$id]) ? clone self::$attributes[$id] : null;
|
||||
}
|
||||
@@ -128,8 +115,6 @@ class Attribute{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $minValue
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMinValue(float $minValue){
|
||||
@@ -149,8 +134,6 @@ class Attribute{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $maxValue
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMaxValue(float $maxValue){
|
||||
@@ -170,8 +153,6 @@ class Attribute{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $defaultValue
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefaultValue(float $defaultValue){
|
||||
@@ -195,10 +176,6 @@ class Attribute{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $value
|
||||
* @param bool $fit
|
||||
* @param bool $forceSend
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setValue(float $value, bool $fit = false, bool $forceSend = false){
|
||||
|
@@ -33,11 +33,6 @@ class AttributeMap{
|
||||
$this->attributes[$attribute->getId()] = $attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*
|
||||
* @return Attribute|null
|
||||
*/
|
||||
public function get(string $id) : ?Attribute{
|
||||
return $this->attributes[$id] ?? null;
|
||||
}
|
||||
|
@@ -281,72 +281,42 @@ abstract class Entity{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNameTag() : string{
|
||||
return $this->nameTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNameTagVisible() : bool{
|
||||
return $this->nameTagVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNameTagAlwaysVisible() : bool{
|
||||
return $this->alwaysShowNameTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setNameTag(string $name) : void{
|
||||
$this->nameTag = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setNameTagVisible(bool $value = true) : void{
|
||||
$this->nameTagVisible = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setNameTagAlwaysVisible(bool $value = true) : void{
|
||||
$this->alwaysShowNameTag = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getScoreTag() : ?string{
|
||||
return $this->scoreTag; //TODO: maybe this shouldn't be nullable?
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $score
|
||||
*/
|
||||
public function setScoreTag(string $score) : void{
|
||||
$this->scoreTag = $score;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getScale() : float{
|
||||
return $this->scale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $value
|
||||
*/
|
||||
public function setScale(float $value) : void{
|
||||
if($value <= 0){
|
||||
throw new \InvalidArgumentException("Scale must be greater than 0");
|
||||
@@ -417,7 +387,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Returns whether the entity is able to climb blocks such as ladders or vines.
|
||||
* @return bool
|
||||
*/
|
||||
public function canClimb() : bool{
|
||||
return $this->canClimb;
|
||||
@@ -425,8 +394,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Sets whether the entity is able to climb climbable blocks.
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setCanClimb(bool $value = true) : void{
|
||||
$this->canClimb = $value;
|
||||
@@ -434,8 +401,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Returns whether this entity is climbing a block. By default this is only true if the entity is climbing a ladder or vine or similar block.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canClimbWalls() : bool{
|
||||
return $this->canClimbWalls;
|
||||
@@ -443,8 +408,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Sets whether the entity is climbing a block. If true, the entity can climb anything.
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setCanClimbWalls(bool $value = true) : void{
|
||||
$this->canClimbWalls = $value;
|
||||
@@ -452,7 +415,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Returns the entity ID of the owning entity, or null if the entity doesn't have an owner.
|
||||
* @return int|null
|
||||
*/
|
||||
public function getOwningEntityId() : ?int{
|
||||
return $this->ownerId;
|
||||
@@ -460,7 +422,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Returns the owning entity, or null if the entity was not found.
|
||||
* @return Entity|null
|
||||
*/
|
||||
public function getOwningEntity() : ?Entity{
|
||||
return $this->ownerId !== null ? $this->server->getWorldManager()->findEntity($this->ownerId) : null;
|
||||
@@ -469,8 +430,6 @@ abstract class Entity{
|
||||
/**
|
||||
* Sets the owner of the entity. Passing null will remove the current owner.
|
||||
*
|
||||
* @param Entity|null $owner
|
||||
*
|
||||
* @throws \InvalidArgumentException if the supplied entity is not valid
|
||||
*/
|
||||
public function setOwningEntity(?Entity $owner) : void{
|
||||
@@ -485,7 +444,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Returns the entity ID of the entity's target, or null if it doesn't have a target.
|
||||
* @return int|null
|
||||
*/
|
||||
public function getTargetEntityId() : ?int{
|
||||
return $this->targetId;
|
||||
@@ -494,8 +452,6 @@ abstract class Entity{
|
||||
/**
|
||||
* Returns the entity's target entity, or null if not found.
|
||||
* This is used for things like hostile mobs attacking entities, and for fishing rods reeling hit entities in.
|
||||
*
|
||||
* @return Entity|null
|
||||
*/
|
||||
public function getTargetEntity() : ?Entity{
|
||||
return $this->targetId !== null ? $this->server->getWorldManager()->findEntity($this->targetId) : null;
|
||||
@@ -504,8 +460,6 @@ abstract class Entity{
|
||||
/**
|
||||
* Sets the entity's target entity. Passing null will remove the current target.
|
||||
*
|
||||
* @param Entity|null $target
|
||||
*
|
||||
* @throws \InvalidArgumentException if the target entity is not valid
|
||||
*/
|
||||
public function setTargetEntity(?Entity $target) : void{
|
||||
@@ -520,7 +474,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Returns whether this entity will be saved when its chunk is unloaded.
|
||||
* @return bool
|
||||
*/
|
||||
public function canSaveWithChunk() : bool{
|
||||
return $this->savedWithChunk;
|
||||
@@ -529,8 +482,6 @@ abstract class Entity{
|
||||
/**
|
||||
* Sets whether this entity will be saved when its chunk is unloaded. This can be used to prevent the entity being
|
||||
* saved to disk.
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setCanSaveWithChunk(bool $value) : void{
|
||||
$this->savedWithChunk = $value;
|
||||
@@ -596,9 +547,6 @@ abstract class Entity{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EntityDamageEvent $source
|
||||
*/
|
||||
public function attack(EntityDamageEvent $source) : void{
|
||||
$source->call();
|
||||
if($source->isCancelled()){
|
||||
@@ -610,9 +558,6 @@ abstract class Entity{
|
||||
$this->setHealth($this->getHealth() - $source->getFinalDamage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EntityRegainHealthEvent $source
|
||||
*/
|
||||
public function heal(EntityRegainHealthEvent $source) : void{
|
||||
$source->call();
|
||||
if($source->isCancelled()){
|
||||
@@ -639,10 +584,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Called to tick entities while dead. Returns whether the entity should be flagged for despawn yet.
|
||||
*
|
||||
* @param int $tickDiff
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function onDeathUpdate(int $tickDiff) : bool{
|
||||
return true;
|
||||
@@ -652,17 +593,12 @@ abstract class Entity{
|
||||
return $this->health > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getHealth() : float{
|
||||
return $this->health;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the health of the Entity. This won't send any update to the players
|
||||
*
|
||||
* @param float $amount
|
||||
*/
|
||||
public function setHealth(float $amount) : void{
|
||||
if($amount == $this->health){
|
||||
@@ -680,30 +616,18 @@ abstract class Entity{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxHealth() : int{
|
||||
return $this->maxHealth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $amount
|
||||
*/
|
||||
public function setMaxHealth(int $amount) : void{
|
||||
$this->maxHealth = $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EntityDamageEvent $type
|
||||
*/
|
||||
public function setLastDamageCause(EntityDamageEvent $type) : void{
|
||||
$this->lastDamageCause = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EntityDamageEvent|null
|
||||
*/
|
||||
public function getLastDamageCause() : ?EntityDamageEvent{
|
||||
return $this->lastDamageCause;
|
||||
}
|
||||
@@ -764,15 +688,11 @@ abstract class Entity{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFireTicks() : int{
|
||||
return $this->fireTicks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $fireTicks
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setFireTicks(int $fireTicks) : void{
|
||||
@@ -1033,9 +953,6 @@ abstract class Entity{
|
||||
return Facing::EAST;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Vector3
|
||||
*/
|
||||
public function getDirectionVector() : Vector3{
|
||||
$y = -sin(deg2rad($this->location->pitch));
|
||||
$xz = cos(deg2rad($this->location->pitch));
|
||||
@@ -1125,8 +1042,6 @@ abstract class Entity{
|
||||
/**
|
||||
* Flags the entity as needing a movement update on the next tick. Setting this forces a movement update even if the
|
||||
* entity's motion is zero. Used to trigger movement updates when blocks change near entities.
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
final public function setForceMovementUpdate(bool $value = true) : void{
|
||||
$this->forceMovementUpdate = $value;
|
||||
@@ -1136,7 +1051,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Returns whether the entity needs a movement update on the next tick.
|
||||
* @return bool
|
||||
*/
|
||||
public function hasMovementUpdate() : bool{
|
||||
return (
|
||||
@@ -1152,10 +1066,6 @@ abstract class Entity{
|
||||
$this->fallDistance = 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $distanceThisTick
|
||||
* @param bool $onGround
|
||||
*/
|
||||
protected function updateFallState(float $distanceThisTick, bool $onGround) : void{
|
||||
if($onGround){
|
||||
if($this->fallDistance > 0){
|
||||
@@ -1169,8 +1079,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Called when a falling entity hits the ground.
|
||||
*
|
||||
* @param float $fallDistance
|
||||
*/
|
||||
public function fall(float $fallDistance) : void{
|
||||
|
||||
@@ -1397,8 +1305,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Returns whether this entity can be moved by currents in liquids.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canBeMovedByCurrents() : bool{
|
||||
return true;
|
||||
@@ -1533,10 +1439,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Adds the given values to the entity's motion vector.
|
||||
*
|
||||
* @param float $x
|
||||
* @param float $y
|
||||
* @param float $z
|
||||
*/
|
||||
public function addMotion(float $x, float $y, float $z) : void{
|
||||
$this->motion->x += $x;
|
||||
@@ -1550,10 +1452,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* @param Vector3|Position|Location $pos
|
||||
* @param float|null $yaw
|
||||
* @param float|null $pitch
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function teleport(Vector3 $pos, ?float $yaw = null, ?float $pitch = null) : bool{
|
||||
if($pos instanceof Location){
|
||||
@@ -1615,8 +1513,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Called by spawnTo() to send whatever packets needed to spawn the entity to the client.
|
||||
*
|
||||
* @param Player $player
|
||||
*/
|
||||
protected function sendSpawnPacket(Player $player) : void{
|
||||
$pk = new AddActorPacket();
|
||||
@@ -1633,9 +1529,6 @@ abstract class Entity{
|
||||
$player->getNetworkSession()->sendDataPacket($pk);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
*/
|
||||
public function spawnTo(Player $player) : void{
|
||||
$id = spl_object_id($player);
|
||||
if(!isset($this->hasSpawned[$id]) and $player->isUsingChunk($this->location->getFloorX() >> 4, $this->location->getFloorZ() >> 4)){
|
||||
@@ -1664,9 +1557,6 @@ abstract class Entity{
|
||||
/**
|
||||
* @deprecated WARNING: This function DOES NOT permanently hide the entity from the player. As soon as the entity or
|
||||
* player moves, the player will once again be able to see the entity.
|
||||
*
|
||||
* @param Player $player
|
||||
* @param bool $send
|
||||
*/
|
||||
public function despawnFrom(Player $player, bool $send = true) : void{
|
||||
$id = spl_object_id($player);
|
||||
@@ -1702,7 +1592,6 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* Returns whether the entity has been "closed".
|
||||
* @return bool
|
||||
*/
|
||||
public function isClosed() : bool{
|
||||
return $this->closed;
|
||||
@@ -1773,8 +1662,6 @@ abstract class Entity{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $dirtyOnly
|
||||
*
|
||||
* @return MetadataProperty[]
|
||||
*/
|
||||
final protected function getSyncedNetworkData(bool $dirtyOnly) : array{
|
||||
|
@@ -163,8 +163,6 @@ final class EntityFactory{
|
||||
|
||||
/**
|
||||
* Returns a new runtime entity ID for a new entity.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function nextRuntimeId() : int{
|
||||
return self::$entityCount++;
|
||||
@@ -176,9 +174,6 @@ final class EntityFactory{
|
||||
*
|
||||
* TODO: make this NBT-independent
|
||||
*
|
||||
* @param string $baseClass
|
||||
* @param World $world
|
||||
* @param CompoundTag $nbt
|
||||
* @param mixed ...$args
|
||||
*
|
||||
* @return Entity instanceof $baseClass
|
||||
@@ -203,10 +198,6 @@ final class EntityFactory{
|
||||
/**
|
||||
* Creates an entity from data stored on a chunk.
|
||||
*
|
||||
* @param World $world
|
||||
* @param CompoundTag $nbt
|
||||
*
|
||||
* @return Entity|null
|
||||
* @throws \RuntimeException
|
||||
*@internal
|
||||
*
|
||||
@@ -243,13 +234,6 @@ final class EntityFactory{
|
||||
|
||||
/**
|
||||
* Helper function which creates minimal NBT needed to spawn an entity.
|
||||
*
|
||||
* @param Vector3 $pos
|
||||
* @param Vector3|null $motion
|
||||
* @param float $yaw
|
||||
* @param float $pitch
|
||||
*
|
||||
* @return CompoundTag
|
||||
*/
|
||||
public static function createBaseNBT(Vector3 $pos, ?Vector3 $motion = null, float $yaw = 0.0, float $pitch = 0.0) : CompoundTag{
|
||||
return CompoundTag::create()
|
||||
|
@@ -64,7 +64,6 @@ class ExperienceManager{
|
||||
|
||||
/**
|
||||
* Returns the player's experience level.
|
||||
* @return int
|
||||
*/
|
||||
public function getXpLevel() : int{
|
||||
return (int) $this->levelAttr->getValue();
|
||||
@@ -72,10 +71,6 @@ class ExperienceManager{
|
||||
|
||||
/**
|
||||
* Sets the player's experience level. This does not affect their total XP or their XP progress.
|
||||
*
|
||||
* @param int $level
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setXpLevel(int $level) : bool{
|
||||
return $this->setXpAndProgress($level, null);
|
||||
@@ -83,11 +78,6 @@ class ExperienceManager{
|
||||
|
||||
/**
|
||||
* Adds a number of XP levels to the player.
|
||||
*
|
||||
* @param int $amount
|
||||
* @param bool $playSound
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function addXpLevels(int $amount, bool $playSound = true) : bool{
|
||||
$oldLevel = $this->getXpLevel();
|
||||
@@ -107,10 +97,6 @@ class ExperienceManager{
|
||||
|
||||
/**
|
||||
* Subtracts a number of XP levels from the player.
|
||||
*
|
||||
* @param int $amount
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function subtractXpLevels(int $amount) : bool{
|
||||
return $this->addXpLevels(-$amount);
|
||||
@@ -118,7 +104,6 @@ class ExperienceManager{
|
||||
|
||||
/**
|
||||
* Returns a value between 0.0 and 1.0 to indicate how far through the current level the player is.
|
||||
* @return float
|
||||
*/
|
||||
public function getXpProgress() : float{
|
||||
return $this->progressAttr->getValue();
|
||||
@@ -126,10 +111,6 @@ class ExperienceManager{
|
||||
|
||||
/**
|
||||
* Sets the player's progress through the current level to a value between 0.0 and 1.0.
|
||||
*
|
||||
* @param float $progress
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setXpProgress(float $progress) : bool{
|
||||
return $this->setXpAndProgress(null, $progress);
|
||||
@@ -137,7 +118,6 @@ class ExperienceManager{
|
||||
|
||||
/**
|
||||
* Returns the number of XP points the player has progressed into their current level.
|
||||
* @return int
|
||||
*/
|
||||
public function getRemainderXp() : int{
|
||||
return (int) (ExperienceUtils::getXpToCompleteLevel($this->getXpLevel()) * $this->getXpProgress());
|
||||
@@ -147,8 +127,6 @@ class ExperienceManager{
|
||||
* Returns the amount of XP points the player currently has, calculated from their current level and progress
|
||||
* through their current level. This will be reduced by enchanting deducting levels and is used to calculate the
|
||||
* amount of XP the player drops on death.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCurrentTotalXp() : int{
|
||||
return ExperienceUtils::getXpToReachLevel($this->getXpLevel()) + $this->getRemainderXp();
|
||||
@@ -157,10 +135,6 @@ class ExperienceManager{
|
||||
/**
|
||||
* Sets the current total of XP the player has, recalculating their XP level and progress.
|
||||
* Note that this DOES NOT update the player's lifetime total XP.
|
||||
*
|
||||
* @param int $amount
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setCurrentTotalXp(int $amount) : bool{
|
||||
$newLevel = ExperienceUtils::getLevelFromXp($amount);
|
||||
@@ -172,10 +146,7 @@ class ExperienceManager{
|
||||
* Adds an amount of XP to the player, recalculating their XP level and progress. XP amount will be added to the
|
||||
* player's lifetime XP.
|
||||
*
|
||||
* @param int $amount
|
||||
* @param bool $playSound Whether to play level-up and XP gained sounds.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function addXp(int $amount, bool $playSound = true) : bool{
|
||||
$this->totalXp += $amount;
|
||||
@@ -201,10 +172,6 @@ class ExperienceManager{
|
||||
|
||||
/**
|
||||
* Takes an amount of XP from the player, recalculating their XP level and progress.
|
||||
*
|
||||
* @param int $amount
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function subtractXp(int $amount) : bool{
|
||||
return $this->addXp(-$amount);
|
||||
@@ -234,9 +201,6 @@ class ExperienceManager{
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @param int $level
|
||||
* @param float $progress
|
||||
*/
|
||||
public function setXpAndProgressNoEvent(int $level, float $progress) : void{
|
||||
$this->levelAttr->setValue($level);
|
||||
@@ -246,8 +210,6 @@ class ExperienceManager{
|
||||
/**
|
||||
* Returns the total XP the player has collected in their lifetime. Resets when the player dies.
|
||||
* XP levels being removed in enchanting do not reduce this number.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLifetimeTotalXp() : int{
|
||||
return $this->totalXp;
|
||||
@@ -256,8 +218,6 @@ class ExperienceManager{
|
||||
/**
|
||||
* Sets the lifetime total XP of the player. This does not recalculate their level or progress. Used for player
|
||||
* score when they die. (TODO: add this when MCPE supports it)
|
||||
*
|
||||
* @param int $amount
|
||||
*/
|
||||
public function setLifetimeTotalXp(int $amount) : void{
|
||||
if($amount < 0){
|
||||
@@ -270,7 +230,6 @@ class ExperienceManager{
|
||||
|
||||
/**
|
||||
* Returns whether the human can pickup XP orbs (checks cooldown time)
|
||||
* @return bool
|
||||
*/
|
||||
public function canPickupXp() : bool{
|
||||
return $this->xpCooldown === 0;
|
||||
@@ -314,8 +273,6 @@ class ExperienceManager{
|
||||
|
||||
/**
|
||||
* Sets the duration in ticks until the human can pick up another XP orb.
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function resetXpCooldown(int $value = 2) : void{
|
||||
$this->xpCooldown = $value;
|
||||
|
@@ -112,25 +112,17 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
* @deprecated
|
||||
*
|
||||
* Checks the length of a supplied skin bitmap and returns whether the length is valid.
|
||||
*
|
||||
* @param string $skin
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isValidSkin(string $skin) : bool{
|
||||
return in_array(strlen($skin), Skin::ACCEPTED_SKIN_SIZES, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UUID
|
||||
*/
|
||||
public function getUniqueId() : UUID{
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Skin object containing information about this human's skin.
|
||||
* @return Skin
|
||||
*/
|
||||
public function getSkin() : Skin{
|
||||
return $this->skin;
|
||||
@@ -139,8 +131,6 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
/**
|
||||
* Sets the human's skin. This will not send any update to viewers, you need to do that manually using
|
||||
* {@link sendSkin}.
|
||||
*
|
||||
* @param Skin $skin
|
||||
*/
|
||||
public function setSkin(Skin $skin) : void{
|
||||
$this->skin = $skin;
|
||||
@@ -168,9 +158,6 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HungerManager
|
||||
*/
|
||||
public function getHungerManager() : HungerManager{
|
||||
return $this->hungerManager;
|
||||
}
|
||||
@@ -188,9 +175,6 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
return parent::consumeObject($consumable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ExperienceManager
|
||||
*/
|
||||
public function getXpManager() : ExperienceManager{
|
||||
return $this->xpManager;
|
||||
}
|
||||
@@ -214,8 +198,6 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
|
||||
/**
|
||||
* For Human entities which are not players, sets their properties such as nametag, skin and UUID from NBT.
|
||||
*
|
||||
* @param CompoundTag $nbt
|
||||
*/
|
||||
protected function initHumanData(CompoundTag $nbt) : void{
|
||||
if($nbt->hasTag("NameTag", StringTag::class)){
|
||||
|
@@ -69,8 +69,6 @@ class HungerManager{
|
||||
* WARNING: This method does not check if full and may throw an exception if out of bounds.
|
||||
* @see HungerManager::addFood()
|
||||
*
|
||||
* @param float $new
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setFood(float $new) : void{
|
||||
@@ -98,8 +96,6 @@ class HungerManager{
|
||||
|
||||
/**
|
||||
* Returns whether this Human may consume objects requiring hunger.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isHungry() : bool{
|
||||
return $this->getFood() < $this->getMaxFood();
|
||||
@@ -113,8 +109,6 @@ class HungerManager{
|
||||
* WARNING: This method does not check if saturated and may throw an exception if out of bounds.
|
||||
* @see HungerManager::addSaturation()
|
||||
*
|
||||
* @param float $saturation
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setSaturation(float $saturation) : void{
|
||||
@@ -132,8 +126,6 @@ class HungerManager{
|
||||
/**
|
||||
* WARNING: This method does not check if exhausted and does not consume saturation/food.
|
||||
* @see HungerManager::exhaust()
|
||||
*
|
||||
* @param float $exhaustion
|
||||
*/
|
||||
public function setExhaustion(float $exhaustion) : void{
|
||||
$this->exhaustionAttr->setValue($exhaustion);
|
||||
@@ -142,9 +134,6 @@ class HungerManager{
|
||||
/**
|
||||
* Increases exhaustion level.
|
||||
*
|
||||
* @param float $amount
|
||||
* @param int $cause
|
||||
*
|
||||
* @return float the amount of exhaustion level increased
|
||||
*/
|
||||
public function exhaust(float $amount, int $cause = PlayerExhaustEvent::CAUSE_CUSTOM) : float{
|
||||
@@ -180,16 +169,10 @@ class HungerManager{
|
||||
return $ev->getAmount();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFoodTickTimer() : int{
|
||||
return $this->foodTickTimer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $foodTickTimer
|
||||
*/
|
||||
public function setFoodTickTimer(int $foodTickTimer) : void{
|
||||
if($foodTickTimer < 0){
|
||||
throw new \InvalidArgumentException("Expected a non-negative value");
|
||||
@@ -238,16 +221,10 @@ class HungerManager{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled() : bool{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $enabled
|
||||
*/
|
||||
public function setEnabled(bool $enabled) : void{
|
||||
$this->enabled = $enabled;
|
||||
}
|
||||
|
@@ -217,10 +217,6 @@ abstract class Living extends Entity{
|
||||
/**
|
||||
* Causes the mob to consume the given Consumable object, applying applicable effects, health bonuses, food bonuses,
|
||||
* etc.
|
||||
*
|
||||
* @param Consumable $consumable
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function consumeObject(Consumable $consumable) : bool{
|
||||
foreach($consumable->getAdditionalEffects() as $effect){
|
||||
@@ -234,7 +230,6 @@ abstract class Living extends Entity{
|
||||
|
||||
/**
|
||||
* Returns the initial upwards velocity of a jumping entity in blocks/tick, including additional velocity due to effects.
|
||||
* @return float
|
||||
*/
|
||||
public function getJumpVelocity() : float{
|
||||
return $this->jumpVelocity + ($this->effectManager->has(VanillaEffects::JUMP_BOOST()) ? ($this->effectManager->get(VanillaEffects::JUMP_BOOST())->getEffectLevel() / 10) : 0);
|
||||
@@ -261,8 +256,6 @@ abstract class Living extends Entity{
|
||||
* Returns how many armour points this mob has. Armour points provide a percentage reduction to damage.
|
||||
* For mobs which can wear armour, this should return the sum total of the armour points provided by their
|
||||
* equipment.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getArmorPoints() : int{
|
||||
$total = 0;
|
||||
@@ -275,10 +268,6 @@ abstract class Living extends Entity{
|
||||
|
||||
/**
|
||||
* Returns the highest level of the specified enchantment on any armour piece that the entity is currently wearing.
|
||||
*
|
||||
* @param Enchantment $enchantment
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHighestArmorEnchantmentLevel(Enchantment $enchantment) : int{
|
||||
$result = 0;
|
||||
@@ -289,9 +278,6 @@ abstract class Living extends Entity{
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArmorInventory
|
||||
*/
|
||||
public function getArmorInventory() : ArmorInventory{
|
||||
return $this->armorInventory;
|
||||
}
|
||||
@@ -303,8 +289,6 @@ abstract class Living extends Entity{
|
||||
/**
|
||||
* Called prior to EntityDamageEvent execution to apply modifications to the event's damage, such as reduction due
|
||||
* to effects or armour.
|
||||
*
|
||||
* @param EntityDamageEvent $source
|
||||
*/
|
||||
public function applyDamageModifiers(EntityDamageEvent $source) : void{
|
||||
if($source->canBeReducedByArmor()){
|
||||
@@ -332,8 +316,6 @@ abstract class Living extends Entity{
|
||||
* Called after EntityDamageEvent execution to apply post-hurt effects, such as reducing absorption or modifying
|
||||
* armour durability.
|
||||
* This will not be called by damage sources causing death.
|
||||
*
|
||||
* @param EntityDamageEvent $source
|
||||
*/
|
||||
protected function applyPostDamageEffects(EntityDamageEvent $source) : void{
|
||||
$this->setAbsorption(max(0, $this->getAbsorption() + $source->getModifier(EntityDamageEvent::MODIFIER_ABSORPTION)));
|
||||
@@ -363,8 +345,6 @@ abstract class Living extends Entity{
|
||||
/**
|
||||
* Damages the worn armour according to the amount of damage given. Each 4 points (rounded down) deals 1 damage
|
||||
* point to each armour piece, but never less than 1 total.
|
||||
*
|
||||
* @param float $damage
|
||||
*/
|
||||
public function damageArmor(float $damage) : void{
|
||||
$durabilityRemoved = (int) max(floor($damage / 4), 1);
|
||||
@@ -544,10 +524,6 @@ abstract class Living extends Entity{
|
||||
|
||||
/**
|
||||
* Ticks the entity's air supply, consuming it when underwater and regenerating it when out of water.
|
||||
*
|
||||
* @param int $tickDiff
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doAirSupplyTick(int $tickDiff) : bool{
|
||||
$ticks = $this->getAirSupplyTicks();
|
||||
@@ -583,7 +559,6 @@ abstract class Living extends Entity{
|
||||
|
||||
/**
|
||||
* Returns whether the entity can currently breathe.
|
||||
* @return bool
|
||||
*/
|
||||
public function canBreathe() : bool{
|
||||
return $this->effectManager->has(VanillaEffects::WATER_BREATHING()) or $this->effectManager->has(VanillaEffects::CONDUIT_POWER()) or !$this->isUnderwater();
|
||||
@@ -591,7 +566,6 @@ abstract class Living extends Entity{
|
||||
|
||||
/**
|
||||
* Returns whether the entity is currently breathing or not. If this is false, the entity's air supply will be used.
|
||||
* @return bool
|
||||
*/
|
||||
public function isBreathing() : bool{
|
||||
return $this->breathing;
|
||||
@@ -600,8 +574,6 @@ abstract class Living extends Entity{
|
||||
/**
|
||||
* Sets whether the entity is currently breathing. If false, it will cause the entity's air supply to be used.
|
||||
* For players, this also shows the oxygen bar.
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setBreathing(bool $value = true) : void{
|
||||
$this->breathing = $value;
|
||||
@@ -610,8 +582,6 @@ abstract class Living extends Entity{
|
||||
/**
|
||||
* Returns the number of ticks remaining in the entity's air supply. Note that the entity may survive longer than
|
||||
* this amount of time without damage due to enchantments such as Respiration.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAirSupplyTicks() : int{
|
||||
return $this->breathTicks;
|
||||
@@ -619,8 +589,6 @@ abstract class Living extends Entity{
|
||||
|
||||
/**
|
||||
* Sets the number of air ticks left in the entity's air supply.
|
||||
*
|
||||
* @param int $ticks
|
||||
*/
|
||||
public function setAirSupplyTicks(int $ticks) : void{
|
||||
$this->breathTicks = $ticks;
|
||||
@@ -628,7 +596,6 @@ abstract class Living extends Entity{
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of air ticks the entity's air supply can contain.
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxAirSupplyTicks() : int{
|
||||
return $this->maxBreathTicks;
|
||||
@@ -636,8 +603,6 @@ abstract class Living extends Entity{
|
||||
|
||||
/**
|
||||
* Sets the maximum amount of air ticks the air supply can hold.
|
||||
*
|
||||
* @param int $ticks
|
||||
*/
|
||||
public function setMaxAirSupplyTicks(int $ticks) : void{
|
||||
$this->maxBreathTicks = $ticks;
|
||||
@@ -661,17 +626,12 @@ abstract class Living extends Entity{
|
||||
|
||||
/**
|
||||
* Returns the amount of XP this mob will drop on death.
|
||||
* @return int
|
||||
*/
|
||||
public function getXpDropAmount() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $maxDistance
|
||||
* @param int $maxLength
|
||||
* @param array $transparent
|
||||
*
|
||||
* @return Block[]
|
||||
*/
|
||||
public function getLineOfSight(int $maxDistance, int $maxLength = 0, array $transparent = []) : array{
|
||||
@@ -711,12 +671,6 @@ abstract class Living extends Entity{
|
||||
return $blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $maxDistance
|
||||
* @param array $transparent
|
||||
*
|
||||
* @return Block|null
|
||||
*/
|
||||
public function getTargetBlock(int $maxDistance, array $transparent = []) : ?Block{
|
||||
$line = $this->getLineOfSight($maxDistance, 1, $transparent);
|
||||
if(count($line) > 0){
|
||||
@@ -729,8 +683,6 @@ abstract class Living extends Entity{
|
||||
/**
|
||||
* Changes the entity's yaw and pitch to make it look at the specified Vector3 position. For mobs, this will cause
|
||||
* their heads to turn.
|
||||
*
|
||||
* @param Vector3 $target
|
||||
*/
|
||||
public function lookAt(Vector3 $target) : void{
|
||||
$horizontal = sqrt(($target->x - $this->location->x) ** 2 + ($target->z - $this->location->z) ** 2);
|
||||
|
@@ -38,8 +38,6 @@ class Location extends Position{
|
||||
* @param float|int $x
|
||||
* @param float|int $y
|
||||
* @param float|int $z
|
||||
* @param float $yaw
|
||||
* @param float $pitch
|
||||
* @param World $world
|
||||
*/
|
||||
public function __construct($x = 0, $y = 0, $z = 0, float $yaw = 0.0, float $pitch = 0.0, ?World $world = null){
|
||||
@@ -49,7 +47,6 @@ class Location extends Position{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Vector3 $pos
|
||||
* @param World|null $world default null
|
||||
* @param float $yaw default 0.0
|
||||
* @param float $pitch default 0.0
|
||||
@@ -62,8 +59,6 @@ class Location extends Position{
|
||||
|
||||
/**
|
||||
* Return a Location instance
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public function asLocation() : Location{
|
||||
return new Location($this->x, $this->y, $this->z, $this->yaw, $this->pitch, $this->world);
|
||||
|
@@ -83,37 +83,22 @@ final class Skin{
|
||||
$this->geometryData = $geometryData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSkinId() : string{
|
||||
return $this->skinId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSkinData() : string{
|
||||
return $this->skinData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCapeData() : string{
|
||||
return $this->capeData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getGeometryName() : string{
|
||||
return $this->geometryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getGeometryData() : string{
|
||||
return $this->geometryData;
|
||||
}
|
||||
|
@@ -71,8 +71,6 @@ class Villager extends Living implements Ageable{
|
||||
|
||||
/**
|
||||
* Sets the villager profession
|
||||
*
|
||||
* @param int $profession
|
||||
*/
|
||||
public function setProfession(int $profession) : void{
|
||||
$this->profession = $profession; //TODO: validation
|
||||
|
@@ -57,7 +57,6 @@ class Effect{
|
||||
|
||||
/**
|
||||
* Returns the effect ID as per Minecraft PE
|
||||
* @return int
|
||||
*/
|
||||
public function getId() : int{
|
||||
return $this->id;
|
||||
@@ -65,7 +64,6 @@ class Effect{
|
||||
|
||||
/**
|
||||
* Returns the translation key used to translate this effect's name.
|
||||
* @return string
|
||||
*/
|
||||
public function getName() : string{
|
||||
return $this->name;
|
||||
@@ -73,7 +71,6 @@ class Effect{
|
||||
|
||||
/**
|
||||
* Returns a Color object representing this effect's particle colour.
|
||||
* @return Color
|
||||
*/
|
||||
public function getColor() : Color{
|
||||
return $this->color;
|
||||
@@ -82,8 +79,6 @@ class Effect{
|
||||
/**
|
||||
* Returns whether this effect is harmful.
|
||||
* TODO: implement inverse effect results for undead mobs
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isBad() : bool{
|
||||
return $this->bad;
|
||||
@@ -91,7 +86,6 @@ class Effect{
|
||||
|
||||
/**
|
||||
* Returns the default duration (in ticks) this effect will apply for if a duration is not specified.
|
||||
* @return int
|
||||
*/
|
||||
public function getDefaultDuration() : int{
|
||||
return 600;
|
||||
@@ -99,7 +93,6 @@ class Effect{
|
||||
|
||||
/**
|
||||
* Returns whether this effect will give the subject potion bubbles.
|
||||
* @return bool
|
||||
*/
|
||||
public function hasBubbles() : bool{
|
||||
return $this->hasBubbles;
|
||||
@@ -107,10 +100,6 @@ class Effect{
|
||||
|
||||
/**
|
||||
* Returns whether the effect will do something on the current tick.
|
||||
*
|
||||
* @param EffectInstance $instance
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canTick(EffectInstance $instance) : bool{
|
||||
return false;
|
||||
@@ -118,11 +107,6 @@ class Effect{
|
||||
|
||||
/**
|
||||
* Applies effect results to an entity. This will not be called unless canTick() returns true.
|
||||
*
|
||||
* @param Living $entity
|
||||
* @param EffectInstance $instance
|
||||
* @param float $potency
|
||||
* @param null|Entity $source
|
||||
*/
|
||||
public function applyEffect(Living $entity, EffectInstance $instance, float $potency = 1.0, ?Entity $source = null) : void{
|
||||
|
||||
@@ -130,9 +114,6 @@ class Effect{
|
||||
|
||||
/**
|
||||
* Applies effects to the entity when the effect is first added.
|
||||
*
|
||||
* @param Living $entity
|
||||
* @param EffectInstance $instance
|
||||
*/
|
||||
public function add(Living $entity, EffectInstance $instance) : void{
|
||||
|
||||
@@ -140,9 +121,6 @@ class Effect{
|
||||
|
||||
/**
|
||||
* Removes the effect from the entity, resetting any changed values back to their original defaults.
|
||||
*
|
||||
* @param Living $entity
|
||||
* @param EffectInstance $instance
|
||||
*/
|
||||
public function remove(Living $entity, EffectInstance $instance) : void{
|
||||
|
||||
|
@@ -47,12 +47,7 @@ class EffectInstance{
|
||||
private $color;
|
||||
|
||||
/**
|
||||
* @param Effect $effectType
|
||||
* @param int|null $duration Passing null will use the effect type's default duration
|
||||
* @param int $amplifier
|
||||
* @param bool $visible
|
||||
* @param bool $ambient
|
||||
* @param null|Color $overrideColor
|
||||
*/
|
||||
public function __construct(Effect $effectType, ?int $duration = null, int $amplifier = 0, bool $visible = true, bool $ambient = false, ?Color $overrideColor = null){
|
||||
$this->effectType = $effectType;
|
||||
@@ -67,17 +62,12 @@ class EffectInstance{
|
||||
return $this->effectType->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Effect
|
||||
*/
|
||||
public function getType() : Effect{
|
||||
return $this->effectType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of ticks remaining until the effect expires.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDuration() : int{
|
||||
return $this->duration;
|
||||
@@ -86,8 +76,6 @@ class EffectInstance{
|
||||
/**
|
||||
* Sets the number of ticks remaining until the effect expires.
|
||||
*
|
||||
* @param int $duration
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return $this
|
||||
@@ -104,8 +92,6 @@ class EffectInstance{
|
||||
/**
|
||||
* Decreases the duration by the given number of ticks, without dropping below zero.
|
||||
*
|
||||
* @param int $ticks
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function decreaseDuration(int $ticks) : EffectInstance{
|
||||
@@ -116,32 +102,23 @@ class EffectInstance{
|
||||
|
||||
/**
|
||||
* Returns whether the duration has run out.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasExpired() : bool{
|
||||
return $this->duration <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAmplifier() : int{
|
||||
return $this->amplifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the level of this effect, which is always one higher than the amplifier.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getEffectLevel() : int{
|
||||
return $this->amplifier + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $amplifier
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAmplifier(int $amplifier) : EffectInstance{
|
||||
@@ -155,16 +132,12 @@ class EffectInstance{
|
||||
|
||||
/**
|
||||
* Returns whether this effect will produce some visible effect, such as bubbles or particles.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isVisible() : bool{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $visible
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setVisible(bool $visible = true) : EffectInstance{
|
||||
@@ -177,16 +150,12 @@ class EffectInstance{
|
||||
* Returns whether the effect originated from the ambient environment.
|
||||
* Ambient effects can originate from things such as a Beacon's area of effect radius.
|
||||
* If this flag is set, the amount of visible particles will be reduced by a factor of 5.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAmbient() : bool{
|
||||
return $this->ambient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $ambient
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAmbient(bool $ambient = true) : EffectInstance{
|
||||
@@ -198,8 +167,6 @@ class EffectInstance{
|
||||
/**
|
||||
* Returns the particle colour of this effect instance. This can be overridden on a per-EffectInstance basis, so it
|
||||
* is not reflective of the default colour of the effect.
|
||||
*
|
||||
* @return Color
|
||||
*/
|
||||
public function getColor() : Color{
|
||||
return $this->color;
|
||||
@@ -207,10 +174,6 @@ class EffectInstance{
|
||||
|
||||
/**
|
||||
* Sets the colour of this EffectInstance.
|
||||
*
|
||||
* @param Color $color
|
||||
*
|
||||
* @return EffectInstance
|
||||
*/
|
||||
public function setColor(Color $color) : EffectInstance{
|
||||
$this->color = $color;
|
||||
@@ -220,8 +183,6 @@ class EffectInstance{
|
||||
|
||||
/**
|
||||
* Resets the colour of this EffectInstance to the default specified by its type.
|
||||
*
|
||||
* @return EffectInstance
|
||||
*/
|
||||
public function resetColor() : EffectInstance{
|
||||
$this->color = $this->effectType->getColor();
|
||||
|
@@ -73,8 +73,6 @@ class EffectManager{
|
||||
|
||||
/**
|
||||
* Removes the effect with the specified ID from the mob.
|
||||
*
|
||||
* @param Effect $effectType
|
||||
*/
|
||||
public function remove(Effect $effectType) : void{
|
||||
$index = $effectType->getId();
|
||||
@@ -105,10 +103,6 @@ class EffectManager{
|
||||
/**
|
||||
* Returns the effect instance active on this entity with the specified ID, or null if the mob does not have the
|
||||
* effect.
|
||||
*
|
||||
* @param Effect $effect
|
||||
*
|
||||
* @return EffectInstance|null
|
||||
*/
|
||||
public function get(Effect $effect) : ?EffectInstance{
|
||||
return $this->effects[$effect->getId()] ?? null;
|
||||
@@ -116,10 +110,6 @@ class EffectManager{
|
||||
|
||||
/**
|
||||
* Returns whether the specified effect is active on the mob.
|
||||
*
|
||||
* @param Effect $effect
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has(Effect $effect) : bool{
|
||||
return isset($this->effects[$effect->getId()]);
|
||||
@@ -130,8 +120,6 @@ class EffectManager{
|
||||
* If a weaker effect of the same type is already applied, it will be replaced.
|
||||
* If a weaker or equal-strength effect is already applied but has a shorter duration, it will be replaced.
|
||||
*
|
||||
* @param EffectInstance $effect
|
||||
*
|
||||
* @return bool whether the effect has been successfully applied.
|
||||
*/
|
||||
public function add(EffectInstance $effect) : bool{
|
||||
@@ -203,16 +191,10 @@ class EffectManager{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Color
|
||||
*/
|
||||
public function getBubbleColor() : Color{
|
||||
return $this->bubbleColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOnlyAmbientEffects() : bool{
|
||||
return $this->onlyAmbientEffects;
|
||||
}
|
||||
|
@@ -104,11 +104,6 @@ final class VanillaEffects{
|
||||
self::$mcpeIdMap[$member->getId()] = $member;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return Effect|null
|
||||
*/
|
||||
public static function byMcpeId(int $id) : ?Effect{
|
||||
self::checkInit();
|
||||
return self::$mcpeIdMap[$id] ?? null;
|
||||
@@ -121,11 +116,6 @@ final class VanillaEffects{
|
||||
return self::_registryGetAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return Effect
|
||||
*/
|
||||
public static function fromString(string $name) : Effect{
|
||||
$result = self::_registryFromString($name);
|
||||
assert($result instanceof Effect);
|
||||
|
@@ -52,10 +52,6 @@ class ExperienceOrb extends Entity{
|
||||
/**
|
||||
* Returns the largest size of normal XP orb that will be spawned for the specified amount of XP. Used to split XP
|
||||
* up into multiple orbs when an amount of XP is dropped.
|
||||
*
|
||||
* @param int $amount
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getMaxOrbSize(int $amount) : int{
|
||||
foreach(self::ORB_SPLIT_SIZES as $split){
|
||||
@@ -70,8 +66,6 @@ class ExperienceOrb extends Entity{
|
||||
/**
|
||||
* Splits the specified amount of XP into an array of acceptable XP orb sizes.
|
||||
*
|
||||
* @param int $amount
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public static function splitIntoOrbSizes(int $amount) : array{
|
||||
|
@@ -154,9 +154,6 @@ class ItemEntity extends Entity{
|
||||
return $nbt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getItem() : Item{
|
||||
return $this->item;
|
||||
}
|
||||
@@ -169,32 +166,22 @@ class ItemEntity extends Entity{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPickupDelay() : int{
|
||||
return $this->pickupDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $delay
|
||||
*/
|
||||
public function setPickupDelay(int $delay) : void{
|
||||
$this->pickupDelay = $delay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of ticks left before this item will despawn. If -1, the item will never despawn.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDespawnDelay() : int{
|
||||
return $this->despawnDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $despawnDelay
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setDespawnDelay(int $despawnDelay) : void{
|
||||
@@ -204,30 +191,18 @@ class ItemEntity extends Entity{
|
||||
$this->despawnDelay = $despawnDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOwner() : string{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
*/
|
||||
public function setOwner(string $owner) : void{
|
||||
$this->owner = $owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getThrower() : string{
|
||||
return $this->thrower;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $thrower
|
||||
*/
|
||||
public function setThrower(string $thrower) : void{
|
||||
$this->thrower = $thrower;
|
||||
}
|
||||
|
@@ -164,7 +164,6 @@ class Painting extends Entity{
|
||||
|
||||
/**
|
||||
* Returns the painting motive (which image is displayed on the painting)
|
||||
* @return PaintingMotive
|
||||
*/
|
||||
public function getMotive() : PaintingMotive{
|
||||
return PaintingMotive::getMotiveByName($this->motive);
|
||||
@@ -176,11 +175,6 @@ class Painting extends Entity{
|
||||
|
||||
/**
|
||||
* Returns the bounding-box a painting with the specified motive would have at the given position and direction.
|
||||
*
|
||||
* @param int $facing
|
||||
* @param PaintingMotive $motive
|
||||
*
|
||||
* @return AxisAlignedBB
|
||||
*/
|
||||
private static function getPaintingBB(int $facing, PaintingMotive $motive) : AxisAlignedBB{
|
||||
$width = $motive->getWidth();
|
||||
@@ -199,14 +193,6 @@ class Painting extends Entity{
|
||||
|
||||
/**
|
||||
* Returns whether a painting with the specified motive can be placed at the given position.
|
||||
*
|
||||
* @param World $world
|
||||
* @param Vector3 $blockIn
|
||||
* @param int $facing
|
||||
* @param bool $checkOverlap
|
||||
* @param PaintingMotive $motive
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function canFit(World $world, Vector3 $blockIn, int $facing, bool $checkOverlap, PaintingMotive $motive) : bool{
|
||||
$width = $motive->getWidth();
|
||||
|
@@ -64,18 +64,10 @@ class PaintingMotive{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PaintingMotive $motive
|
||||
*/
|
||||
public static function registerMotive(PaintingMotive $motive) : void{
|
||||
self::$motives[$motive->getName()] = $motive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return PaintingMotive|null
|
||||
*/
|
||||
public static function getMotiveByName(string $name) : ?PaintingMotive{
|
||||
return self::$motives[$name] ?? null;
|
||||
}
|
||||
@@ -101,23 +93,14 @@ class PaintingMotive{
|
||||
$this->height = $height;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() : string{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getWidth() : int{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getHeight() : int{
|
||||
return $this->height;
|
||||
}
|
||||
|
@@ -106,16 +106,10 @@ class Arrow extends Projectile{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getPunchKnockback() : float{
|
||||
return $this->punchKnockback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $punchKnockback
|
||||
*/
|
||||
public function setPunchKnockback(float $punchKnockback) : void{
|
||||
$this->punchKnockback = $punchKnockback;
|
||||
}
|
||||
@@ -161,16 +155,10 @@ class Arrow extends Projectile{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPickupMode() : int{
|
||||
return $this->pickupMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $pickupMode
|
||||
*/
|
||||
public function setPickupMode(int $pickupMode) : void{
|
||||
$this->pickupMode = $pickupMode;
|
||||
}
|
||||
|
@@ -116,8 +116,6 @@ abstract class Projectile extends Entity{
|
||||
/**
|
||||
* Returns the base damage applied on collision. This is multiplied by the projectile's speed to give a result
|
||||
* damage.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getBaseDamage() : float{
|
||||
return $this->damage;
|
||||
@@ -125,8 +123,6 @@ abstract class Projectile extends Entity{
|
||||
|
||||
/**
|
||||
* Sets the base amount of damage applied by the projectile.
|
||||
*
|
||||
* @param float $damage
|
||||
*/
|
||||
public function setBaseDamage(float $damage) : void{
|
||||
$this->damage = $damage;
|
||||
@@ -134,7 +130,6 @@ abstract class Projectile extends Entity{
|
||||
|
||||
/**
|
||||
* Returns the amount of damage this projectile will deal to the entity it hits.
|
||||
* @return int
|
||||
*/
|
||||
public function getResultDamage() : int{
|
||||
return (int) ceil($this->motion->length() * $this->damage);
|
||||
@@ -275,10 +270,6 @@ abstract class Projectile extends Entity{
|
||||
* This can be overridden by other projectiles to allow altering the blocks which are collided with (for example
|
||||
* some projectiles collide with any non-air block).
|
||||
*
|
||||
* @param Block $block
|
||||
* @param Vector3 $start
|
||||
* @param Vector3 $end
|
||||
*
|
||||
* @return RayTraceResult|null the result of the ray trace if successful, or null if no interception is found.
|
||||
*/
|
||||
protected function calculateInterceptWithBlock(Block $block, Vector3 $start, Vector3 $end) : ?RayTraceResult{
|
||||
@@ -288,8 +279,6 @@ abstract class Projectile extends Entity{
|
||||
/**
|
||||
* Called when the projectile hits something. Override this to perform non-target-specific effects when the
|
||||
* projectile hits something.
|
||||
*
|
||||
* @param ProjectileHitEvent $event
|
||||
*/
|
||||
protected function onHit(ProjectileHitEvent $event) : void{
|
||||
|
||||
@@ -297,9 +286,6 @@ abstract class Projectile extends Entity{
|
||||
|
||||
/**
|
||||
* Called when the projectile collides with an Entity.
|
||||
*
|
||||
* @param Entity $entityHit
|
||||
* @param RayTraceResult $hitResult
|
||||
*/
|
||||
protected function onHitEntity(Entity $entityHit, RayTraceResult $hitResult) : void{
|
||||
$damage = $this->getResultDamage();
|
||||
@@ -327,9 +313,6 @@ abstract class Projectile extends Entity{
|
||||
|
||||
/**
|
||||
* Called when the projectile collides with a Block.
|
||||
*
|
||||
* @param Block $blockHit
|
||||
* @param RayTraceResult $hitResult
|
||||
*/
|
||||
protected function onHitBlock(Block $blockHit, RayTraceResult $hitResult) : void{
|
||||
$this->blockHit = clone $blockHit;
|
||||
|
@@ -142,22 +142,17 @@ class SplashPotion extends Throwable{
|
||||
|
||||
/**
|
||||
* Returns the meta value of the potion item that this splash potion corresponds to. This decides what effects will be applied to the entity when it collides with its target.
|
||||
* @return int
|
||||
*/
|
||||
public function getPotionId() : int{
|
||||
return $this->potionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
public function setPotionId(int $id) : void{
|
||||
$this->potionId = $id; //TODO: validation
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this splash potion will create an area-effect cloud when it lands.
|
||||
* @return bool
|
||||
*/
|
||||
public function willLinger() : bool{
|
||||
return $this->linger;
|
||||
@@ -165,8 +160,6 @@ class SplashPotion extends Throwable{
|
||||
|
||||
/**
|
||||
* Sets whether this splash potion will create an area-effect-cloud when it lands.
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setLinger(bool $value = true) : void{
|
||||
$this->linger = $value;
|
||||
|
@@ -30,10 +30,6 @@ abstract class ExperienceUtils{
|
||||
|
||||
/**
|
||||
* Calculates and returns the amount of XP needed to get from level 0 to level $level
|
||||
*
|
||||
* @param int $level
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getXpToReachLevel(int $level) : int{
|
||||
if($level <= 16){
|
||||
@@ -47,10 +43,6 @@ abstract class ExperienceUtils{
|
||||
|
||||
/**
|
||||
* Returns the amount of XP needed to reach $level + 1.
|
||||
*
|
||||
* @param int $level
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getXpToCompleteLevel(int $level) : int{
|
||||
if($level <= 15){
|
||||
@@ -65,10 +57,6 @@ abstract class ExperienceUtils{
|
||||
/**
|
||||
* Calculates and returns the number of XP levels the specified amount of XP points are worth.
|
||||
* This returns a floating-point number, the decimal part being the progress through the resulting level.
|
||||
*
|
||||
* @param int $xp
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function getLevelFromXp(int $xp) : float{
|
||||
if($xp <= self::getXpToReachLevel(16)){
|
||||
|
Reference in New Issue
Block a user