mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
phpdoc armageddon for master, pass 1
This commit is contained in:
parent
4bae3baa74
commit
67bcc1c0fb
@ -174,33 +174,20 @@ class MemoryManager{
|
||||
gc_enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isLowMemory() : bool{
|
||||
return $this->lowMemory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getGlobalMemoryLimit() : int{
|
||||
return $this->globalMemoryLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function canUseChunkCache() : bool{
|
||||
return !$this->lowMemory or !$this->lowMemDisableChunkCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the allowed chunk radius based on the current memory usage.
|
||||
*
|
||||
* @param int $distance
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getViewDistance(int $distance) : int{
|
||||
return ($this->lowMemory and $this->lowMemChunkRadiusOverride > 0) ? (int) min($this->lowMemChunkRadiusOverride, $distance) : $distance;
|
||||
@ -208,11 +195,6 @@ class MemoryManager{
|
||||
|
||||
/**
|
||||
* Triggers garbage collection and cache cleanup to try and free memory.
|
||||
*
|
||||
* @param int $memory
|
||||
* @param int $limit
|
||||
* @param bool $global
|
||||
* @param int $triggerCount
|
||||
*/
|
||||
public function trigger(int $memory, int $limit, bool $global = false, int $triggerCount = 0) : void{
|
||||
$this->logger->debug(sprintf("%sLow memory triggered, limit %gMB, using %gMB",
|
||||
@ -280,9 +262,6 @@ class MemoryManager{
|
||||
Timings::$memoryManagerTimer->stopTiming();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function triggerGarbageCollector() : int{
|
||||
Timings::$garbageCollectorTimer->startTiming();
|
||||
|
||||
@ -305,10 +284,6 @@ class MemoryManager{
|
||||
|
||||
/**
|
||||
* Dumps the server memory into the specified output folder.
|
||||
*
|
||||
* @param string $outputFolder
|
||||
* @param int $maxNesting
|
||||
* @param int $maxStringSize
|
||||
*/
|
||||
public function dumpServerMemory(string $outputFolder, int $maxNesting, int $maxStringSize) : void{
|
||||
$logger = new \PrefixedLogger($this->server->getLogger(), "Memory Dump");
|
||||
@ -327,10 +302,6 @@ class MemoryManager{
|
||||
* Static memory dumper accessible from any thread.
|
||||
*
|
||||
* @param mixed $startingObject
|
||||
* @param string $outputFolder
|
||||
* @param int $maxNesting
|
||||
* @param int $maxStringSize
|
||||
* @param \Logger $logger
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
@ -488,9 +459,6 @@ class MemoryManager{
|
||||
* @param mixed $data reference parameter
|
||||
* @param object[] $objects reference parameter
|
||||
* @param int[] $refCounts reference parameter
|
||||
* @param int $recursion
|
||||
* @param int $maxNesting
|
||||
* @param int $maxStringSize
|
||||
*/
|
||||
private static function continueDump($from, &$data, array &$objects, array &$refCounts, int $recursion, int $maxNesting, int $maxStringSize) : void{
|
||||
if($maxNesting <= 0){
|
||||
|
214
src/Server.php
214
src/Server.php
@ -284,72 +284,42 @@ class Server{
|
||||
/** @var Player[] */
|
||||
private $playerList = [];
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() : string{
|
||||
return \pocketmine\NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isRunning() : bool{
|
||||
return $this->isRunning;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPocketMineVersion() : string{
|
||||
return \pocketmine\VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion() : string{
|
||||
return ProtocolInfo::MINECRAFT_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getApiVersion() : string{
|
||||
return \pocketmine\BASE_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFilePath() : string{
|
||||
return \pocketmine\PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getResourcePath() : string{
|
||||
return \pocketmine\RESOURCE_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDataPath() : string{
|
||||
return $this->dataPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPluginPath() : string{
|
||||
return $this->pluginPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxPlayers() : int{
|
||||
return $this->maxPlayers;
|
||||
}
|
||||
@ -357,8 +327,6 @@ class Server{
|
||||
/**
|
||||
* Returns whether the server requires that players be authenticated to Xbox Live. If true, connecting players who
|
||||
* are not logged into Xbox Live will be disconnected.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getOnlineMode() : bool{
|
||||
return $this->onlineMode;
|
||||
@ -366,40 +334,26 @@ class Server{
|
||||
|
||||
/**
|
||||
* Alias of {@link #getOnlineMode()}.
|
||||
* @return bool
|
||||
*/
|
||||
public function requiresAuthentication() : bool{
|
||||
return $this->getOnlineMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPort() : int{
|
||||
return $this->getConfigInt("server-port", 19132);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getViewDistance() : int{
|
||||
return max(2, $this->getConfigInt("view-distance", 8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view distance up to the currently-allowed limit.
|
||||
*
|
||||
* @param int $distance
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAllowedViewDistance(int $distance) : int{
|
||||
return max(2, min($distance, $this->memoryManager->getViewDistance($this->getViewDistance())));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIp() : string{
|
||||
$str = $this->getConfigString("server-ip");
|
||||
return $str !== "" ? $str : "0.0.0.0";
|
||||
@ -412,45 +366,29 @@ class Server{
|
||||
return $this->serverID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return GameMode
|
||||
*/
|
||||
public function getGamemode() : GameMode{
|
||||
return GameMode::fromMagicNumber($this->getConfigInt("gamemode", 0) & 0b11);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getForceGamemode() : bool{
|
||||
return $this->getConfigBool("force-gamemode", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Server global difficulty. Note that this may be overridden in individual worlds.
|
||||
* @return int
|
||||
*/
|
||||
public function getDifficulty() : int{
|
||||
return $this->getConfigInt("difficulty", World::DIFFICULTY_NORMAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasWhitelist() : bool{
|
||||
return $this->getConfigBool("white-list", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHardcore() : bool{
|
||||
return $this->getConfigBool("hardcore", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMotd() : string{
|
||||
return $this->getConfigString("motd", \pocketmine\NAME . " Server");
|
||||
}
|
||||
@ -490,16 +428,10 @@ class Server{
|
||||
return $this->craftingManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ResourcePackManager
|
||||
*/
|
||||
public function getResourcePackManager() : ResourcePackManager{
|
||||
return $this->resourceManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return WorldManager
|
||||
*/
|
||||
public function getWorldManager() : WorldManager{
|
||||
return $this->worldManager;
|
||||
}
|
||||
@ -508,17 +440,12 @@ class Server{
|
||||
return $this->asyncPool;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTick() : int{
|
||||
return $this->tickCounter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last server TPS measure
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getTicksPerSecond() : float{
|
||||
return round($this->currentTPS, 2);
|
||||
@ -526,8 +453,6 @@ class Server{
|
||||
|
||||
/**
|
||||
* Returns the last server TPS average measure
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getTicksPerSecondAverage() : float{
|
||||
return round(array_sum($this->tickAverage) / count($this->tickAverage), 2);
|
||||
@ -535,8 +460,6 @@ class Server{
|
||||
|
||||
/**
|
||||
* Returns the TPS usage/load in %
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getTickUsage() : float{
|
||||
return round($this->currentUse * 100, 2);
|
||||
@ -544,16 +467,11 @@ class Server{
|
||||
|
||||
/**
|
||||
* Returns the TPS usage/load average in %
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getTickUsageAverage() : float{
|
||||
return round((array_sum($this->useAverage) / count($this->useAverage)) * 100, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getStartTime() : float{
|
||||
return $this->startTime;
|
||||
}
|
||||
@ -577,8 +495,6 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return OfflinePlayer|Player
|
||||
*/
|
||||
public function getOfflinePlayer(string $name){
|
||||
@ -594,21 +510,12 @@ class Server{
|
||||
|
||||
/**
|
||||
* Returns whether the server has stored any saved data for this player.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOfflinePlayerData(string $name) : bool{
|
||||
$name = strtolower($name);
|
||||
return file_exists($this->getDataPath() . "players/$name.dat");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return CompoundTag|null
|
||||
*/
|
||||
public function getOfflinePlayerData(string $name) : ?CompoundTag{
|
||||
$name = strtolower($name);
|
||||
$path = $this->getDataPath() . "players/";
|
||||
@ -624,10 +531,6 @@ class Server{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param CompoundTag $nbtTag
|
||||
*/
|
||||
public function saveOfflinePlayerData(string $name, CompoundTag $nbtTag) : void{
|
||||
$ev = new PlayerDataSaveEvent($nbtTag, $name);
|
||||
$ev->setCancelled(!$this->shouldSavePlayerData());
|
||||
@ -650,10 +553,6 @@ class Server{
|
||||
* The closest match will be returned, or null if there are no online matches.
|
||||
*
|
||||
* @see Server::getPlayerExact()
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Player|null
|
||||
*/
|
||||
public function getPlayer(string $name) : ?Player{
|
||||
$found = null;
|
||||
@ -677,10 +576,6 @@ class Server{
|
||||
|
||||
/**
|
||||
* Returns an online player with the given name (case insensitive), or null if not found.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Player|null
|
||||
*/
|
||||
public function getPlayerExact(string $name) : ?Player{
|
||||
$name = strtolower($name);
|
||||
@ -697,8 +592,6 @@ class Server{
|
||||
* Returns a list of online players whose names contain with the given string (case insensitive).
|
||||
* If an exact match is found, only that match is returned.
|
||||
*
|
||||
* @param string $partialName
|
||||
*
|
||||
* @return Player[]
|
||||
*/
|
||||
public function matchPlayer(string $partialName) : array{
|
||||
@ -718,10 +611,6 @@ class Server{
|
||||
|
||||
/**
|
||||
* Returns the player online with the specified raw UUID, or null if not found
|
||||
*
|
||||
* @param string $rawUUID
|
||||
*
|
||||
* @return null|Player
|
||||
*/
|
||||
public function getPlayerByRawUUID(string $rawUUID) : ?Player{
|
||||
return $this->playerList[$rawUUID] ?? null;
|
||||
@ -729,17 +618,12 @@ class Server{
|
||||
|
||||
/**
|
||||
* Returns the player online with a UUID equivalent to the specified UUID object, or null if not found
|
||||
*
|
||||
* @param UUID $uuid
|
||||
*
|
||||
* @return null|Player
|
||||
*/
|
||||
public function getPlayerByUUID(UUID $uuid) : ?Player{
|
||||
return $this->getPlayerByRawUUID($uuid->toBinary());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $variable
|
||||
* @param mixed $defaultValue
|
||||
*
|
||||
* @return mixed
|
||||
@ -757,12 +641,6 @@ class Server{
|
||||
return $this->propertyCache[$variable] ?? $defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $variable
|
||||
* @param string $defaultValue
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getConfigString(string $variable, string $defaultValue = "") : string{
|
||||
$v = getopt("", ["$variable::"]);
|
||||
if(isset($v[$variable])){
|
||||
@ -772,20 +650,10 @@ class Server{
|
||||
return $this->properties->exists($variable) ? (string) $this->properties->get($variable) : $defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $variable
|
||||
* @param string $value
|
||||
*/
|
||||
public function setConfigString(string $variable, string $value) : void{
|
||||
$this->properties->set($variable, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $variable
|
||||
* @param int $defaultValue
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getConfigInt(string $variable, int $defaultValue = 0) : int{
|
||||
$v = getopt("", ["$variable::"]);
|
||||
if(isset($v[$variable])){
|
||||
@ -795,20 +663,10 @@ class Server{
|
||||
return $this->properties->exists($variable) ? (int) $this->properties->get($variable) : $defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $variable
|
||||
* @param int $value
|
||||
*/
|
||||
public function setConfigInt(string $variable, int $value) : void{
|
||||
$this->properties->set($variable, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $variable
|
||||
* @param bool $defaultValue
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getConfigBool(string $variable, bool $defaultValue = false) : bool{
|
||||
$v = getopt("", ["$variable::"]);
|
||||
if(isset($v[$variable])){
|
||||
@ -831,17 +689,11 @@ class Server{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $variable
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setConfigBool(string $variable, bool $value) : void{
|
||||
$this->properties->set($variable, $value ? "1" : "0");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return PluginIdentifiableCommand|null
|
||||
*/
|
||||
public function getPluginCommand(string $name){
|
||||
@ -866,9 +718,6 @@ class Server{
|
||||
return $this->banByIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function addOp(string $name) : void{
|
||||
$this->operators->set(strtolower($name), true);
|
||||
|
||||
@ -878,9 +727,6 @@ class Server{
|
||||
$this->operators->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function removeOp(string $name) : void{
|
||||
$this->operators->remove(strtolower($name));
|
||||
|
||||
@ -890,36 +736,20 @@ class Server{
|
||||
$this->operators->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function addWhitelist(string $name) : void{
|
||||
$this->whitelist->set(strtolower($name), true);
|
||||
$this->whitelist->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function removeWhitelist(string $name) : void{
|
||||
$this->whitelist->remove(strtolower($name));
|
||||
$this->whitelist->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isWhitelisted(string $name) : bool{
|
||||
return !$this->hasWhitelist() or $this->operators->exists($name, true) or $this->whitelist->exists($name, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isOp(string $name) : bool{
|
||||
return $this->operators->exists($name, true);
|
||||
}
|
||||
@ -960,9 +790,6 @@ class Server{
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Server
|
||||
*/
|
||||
public static function getInstance() : Server{
|
||||
if(self::$instance === null){
|
||||
throw new \RuntimeException("Attempt to retrieve Server instance outside server thread");
|
||||
@ -970,12 +797,6 @@ class Server{
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DynamicClassLoader $autoloader
|
||||
* @param \AttachableThreadedLogger $logger
|
||||
* @param string $dataPath
|
||||
* @param string $pluginPath
|
||||
*/
|
||||
public function __construct(\DynamicClassLoader $autoloader, \AttachableThreadedLogger $logger, string $dataPath, string $pluginPath){
|
||||
if(self::$instance !== null){
|
||||
throw new \InvalidStateException("Only one server instance can exist at once");
|
||||
@ -1316,8 +1137,6 @@ class Server{
|
||||
/**
|
||||
* @param TextContainer|string $message
|
||||
* @param CommandSender[] $recipients
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function broadcastMessage($message, ?array $recipients = null) : int{
|
||||
if(!is_array($recipients)){
|
||||
@ -1343,10 +1162,7 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tip
|
||||
* @param Player[] $recipients
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function broadcastTip(string $tip, ?array $recipients = null) : int{
|
||||
$recipients = $recipients ?? $this->selectPermittedPlayers(self::BROADCAST_CHANNEL_USERS);
|
||||
@ -1359,10 +1175,7 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $popup
|
||||
* @param Player[] $recipients
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function broadcastPopup(string $popup, ?array $recipients = null) : int{
|
||||
$recipients = $recipients ?? $this->selectPermittedPlayers(self::BROADCAST_CHANNEL_USERS);
|
||||
@ -1375,14 +1188,10 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
* @param string $subtitle
|
||||
* @param int $fadeIn Duration in ticks for fade-in. If -1 is given, client-sided defaults will be used.
|
||||
* @param int $stay Duration in ticks to stay on screen for
|
||||
* @param int $fadeOut Duration in ticks for fade-out.
|
||||
* @param Player[]|null $recipients
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function broadcastTitle(string $title, string $subtitle = "", int $fadeIn = -1, int $stay = -1, int $fadeOut = -1, ?array $recipients = null) : int{
|
||||
$recipients = $recipients ?? $this->selectPermittedPlayers(self::BROADCAST_CHANNEL_USERS);
|
||||
@ -1396,9 +1205,6 @@ class Server{
|
||||
|
||||
/**
|
||||
* @param TextContainer|string $message
|
||||
* @param string $permissions
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function broadcast($message, string $permissions) : int{
|
||||
/** @var CommandSender[] $recipients */
|
||||
@ -1421,8 +1227,6 @@ class Server{
|
||||
/**
|
||||
* @param Player[] $players
|
||||
* @param ClientboundPacket[] $packets
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function broadcastPackets(array $players, array $packets) : bool{
|
||||
if(count($packets) === 0){
|
||||
@ -1467,11 +1271,6 @@ class Server{
|
||||
|
||||
/**
|
||||
* Broadcasts a list of packets in a batch to a list of players
|
||||
*
|
||||
* @param PacketBatch $stream
|
||||
* @param bool $forceSync
|
||||
*
|
||||
* @return CompressBatchPromise
|
||||
*/
|
||||
public function prepareBatch(PacketBatch $stream, bool $forceSync = false) : CompressBatchPromise{
|
||||
try{
|
||||
@ -1498,9 +1297,6 @@ class Server{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PluginLoadOrder $type
|
||||
*/
|
||||
public function enablePlugins(PluginLoadOrder $type) : void{
|
||||
foreach($this->pluginManager->getPlugins() as $plugin){
|
||||
if(!$plugin->isEnabled() and $plugin->getDescription()->getOrder()->equals($type)){
|
||||
@ -1516,12 +1312,6 @@ class Server{
|
||||
|
||||
/**
|
||||
* Executes a command from a CommandSender
|
||||
*
|
||||
* @param CommandSender $sender
|
||||
* @param string $commandLine
|
||||
* @param bool $internal
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatchCommand(CommandSender $sender, string $commandLine, bool $internal = false) : bool{
|
||||
if(!$internal){
|
||||
@ -1627,7 +1417,6 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Throwable $e
|
||||
* @param array|null $trace
|
||||
*/
|
||||
public function exceptionHandler(\Throwable $e, $trace = null) : void{
|
||||
@ -1799,9 +1588,6 @@ class Server{
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isLanguageForced() : bool{
|
||||
return $this->forceLanguage;
|
||||
}
|
||||
|
@ -120,7 +120,6 @@ class Banner extends Transparent{
|
||||
|
||||
/**
|
||||
* TODO: interface method? this is only the BASE colour...
|
||||
* @return DyeColor
|
||||
*/
|
||||
public function getColor() : DyeColor{
|
||||
return $this->baseColor;
|
||||
|
@ -124,10 +124,6 @@ abstract class BaseRail extends Flowable{
|
||||
/**
|
||||
* Returns a meta value for the rail with the given connections.
|
||||
*
|
||||
* @param array $connections
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws \InvalidArgumentException if no state matches the given connections
|
||||
*/
|
||||
protected function getMetaForState(array $connections) : int{
|
||||
@ -137,8 +133,6 @@ abstract class BaseRail extends Flowable{
|
||||
/**
|
||||
* Returns the connection directions of this rail (depending on the current block state)
|
||||
*
|
||||
* @param int $meta
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
abstract protected function getConnectionsFromMeta(int $meta) : ?array;
|
||||
|
@ -99,9 +99,6 @@ class Bed extends Transparent{
|
||||
return $this->head;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isOccupied() : bool{
|
||||
return $this->occupied;
|
||||
}
|
||||
@ -116,16 +113,10 @@ class Bed extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
private function getOtherHalfSide() : int{
|
||||
return $this->head ? Facing::opposite($this->facing) : $this->facing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Bed|null
|
||||
*/
|
||||
public function getOtherHalf() : ?Bed{
|
||||
$other = $this->getSide($this->getOtherHalfSide());
|
||||
if($other instanceof Bed and $other->head !== $this->head and $other->facing === $this->facing){
|
||||
|
@ -68,9 +68,7 @@ class Block{
|
||||
protected $collisionBoxes = null;
|
||||
|
||||
/**
|
||||
* @param BlockIdentifier $idInfo
|
||||
* @param string $name English name of the block type (TODO: implement translations)
|
||||
* @param BlockBreakInfo $breakInfo
|
||||
*/
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
|
||||
if(($idInfo->getVariant() & $this->getStateBitmask()) !== 0){
|
||||
@ -90,23 +88,16 @@ class Block{
|
||||
return $this->idInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() : string{
|
||||
return $this->fallbackName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId() : int{
|
||||
return $this->idInfo->getBlockId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @return int
|
||||
*/
|
||||
public function getFullId() : int{
|
||||
return ($this->getId() << 4) | $this->getMeta();
|
||||
@ -118,26 +109,19 @@ class Block{
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @return int
|
||||
*/
|
||||
public function getRuntimeId() : int{
|
||||
return RuntimeBlockMapping::toStaticRuntimeId($this->getId(), $this->getMeta());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMeta() : int{
|
||||
$stateMeta = $this->writeStateToMeta();
|
||||
assert(($stateMeta & ~$this->getStateBitmask()) === 0);
|
||||
return $this->idInfo->getVariant() | $stateMeta;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a bitmask used to extract state bits from block metadata.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStateBitmask() : int{
|
||||
return 0;
|
||||
@ -148,9 +132,6 @@ class Block{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param int $stateMeta
|
||||
*
|
||||
* @throws InvalidBlockStateException
|
||||
*/
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
@ -191,10 +172,6 @@ class Block{
|
||||
*
|
||||
* Note: This ignores additional IDs used to represent additional states. This means that, for example, a lit
|
||||
* furnace and unlit furnace are considered the same type.
|
||||
*
|
||||
* @param Block $other
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSameType(Block $other) : bool{
|
||||
return $this->idInfo->getBlockId() === $other->idInfo->getBlockId() and $this->idInfo->getVariant() === $other->idInfo->getVariant();
|
||||
@ -202,10 +179,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Returns whether the given block has the same type and properties as this block.
|
||||
*
|
||||
* @param Block $other
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSameState(Block $other) : bool{
|
||||
return $this->isSameType($other) and $this->writeStateToMeta() === $other->writeStateToMeta();
|
||||
@ -213,15 +186,11 @@ class Block{
|
||||
|
||||
/**
|
||||
* AKA: Block->isPlaceable
|
||||
* @return bool
|
||||
*/
|
||||
public function canBePlaced() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function canBeReplaced() : bool{
|
||||
return false;
|
||||
}
|
||||
@ -232,16 +201,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Places the Block, using block space and block target, and side. Returns if the block has been placed.
|
||||
*
|
||||
* @param BlockTransaction $tx
|
||||
* @param Item $item
|
||||
* @param Block $blockReplace
|
||||
* @param Block $blockClicked
|
||||
* @param int $face
|
||||
* @param Vector3 $clickVector
|
||||
* @param Player|null $player
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$tx->addBlock($blockReplace->pos, $this);
|
||||
@ -254,8 +213,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Returns an object containing information about the destruction requirements of this block.
|
||||
*
|
||||
* @return BlockBreakInfo
|
||||
*/
|
||||
public function getBreakInfo() : BlockBreakInfo{
|
||||
return $this->breakInfo;
|
||||
@ -263,11 +220,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Do the actions needed so the block is broken with the Item
|
||||
*
|
||||
* @param Item $item
|
||||
* @param Player|null $player
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function onBreak(Item $item, ?Player $player = null) : bool{
|
||||
if(($t = $this->pos->getWorld()->getTile($this->pos)) !== null){
|
||||
@ -286,8 +238,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Returns whether random block updates will be done on this block.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function ticksRandomly() : bool{
|
||||
return false;
|
||||
@ -310,13 +260,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Do actions when interacted by Item. Returns if it has done anything
|
||||
*
|
||||
* @param Item $item
|
||||
* @param int $face
|
||||
* @param Vector3 $clickVector
|
||||
* @param Player|null $player
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
return false;
|
||||
@ -326,19 +269,12 @@ class Block{
|
||||
* Called when this block is attacked (left-clicked). This is called when a player left-clicks the block to try and
|
||||
* start to break it in survival mode.
|
||||
*
|
||||
* @param Item $item
|
||||
* @param int $face
|
||||
* @param Player|null $player
|
||||
*
|
||||
* @return bool if an action took place, prevents starting to break the block if true.
|
||||
*/
|
||||
public function onAttack(Item $item, int $face, ?Player $player = null) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getFrictionFactor() : float{
|
||||
return 0.6;
|
||||
}
|
||||
@ -366,16 +302,11 @@ class Block{
|
||||
* Examples of this behaviour include leaves and cobwebs.
|
||||
*
|
||||
* Light-diffusing blocks are included by the heightmap.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function diffusesSkyLight() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isTransparent() : bool{
|
||||
return false;
|
||||
}
|
||||
@ -386,7 +317,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* AKA: Block->isFlowable
|
||||
* @return bool
|
||||
*/
|
||||
public function canBeFlowedInto() : bool{
|
||||
return false;
|
||||
@ -398,7 +328,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Returns whether entities can climb up this block.
|
||||
* @return bool
|
||||
*/
|
||||
public function canClimb() : bool{
|
||||
return false;
|
||||
@ -415,11 +344,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @param World $world
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*/
|
||||
final public function position(World $world, int $x, int $y, int $z) : void{
|
||||
$this->pos->x = $x;
|
||||
@ -431,8 +355,6 @@ class Block{
|
||||
/**
|
||||
* Returns an array of Item objects to be dropped
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
public function getDrops(Item $item) : array{
|
||||
@ -450,8 +372,6 @@ class Block{
|
||||
/**
|
||||
* Returns an array of Items to be dropped when the block is broken using the correct tool type.
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
@ -461,8 +381,6 @@ class Block{
|
||||
/**
|
||||
* Returns an array of Items to be dropped when the block is broken using a compatible Silk Touch-enchanted tool.
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
public function getSilkTouchDrops(Item $item) : array{
|
||||
@ -471,10 +389,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Returns how much XP will be dropped by breaking this block with the given item.
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getXpDropForTool(Item $item) : int{
|
||||
if($item->hasEnchantment(Enchantment::SILK_TOUCH()) or !$this->breakInfo->isToolCompatible($item)){
|
||||
@ -486,8 +400,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Returns how much XP this block will drop when broken with an appropriate tool.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getXpDropAmount() : int{
|
||||
return 0;
|
||||
@ -496,8 +408,6 @@ class Block{
|
||||
/**
|
||||
* Returns whether Silk Touch enchanted tools will cause this block to drop as itself. Since most blocks drop
|
||||
* themselves anyway, this is implicitly true.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return true;
|
||||
@ -505,10 +415,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Returns the item that players will equip when middle-clicking on this block.
|
||||
*
|
||||
* @param bool $addUserData
|
||||
*
|
||||
* @return Item
|
||||
*/
|
||||
public function getPickedItem(bool $addUserData = false) : Item{
|
||||
$item = $this->asItem();
|
||||
@ -527,7 +433,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Returns the time in ticks which the block will fuel a furnace for.
|
||||
* @return int
|
||||
*/
|
||||
public function getFuelTime() : int{
|
||||
return 0;
|
||||
@ -536,8 +441,6 @@ class Block{
|
||||
/**
|
||||
* Returns the chance that the block will catch fire from nearby fire sources. Higher values lead to faster catching
|
||||
* fire.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getFlameEncouragement() : int{
|
||||
return 0;
|
||||
@ -545,8 +448,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Returns the base flammability of this block. Higher values lead to the block burning away more quickly.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getFlammability() : int{
|
||||
return 0;
|
||||
@ -554,8 +455,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Returns whether fire lit on this block will burn indefinitely.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function burnsForever() : bool{
|
||||
return false;
|
||||
@ -563,8 +462,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Returns whether this block can catch fire.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isFlammable() : bool{
|
||||
return $this->getFlammability() > 0;
|
||||
@ -580,9 +477,6 @@ class Block{
|
||||
/**
|
||||
* Returns the Block on the side $side, works like Vector3::getSide()
|
||||
*
|
||||
* @param int $side
|
||||
* @param int $step
|
||||
*
|
||||
* @return Block
|
||||
*/
|
||||
public function getSide(int $side, int $step = 1){
|
||||
@ -641,10 +535,6 @@ class Block{
|
||||
|
||||
/**
|
||||
* Checks for collision against an AxisAlignedBB
|
||||
*
|
||||
* @param AxisAlignedBB $bb
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function collidesWithBB(AxisAlignedBB $bb) : bool{
|
||||
foreach($this->getCollisionBoxes() as $bb2){
|
||||
@ -659,8 +549,6 @@ class Block{
|
||||
/**
|
||||
* Called when an entity's bounding box clips inside this block's cell. Note that the entity may not be intersecting
|
||||
* with the collision box or bounding box.
|
||||
*
|
||||
* @param Entity $entity
|
||||
*/
|
||||
public function onEntityInside(Entity $entity) : void{
|
||||
|
||||
@ -687,21 +575,12 @@ class Block{
|
||||
return [AxisAlignedBB::one()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isFullCube() : bool{
|
||||
$bb = $this->getCollisionBoxes();
|
||||
|
||||
return count($bb) === 1 and $bb[0]->getAverageEdgeLength() >= 1; //TODO: average length 1 != cube
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Vector3 $pos1
|
||||
* @param Vector3 $pos2
|
||||
*
|
||||
* @return RayTraceResult|null
|
||||
*/
|
||||
public function calculateIntercept(Vector3 $pos1, Vector3 $pos2) : ?RayTraceResult{
|
||||
$bbs = $this->getCollisionBoxes();
|
||||
if(count($bbs) === 0){
|
||||
|
@ -38,9 +38,6 @@ class BlockBreakInfo{
|
||||
private $toolHarvestLevel;
|
||||
|
||||
/**
|
||||
* @param float $hardness
|
||||
* @param int $toolType
|
||||
* @param int $toolHarvestLevel
|
||||
* @param float|null $blastResistance default 5x hardness
|
||||
*/
|
||||
public function __construct(float $hardness, int $toolType = BlockToolType::NONE, int $toolHarvestLevel = 0, ?float $blastResistance = null){
|
||||
@ -60,8 +57,6 @@ class BlockBreakInfo{
|
||||
|
||||
/**
|
||||
* Returns a base value used to compute block break times.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getHardness() : float{
|
||||
return $this->hardness;
|
||||
@ -69,8 +64,6 @@ class BlockBreakInfo{
|
||||
|
||||
/**
|
||||
* Returns whether the block can be broken at all.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isBreakable() : bool{
|
||||
return $this->hardness >= 0;
|
||||
@ -78,8 +71,6 @@ class BlockBreakInfo{
|
||||
|
||||
/**
|
||||
* Returns whether this block can be instantly broken.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function breaksInstantly() : bool{
|
||||
return $this->hardness == 0.0;
|
||||
@ -87,16 +78,11 @@ class BlockBreakInfo{
|
||||
|
||||
/**
|
||||
* Returns the block's resistance to explosions. Usually 5x hardness.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getBlastResistance() : float{
|
||||
return $this->blastResistance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getToolType() : int{
|
||||
return $this->toolType;
|
||||
}
|
||||
@ -110,8 +96,6 @@ class BlockBreakInfo{
|
||||
* Otherwise, 1 should be returned if a tool is required, 0 if not.
|
||||
*
|
||||
* @see Item::getBlockToolHarvestLevel()
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getToolHarvestLevel() : int{
|
||||
return $this->toolHarvestLevel;
|
||||
@ -123,10 +107,6 @@ class BlockBreakInfo{
|
||||
*
|
||||
* In most cases this is also used to determine whether block drops should be created or not, except in some
|
||||
* special cases such as vines.
|
||||
*
|
||||
* @param Item $tool
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isToolCompatible(Item $tool) : bool{
|
||||
if($this->hardness < 0){
|
||||
@ -140,9 +120,6 @@ class BlockBreakInfo{
|
||||
/**
|
||||
* Returns the seconds that this block takes to be broken using an specific Item
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
* @return float
|
||||
* @throws \InvalidArgumentException if the item efficiency is not a positive number
|
||||
*/
|
||||
public function getBreakTime(Item $item) : float{
|
||||
|
@ -763,7 +763,6 @@ class BlockFactory{
|
||||
* NOTE: If you are registering a new block type, you will need to add it to the creative inventory yourself - it
|
||||
* will not automatically appear there.
|
||||
*
|
||||
* @param Block $block
|
||||
* @param bool $override Whether to override existing registrations
|
||||
*
|
||||
* @throws \RuntimeException if something attempted to override an already-registered block without specifying the
|
||||
@ -828,11 +827,6 @@ class BlockFactory{
|
||||
|
||||
/**
|
||||
* Returns a new Block instance with the specified ID, meta and position.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
*
|
||||
* @return Block
|
||||
*/
|
||||
public static function get(int $id, int $meta = 0) : Block{
|
||||
if($meta < 0 or $meta > 0xf){
|
||||
@ -863,11 +857,6 @@ class BlockFactory{
|
||||
|
||||
/**
|
||||
* Returns whether a specified block state is already registered in the block factory.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $meta
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isRegistered(int $id, int $meta = 0) : bool{
|
||||
$b = self::$fullList[($id << 4) | $meta];
|
||||
|
@ -41,9 +41,6 @@ class BlockIdentifier{
|
||||
$this->tileClass = $tileClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBlockId() : int{
|
||||
return $this->blockId;
|
||||
}
|
||||
@ -55,23 +52,14 @@ class BlockIdentifier{
|
||||
return [$this->blockId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getVariant() : int{
|
||||
return $this->variant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getItemId() : int{
|
||||
return $this->itemId ?? ($this->blockId > 255 ? 255 - $this->blockId : $this->blockId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTileClass() : ?string{
|
||||
return $this->tileClass;
|
||||
}
|
||||
|
@ -33,9 +33,6 @@ class BlockIdentifierFlattened extends BlockIdentifier{
|
||||
$this->secondId = $secondId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSecondId() : int{
|
||||
return $this->secondId;
|
||||
}
|
||||
|
@ -44,16 +44,10 @@ class ConcretePowder extends Opaque implements Fallable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Block
|
||||
*/
|
||||
public function tickFalling() : ?Block{
|
||||
return $this->checkAdjacentWater();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Block
|
||||
*/
|
||||
private function checkAdjacentWater() : ?Block{
|
||||
foreach(Facing::ALL as $i){
|
||||
if($i === Facing::DOWN){
|
||||
|
@ -70,8 +70,6 @@ class DaylightSensor extends Transparent{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $inverted
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setInverted(bool $inverted = true) : self{
|
||||
|
@ -64,7 +64,6 @@ class DoublePlant extends Flowable{
|
||||
|
||||
/**
|
||||
* Returns whether this double-plant has a corresponding other half.
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidHalfPlant() : bool{
|
||||
$other = $this->getSide($this->top ? Facing::DOWN : Facing::UP);
|
||||
|
@ -39,23 +39,14 @@ class Element extends Opaque{
|
||||
$this->symbol = $symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAtomicWeight() : int{
|
||||
return $this->atomicWeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getGroup() : int{
|
||||
return $this->group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSymbol() : string{
|
||||
return $this->symbol;
|
||||
}
|
||||
|
@ -77,16 +77,10 @@ class FlowerPot extends Flowable{
|
||||
$tile->setPlant($this->plant);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Block|null
|
||||
*/
|
||||
public function getPlant() : ?Block{
|
||||
return $this->plant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Block|null $plant
|
||||
*/
|
||||
public function setPlant(?Block $plant) : void{
|
||||
if($plant === null or $plant instanceof Air){
|
||||
$this->plant = null;
|
||||
|
@ -71,8 +71,6 @@ class Furnace extends Opaque{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $lit
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLit(bool $lit = true) : self{
|
||||
|
@ -86,30 +86,18 @@ class ItemFrame extends Flowable{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFacing() : int{
|
||||
return $this->facing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $facing
|
||||
*/
|
||||
public function setFacing(int $facing) : void{
|
||||
$this->facing = $facing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item|null
|
||||
*/
|
||||
public function getFramedItem() : ?Item{
|
||||
return $this->framedItem !== null ? clone $this->framedItem : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item|null $item
|
||||
*/
|
||||
public function setFramedItem(?Item $item) : void{
|
||||
if($item === null or $item->isNull()){
|
||||
$this->framedItem = null;
|
||||
@ -119,30 +107,18 @@ class ItemFrame extends Flowable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getItemRotation() : int{
|
||||
return $this->itemRotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $itemRotation
|
||||
*/
|
||||
public function setItemRotation(int $itemRotation) : void{
|
||||
$this->itemRotation = $itemRotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getItemDropChance() : float{
|
||||
return $this->itemDropChance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $itemDropChance
|
||||
*/
|
||||
public function setItemDropChance(float $itemDropChance) : void{
|
||||
$this->itemDropChance = $itemDropChance;
|
||||
}
|
||||
|
@ -143,8 +143,6 @@ abstract class Liquid extends Transparent{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $still
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStill(bool $still = true) : self{
|
||||
@ -247,8 +245,6 @@ abstract class Liquid extends Transparent{
|
||||
|
||||
/**
|
||||
* Returns how many liquid levels are lost per block flowed horizontally. Affects how far the liquid can flow.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getFlowDecayPerBlock() : int{
|
||||
return 1;
|
||||
|
@ -48,15 +48,11 @@ class NetherPortal extends Transparent{
|
||||
return 0b11;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAxis() : int{
|
||||
return $this->axis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $axis
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setAxis(int $axis) : void{
|
||||
|
@ -58,16 +58,10 @@ class Note extends Opaque{
|
||||
return 300;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPitch() : int{
|
||||
return $this->pitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $pitch
|
||||
*/
|
||||
public function setPitch(int $pitch) : void{
|
||||
if($pitch < self::MIN_PITCH or $pitch > self::MAX_PITCH){
|
||||
throw new \InvalidArgumentException("Pitch must be in range " . self::MIN_PITCH . " - " . self::MAX_PITCH);
|
||||
|
@ -87,7 +87,6 @@ class RedstoneComparator extends Flowable{
|
||||
|
||||
/**
|
||||
* TODO: ad hoc, move to interface
|
||||
* @return int
|
||||
*/
|
||||
public function getFacing() : int{
|
||||
return $this->facing;
|
||||
@ -95,50 +94,31 @@ class RedstoneComparator extends Flowable{
|
||||
|
||||
/**
|
||||
* TODO: ad hoc, move to interface
|
||||
* @param int $facing
|
||||
*/
|
||||
public function setFacing(int $facing) : void{
|
||||
$this->facing = $facing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSubtractMode() : bool{
|
||||
return $this->isSubtractMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $isSubtractMode
|
||||
*/
|
||||
public function setSubtractMode(bool $isSubtractMode) : void{
|
||||
$this->isSubtractMode = $isSubtractMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPowered() : bool{
|
||||
return $this->powered;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $powered
|
||||
*/
|
||||
public function setPowered(bool $powered) : void{
|
||||
$this->powered = $powered;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSignalStrength() : int{
|
||||
return $this->signalStrength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $signalStrength
|
||||
*/
|
||||
public function setSignalStrength(int $signalStrength) : void{
|
||||
$this->signalStrength = $signalStrength;
|
||||
}
|
||||
|
@ -48,8 +48,6 @@ class RedstoneLamp extends Opaque{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $lit
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLit(bool $lit = true) : self{
|
||||
|
@ -54,8 +54,6 @@ class RedstoneOre extends Opaque{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $lit
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLit(bool $lit = true) : self{
|
||||
|
@ -76,8 +76,6 @@ class RedstoneRepeater extends Flowable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $powered
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPowered(bool $powered = true) : self{
|
||||
|
@ -49,8 +49,6 @@ class RedstoneTorch extends Torch{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $lit
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLit(bool $lit = true) : self{
|
||||
|
@ -135,8 +135,6 @@ class Sign extends Transparent{
|
||||
|
||||
/**
|
||||
* Returns an object containing information about the sign text.
|
||||
*
|
||||
* @return SignText
|
||||
*/
|
||||
public function getText() : SignText{
|
||||
return $this->text;
|
||||
@ -145,9 +143,6 @@ class Sign extends Transparent{
|
||||
/**
|
||||
* Called by the player controller (network session) to update the sign text, firing events as appropriate.
|
||||
*
|
||||
* @param Player $author
|
||||
* @param SignText $text
|
||||
*
|
||||
* @return bool if the sign update was successful.
|
||||
* @throws \UnexpectedValueException if the text payload is too large
|
||||
*/
|
||||
|
@ -83,9 +83,6 @@ class Skull extends Flowable{
|
||||
$tile->setSkullType($this->skullType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SkullType
|
||||
*/
|
||||
public function getSkullType() : SkullType{
|
||||
return $this->skullType;
|
||||
}
|
||||
|
@ -72,16 +72,12 @@ class Slab extends Transparent{
|
||||
|
||||
/**
|
||||
* Returns the type of slab block.
|
||||
*
|
||||
* @return SlabType
|
||||
*/
|
||||
public function getSlabType() : SlabType{
|
||||
return $this->slabType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SlabType $slabType
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSlabType(SlabType $slabType) : self{
|
||||
|
@ -675,11 +675,6 @@ final class VanillaBlocks{
|
||||
self::_registryRegister($name, $block);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return Block
|
||||
*/
|
||||
public static function fromString(string $name) : Block{
|
||||
$result = self::_registryFromString($name);
|
||||
assert($result instanceof Block);
|
||||
|
@ -37,7 +37,6 @@ class Wood extends Opaque{
|
||||
|
||||
/**
|
||||
* TODO: this is ad hoc, but add an interface for this to all tree-related blocks
|
||||
* @return TreeType
|
||||
*/
|
||||
public function getTreeType() : TreeType{
|
||||
return $this->treeType;
|
||||
|
@ -98,8 +98,6 @@ class Banner extends Spawnable{
|
||||
|
||||
/**
|
||||
* Returns the color of the banner base.
|
||||
*
|
||||
* @return DyeColor
|
||||
*/
|
||||
public function getBaseColor() : DyeColor{
|
||||
return $this->baseColor;
|
||||
@ -107,8 +105,6 @@ class Banner extends Spawnable{
|
||||
|
||||
/**
|
||||
* Sets the color of the banner base.
|
||||
*
|
||||
* @param DyeColor $color
|
||||
*/
|
||||
public function setBaseColor(DyeColor $color) : void{
|
||||
$this->baseColor = $color;
|
||||
|
@ -163,9 +163,6 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultName() : string{
|
||||
return "Chest";
|
||||
}
|
||||
@ -174,9 +171,6 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
return $this->pairX !== null and $this->pairZ !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Chest|null
|
||||
*/
|
||||
public function getPair() : ?Chest{
|
||||
if($this->isPaired()){
|
||||
$tile = $this->pos->getWorld()->getTileAt($this->pairX, $this->pos->y, $this->pairZ);
|
||||
|
@ -36,16 +36,10 @@ class Comparator extends Tile{
|
||||
/** @var int */
|
||||
protected $signalStrength = 0;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSignalStrength() : int{
|
||||
return $this->signalStrength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $signalStrength
|
||||
*/
|
||||
public function setSignalStrength(int $signalStrength) : void{
|
||||
$this->signalStrength = $signalStrength;
|
||||
}
|
||||
|
@ -37,10 +37,6 @@ interface Container extends InventoryHolder{
|
||||
|
||||
/**
|
||||
* Returns whether this container can be opened by an item with the given custom name.
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canOpenWith(string $key) : bool;
|
||||
}
|
||||
|
@ -78,10 +78,6 @@ trait ContainerTrait{
|
||||
|
||||
/**
|
||||
* @see Container::canOpenWith()
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canOpenWith(string $key) : bool{
|
||||
return $this->lock === null or $this->lock === $key;
|
||||
@ -89,7 +85,6 @@ trait ContainerTrait{
|
||||
|
||||
/**
|
||||
* @see Position::asPosition()
|
||||
* @return Position
|
||||
*/
|
||||
abstract protected function getPos() : Position;
|
||||
|
||||
|
@ -29,9 +29,6 @@ class EnchantTable extends Spawnable implements Nameable{
|
||||
saveName as writeSaveData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultName() : string{
|
||||
return "Enchanting Table";
|
||||
}
|
||||
|
@ -90,9 +90,6 @@ class Furnace extends Spawnable implements Container, Nameable{
|
||||
$this->saveItems($nbt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultName() : string{
|
||||
return "Furnace";
|
||||
}
|
||||
|
@ -26,23 +26,11 @@ namespace pocketmine\block\tile;
|
||||
interface Nameable{
|
||||
public const TAG_CUSTOM_NAME = "CustomName";
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultName() : string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() : string;
|
||||
|
||||
/**
|
||||
* @param string $str
|
||||
*/
|
||||
public function setName(string $str) : void;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasName() : bool;
|
||||
}
|
||||
|
@ -34,21 +34,12 @@ trait NameableTrait{
|
||||
/** @var string|null */
|
||||
private $customName = null;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getDefaultName() : string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() : string{
|
||||
return $this->customName ?? $this->getDefaultName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name) : void{
|
||||
if($name === ""){
|
||||
$this->customName = null;
|
||||
@ -57,9 +48,6 @@ trait NameableTrait{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasName() : bool{
|
||||
return $this->customName !== null;
|
||||
}
|
||||
@ -83,7 +71,6 @@ trait NameableTrait{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
* @see Tile::copyDataFromItem()
|
||||
*/
|
||||
public function copyDataFromItem(Item $item) : void{
|
||||
|
@ -43,16 +43,10 @@ class Note extends Tile{
|
||||
$nbt->setByte("note", $this->pitch);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPitch() : int{
|
||||
return $this->pitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $pitch
|
||||
*/
|
||||
public function setPitch(int $pitch) : void{
|
||||
if($pitch < BlockNote::MIN_PITCH or $pitch > BlockNote::MAX_PITCH){
|
||||
throw new \InvalidArgumentException("Pitch must be in range " . BlockNote::MIN_PITCH . " - " . BlockNote::MAX_PITCH);
|
||||
|
@ -78,16 +78,10 @@ class Sign extends Spawnable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SignText
|
||||
*/
|
||||
public function getText() : SignText{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SignText $text
|
||||
*/
|
||||
public function setText(SignText $text) : void{
|
||||
$this->text = $text;
|
||||
}
|
||||
|
@ -39,16 +39,11 @@ abstract class Spawnable extends Tile{
|
||||
|
||||
/**
|
||||
* Returns whether the tile needs to be respawned to viewers.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDirty() : bool{
|
||||
return $this->dirty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $dirty
|
||||
*/
|
||||
public function setDirty(bool $dirty = true) : void{
|
||||
if($dirty){
|
||||
$this->spawnCompoundCache = null;
|
||||
@ -74,9 +69,6 @@ abstract class Spawnable extends Tile{
|
||||
return $this->spawnCompoundCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CompoundTag
|
||||
*/
|
||||
final public function getSpawnCompound() : CompoundTag{
|
||||
$nbt = CompoundTag::create()
|
||||
->setString(self::TAG_ID, TileFactory::getSaveId(get_class($this))) //TODO: disassociate network ID from save ID
|
||||
@ -90,8 +82,6 @@ abstract class Spawnable extends Tile{
|
||||
/**
|
||||
* An extension to getSpawnCompound() for
|
||||
* further modifying the generic tile NBT.
|
||||
*
|
||||
* @param CompoundTag $nbt
|
||||
*/
|
||||
abstract protected function addAdditionalSpawnData(CompoundTag $nbt) : void;
|
||||
}
|
||||
|
@ -59,15 +59,11 @@ abstract class Tile{
|
||||
/**
|
||||
* @internal
|
||||
* Reads additional data from the CompoundTag on tile creation.
|
||||
*
|
||||
* @param CompoundTag $nbt
|
||||
*/
|
||||
abstract public function readSaveData(CompoundTag $nbt) : void;
|
||||
|
||||
/**
|
||||
* Writes additional save data to a CompoundTag, not including generic things like ID and coordinates.
|
||||
*
|
||||
* @param CompoundTag $nbt
|
||||
*/
|
||||
abstract protected function writeSaveData(CompoundTag $nbt) : void;
|
||||
|
||||
@ -90,8 +86,6 @@ abstract class Tile{
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function copyDataFromItem(Item $item) : void{
|
||||
@ -100,16 +94,10 @@ abstract class Tile{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Block
|
||||
*/
|
||||
public function getBlock() : Block{
|
||||
return $this->pos->getWorld()->getBlock($this->pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Position
|
||||
*/
|
||||
public function getPos() : Position{
|
||||
return $this->pos;
|
||||
}
|
||||
|
@ -89,7 +89,6 @@ final class TileFactory{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string[] $saveNames
|
||||
*/
|
||||
public static function register(string $className, array $saveNames = []) : void{
|
||||
@ -125,10 +124,6 @@ final class TileFactory{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $baseClass
|
||||
* @param World $world
|
||||
* @param Vector3 $pos
|
||||
*
|
||||
* @return Tile (will be an instanceof $baseClass)
|
||||
* @throws \InvalidArgumentException if the specified class is not a registered tile
|
||||
*/
|
||||
@ -149,12 +144,7 @@ final class TileFactory{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param World $world
|
||||
* @param CompoundTag $nbt
|
||||
*
|
||||
* @return Tile|null
|
||||
*@internal
|
||||
*
|
||||
*/
|
||||
public static function createFromData(World $world, CompoundTag $nbt) : ?Tile{
|
||||
$type = $nbt->getString(Tile::TAG_ID, "", true);
|
||||
|
@ -79,16 +79,10 @@ class BannerPattern{
|
||||
$this->color = $color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getId() : string{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DyeColor
|
||||
*/
|
||||
public function getColor() : DyeColor{
|
||||
return $this->color;
|
||||
}
|
||||
|
@ -32,9 +32,6 @@ final class BlockDataSerializer{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $raw
|
||||
*
|
||||
* @return int
|
||||
* @throws InvalidBlockStateException
|
||||
*/
|
||||
public static function readFacing(int $raw) : int{
|
||||
@ -68,9 +65,6 @@ final class BlockDataSerializer{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $facing
|
||||
*
|
||||
* @return int
|
||||
* @throws InvalidBlockStateException
|
||||
*/
|
||||
public static function readHorizontalFacing(int $facing) : int{
|
||||
@ -89,9 +83,6 @@ final class BlockDataSerializer{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $raw
|
||||
*
|
||||
* @return int
|
||||
* @throws InvalidBlockStateException
|
||||
*/
|
||||
public static function readLegacyHorizontalFacing(int $raw) : int{
|
||||
@ -121,9 +112,6 @@ final class BlockDataSerializer{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $value
|
||||
*
|
||||
* @return int
|
||||
* @throws InvalidBlockStateException
|
||||
*/
|
||||
public static function read5MinusHorizontalFacing(int $value) : int{
|
||||
|
@ -87,10 +87,8 @@ final class DyeColor{
|
||||
* Returns a DyeColor object matching the given magic number
|
||||
* @internal
|
||||
*
|
||||
* @param int $magicNumber
|
||||
* @param bool $inverted Invert the ID before using it (useful for actual dye magic IDs)
|
||||
*
|
||||
* @return DyeColor
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function fromMagicNumber(int $magicNumber, bool $inverted = false) : DyeColor{
|
||||
@ -116,30 +114,18 @@ final class DyeColor{
|
||||
$this->rgbValue = $rgbValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayName() : string{
|
||||
return $this->displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Color
|
||||
*/
|
||||
public function getRgbValue() : Color{
|
||||
return $this->rgbValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMagicNumber() : int{
|
||||
return $this->magicNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getInvertedMagicNumber() : int{
|
||||
return ~$this->magicNumber & 0xf;
|
||||
}
|
||||
|
@ -31,8 +31,6 @@ interface Fallable{
|
||||
* Called every tick by FallingBlock to update the falling state of this block. Used by concrete to check when it
|
||||
* hits water.
|
||||
* Return null if you don't want to change the usual behaviour.
|
||||
*
|
||||
* @return Block|null
|
||||
*/
|
||||
public function tickFalling() : ?Block;
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ trait PillarRotationTrait{
|
||||
|
||||
/**
|
||||
* @see Block::writeStateToMeta()
|
||||
* @return int
|
||||
*/
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->writeAxisToMeta();
|
||||
@ -49,9 +48,6 @@ trait PillarRotationTrait{
|
||||
|
||||
/**
|
||||
* @see Block::readStateFromData()
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $stateMeta
|
||||
*/
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->readAxisFromMeta($stateMeta);
|
||||
@ -59,7 +55,6 @@ trait PillarRotationTrait{
|
||||
|
||||
/**
|
||||
* @see Block::getStateBitmask()
|
||||
* @return int
|
||||
*/
|
||||
public function getStateBitmask() : int{
|
||||
return 0b11 << $this->getAxisMetaShift();
|
||||
@ -89,16 +84,6 @@ trait PillarRotationTrait{
|
||||
|
||||
/**
|
||||
* @see Block::place()
|
||||
*
|
||||
* @param BlockTransaction $tx
|
||||
* @param Item $item
|
||||
* @param Block $blockReplace
|
||||
* @param Block $blockClicked
|
||||
* @param int $face
|
||||
* @param Vector3 $clickVector
|
||||
* @param Player|null $player
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$this->axis = Facing::axis($face);
|
||||
|
@ -50,9 +50,6 @@ class SignText{
|
||||
* Parses sign lines from the given string blob.
|
||||
* TODO: add a strict mode for this
|
||||
*
|
||||
* @param string $blob
|
||||
*
|
||||
* @return SignText
|
||||
* @throws \InvalidArgumentException if the text is not valid UTF-8
|
||||
*/
|
||||
public static function fromBlob(string $blob) : SignText{
|
||||
@ -101,9 +98,6 @@ class SignText{
|
||||
/**
|
||||
* Returns the sign line at the given offset.
|
||||
*
|
||||
* @param int $index
|
||||
*
|
||||
* @return string
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function getLine(int $index) : string{
|
||||
@ -114,9 +108,6 @@ class SignText{
|
||||
/**
|
||||
* Sets the line at the given offset.
|
||||
*
|
||||
* @param int $index
|
||||
* @param string $line
|
||||
*
|
||||
* @throws \InvalidArgumentException if the text is not valid UTF-8
|
||||
* @throws \InvalidArgumentException if the text contains a newline
|
||||
*/
|
||||
|
@ -64,9 +64,7 @@ final class SkullType{
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @param int $magicNumber
|
||||
*
|
||||
* @return SkullType
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function fromMagicNumber(int $magicNumber) : SkullType{
|
||||
@ -87,16 +85,10 @@ final class SkullType{
|
||||
$this->magicNumber = $magicNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayName() : string{
|
||||
return $this->displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMagicNumber() : int{
|
||||
return $this->magicNumber;
|
||||
}
|
||||
|
@ -65,9 +65,6 @@ final class TreeType{
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @param int $magicNumber
|
||||
*
|
||||
* @return TreeType
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function fromMagicNumber(int $magicNumber) : TreeType{
|
||||
@ -83,27 +80,16 @@ final class TreeType{
|
||||
/** @var int */
|
||||
private $magicNumber;
|
||||
|
||||
/**
|
||||
* @param string $enumName
|
||||
* @param string $displayName
|
||||
* @param int $magicNumber
|
||||
*/
|
||||
private function __construct(string $enumName, string $displayName, int $magicNumber){
|
||||
$this->Enum___construct($enumName);
|
||||
$this->displayName = $displayName;
|
||||
$this->magicNumber = $magicNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayName() : string{
|
||||
return $this->displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMagicNumber() : int{
|
||||
return $this->magicNumber;
|
||||
}
|
||||
|
@ -74,8 +74,6 @@ abstract class Command{
|
||||
public $timings;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $description
|
||||
* @param string $usageMessage
|
||||
* @param string[] $aliases
|
||||
*/
|
||||
@ -88,8 +86,6 @@ abstract class Command{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CommandSender $sender
|
||||
* @param string $commandLabel
|
||||
* @param string[] $args
|
||||
*
|
||||
* @return mixed
|
||||
@ -97,33 +93,18 @@ abstract class Command{
|
||||
*/
|
||||
abstract public function execute(CommandSender $sender, string $commandLabel, array $args);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() : string{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPermission() : ?string{
|
||||
return $this->permission;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string|null $permission
|
||||
*/
|
||||
public function setPermission(?string $permission) : void{
|
||||
$this->permission = $permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CommandSender $target
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function testPermission(CommandSender $target) : bool{
|
||||
if($this->testPermissionSilent($target)){
|
||||
return true;
|
||||
@ -138,11 +119,6 @@ abstract class Command{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CommandSender $target
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function testPermissionSilent(CommandSender $target) : bool{
|
||||
if($this->permission === null or $this->permission === ""){
|
||||
return true;
|
||||
@ -157,9 +133,6 @@ abstract class Command{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel() : string{
|
||||
return $this->label;
|
||||
}
|
||||
@ -181,10 +154,6 @@ abstract class Command{
|
||||
|
||||
/**
|
||||
* Registers the command into a Command map
|
||||
*
|
||||
* @param CommandMap $commandMap
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function register(CommandMap $commandMap) : bool{
|
||||
if($this->allowChangesFrom($commandMap)){
|
||||
@ -196,11 +165,6 @@ abstract class Command{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CommandMap $commandMap
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function unregister(CommandMap $commandMap) : bool{
|
||||
if($this->allowChangesFrom($commandMap)){
|
||||
$this->commandMap = null;
|
||||
@ -213,18 +177,10 @@ abstract class Command{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CommandMap $commandMap
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function allowChangesFrom(CommandMap $commandMap) : bool{
|
||||
return $this->commandMap === null or $this->commandMap === $commandMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isRegistered() : bool{
|
||||
return $this->commandMap !== null;
|
||||
}
|
||||
@ -236,23 +192,14 @@ abstract class Command{
|
||||
return $this->activeAliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPermissionMessage() : ?string{
|
||||
return $this->permissionMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription() : string{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUsage() : string{
|
||||
return $this->usageMessage;
|
||||
}
|
||||
@ -267,31 +214,20 @@ abstract class Command{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
*/
|
||||
public function setDescription(string $description) : void{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $permissionMessage
|
||||
*/
|
||||
public function setPermissionMessage(string $permissionMessage) : void{
|
||||
$this->permissionMessage = $permissionMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $usage
|
||||
*/
|
||||
public function setUsage(string $usage) : void{
|
||||
$this->usageMessage = $usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CommandSender $source
|
||||
* @param TextContainer|string $message
|
||||
* @param bool $sendToSource
|
||||
*/
|
||||
public static function broadcastCommandMessage(CommandSender $source, $message, bool $sendToSource = true) : void{
|
||||
$users = PermissionManager::getInstance()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_ADMINISTRATIVE);
|
||||
@ -325,9 +261,6 @@ abstract class Command{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() : string{
|
||||
return $this->name;
|
||||
}
|
||||
|
@ -27,12 +27,7 @@ namespace pocketmine\command;
|
||||
interface CommandExecutor{
|
||||
|
||||
/**
|
||||
* @param CommandSender $sender
|
||||
* @param Command $command
|
||||
* @param string $label
|
||||
* @param string[] $args
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool;
|
||||
|
||||
|
@ -27,38 +27,16 @@ namespace pocketmine\command;
|
||||
interface CommandMap{
|
||||
|
||||
/**
|
||||
* @param string $fallbackPrefix
|
||||
* @param Command[] $commands
|
||||
*/
|
||||
public function registerAll(string $fallbackPrefix, array $commands) : void;
|
||||
|
||||
/**
|
||||
* @param string $fallbackPrefix
|
||||
* @param Command $command
|
||||
* @param string|null $label
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function register(string $fallbackPrefix, Command $command, ?string $label = null) : bool;
|
||||
|
||||
/**
|
||||
* @param CommandSender $sender
|
||||
* @param string $cmdLine
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(CommandSender $sender, string $cmdLine) : bool;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function clearCommands() : void;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return Command|null
|
||||
*/
|
||||
public function getCommand(string $name) : ?Command;
|
||||
|
||||
|
||||
|
@ -114,8 +114,6 @@ class CommandReader extends Thread{
|
||||
* Checks if the specified stream is a FIFO pipe.
|
||||
*
|
||||
* @param resource $stream
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isPipe($stream) : bool{
|
||||
return is_resource($stream) and (!stream_isatty($stream) or ((fstat($stream)["mode"] & 0170000) === 0010000));
|
||||
@ -177,8 +175,6 @@ class CommandReader extends Thread{
|
||||
|
||||
/**
|
||||
* Reads a line from console, if available. Returns null if not available
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLine() : ?string{
|
||||
if($this->buffer->count() !== 0){
|
||||
|
@ -34,28 +34,18 @@ interface CommandSender extends Permissible{
|
||||
*/
|
||||
public function sendMessage($message) : void;
|
||||
|
||||
/**
|
||||
* @return Server
|
||||
*/
|
||||
public function getServer() : Server;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() : string;
|
||||
|
||||
/**
|
||||
* Returns the line height of the command-sender's screen. Used for determining sizes for command output pagination
|
||||
* such as in the /help command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getScreenLineHeight() : int;
|
||||
|
||||
/**
|
||||
* Sets the line height used for command output pagination for this command sender. `null` will reset it to default.
|
||||
*
|
||||
* @param int|null $height
|
||||
*/
|
||||
public function setScreenLineHeight(?int $height) : void;
|
||||
}
|
||||
|
@ -41,9 +41,6 @@ class ConsoleCommandSender implements CommandSender{
|
||||
$this->perm = new PermissibleBase($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Server
|
||||
*/
|
||||
public function getServer() : Server{
|
||||
return Server::getInstance();
|
||||
}
|
||||
@ -64,23 +61,14 @@ class ConsoleCommandSender implements CommandSender{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() : string{
|
||||
return "CONSOLE";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isOp() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setOp(bool $value) : void{
|
||||
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ class FormattedCommandAlias extends Command{
|
||||
private $formatStrings = [];
|
||||
|
||||
/**
|
||||
* @param string $alias
|
||||
* @param string[] $formatStrings
|
||||
*/
|
||||
public function __construct(string $alias, array $formatStrings){
|
||||
@ -65,12 +64,6 @@ class FormattedCommandAlias extends Command{
|
||||
return (bool) $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $formatString
|
||||
* @param array $args
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function buildCommand(string $formatString, array $args) : string{
|
||||
$index = strpos($formatString, '$');
|
||||
while($index !== false){
|
||||
@ -144,13 +137,6 @@ class FormattedCommandAlias extends Command{
|
||||
return $formatString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $i
|
||||
* @param int $j
|
||||
* @param int $k
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function inRange(int $i, int $j, int $k) : bool{
|
||||
return $i >= $j and $i <= $k;
|
||||
}
|
||||
|
@ -34,11 +34,6 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{
|
||||
/** @var CommandExecutor */
|
||||
private $executor;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param Plugin $owner
|
||||
* @param CommandExecutor $executor
|
||||
*/
|
||||
public function __construct(string $name, Plugin $owner, CommandExecutor $executor){
|
||||
parent::__construct($name);
|
||||
$this->owningPlugin = $owner;
|
||||
@ -69,16 +64,10 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{
|
||||
return $this->executor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CommandExecutor $executor
|
||||
*/
|
||||
public function setExecutor(CommandExecutor $executor) : void{
|
||||
$this->executor = $executor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Plugin
|
||||
*/
|
||||
public function getPlugin() : Plugin{
|
||||
return $this->owningPlugin;
|
||||
}
|
||||
|
@ -27,8 +27,5 @@ use pocketmine\plugin\Plugin;
|
||||
|
||||
interface PluginIdentifiableCommand{
|
||||
|
||||
/**
|
||||
* @return Plugin
|
||||
*/
|
||||
public function getPlugin() : Plugin;
|
||||
}
|
||||
|
@ -142,13 +142,6 @@ class SimpleCommandMap implements CommandMap{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fallbackPrefix
|
||||
* @param Command $command
|
||||
* @param string|null $label
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function register(string $fallbackPrefix, Command $command, ?string $label = null) : bool{
|
||||
if($label === null){
|
||||
$label = $command->getName();
|
||||
@ -175,11 +168,6 @@ class SimpleCommandMap implements CommandMap{
|
||||
return $registered;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Command $command
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function unregister(Command $command) : bool{
|
||||
foreach($this->knownCommands as $lbl => $cmd){
|
||||
if($cmd === $command){
|
||||
@ -192,14 +180,6 @@ class SimpleCommandMap implements CommandMap{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Command $command
|
||||
* @param bool $isAlias
|
||||
* @param string $fallbackPrefix
|
||||
* @param string $label
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function registerAlias(Command $command, bool $isAlias, string $fallbackPrefix, string $label) : bool{
|
||||
$this->knownCommands[$fallbackPrefix . ":" . $label] = $command;
|
||||
if(($command instanceof VanillaCommand or $isAlias) and isset($this->knownCommands[$label])){
|
||||
@ -226,8 +206,6 @@ class SimpleCommandMap implements CommandMap{
|
||||
*
|
||||
* @param string $commandName reference parameter
|
||||
* @param string[] $args reference parameter
|
||||
*
|
||||
* @return Command|null
|
||||
*/
|
||||
public function matchCommand(string &$commandName, array &$args) : ?Command{
|
||||
$count = min(count($args), 255);
|
||||
@ -294,10 +272,6 @@ class SimpleCommandMap implements CommandMap{
|
||||
return $this->knownCommands;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function registerServerAliases() : void{
|
||||
$values = $this->server->getCommandAliases();
|
||||
|
||||
|
@ -137,12 +137,6 @@ class ParticleCommand extends VanillaCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param int|null $data
|
||||
*
|
||||
* @return Particle|null
|
||||
*/
|
||||
private function getParticle(string $name, ?int $data = null) : ?Particle{
|
||||
switch($name){
|
||||
case "explode":
|
||||
|
@ -36,12 +36,7 @@ abstract class VanillaCommand extends Command{
|
||||
public const MIN_COORD = -30000000;
|
||||
|
||||
/**
|
||||
* @param CommandSender $sender
|
||||
* @param mixed $value
|
||||
* @param int $min
|
||||
* @param int $max
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getInteger(CommandSender $sender, $value, int $min = self::MIN_COORD, int $max = self::MAX_COORD) : int{
|
||||
$i = (int) $value;
|
||||
@ -55,15 +50,6 @@ abstract class VanillaCommand extends Command{
|
||||
return $i;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $original
|
||||
* @param CommandSender $sender
|
||||
* @param string $input
|
||||
* @param float $min
|
||||
* @param float $max
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
protected function getRelativeDouble(float $original, CommandSender $sender, string $input, float $min = self::MIN_COORD, float $max = self::MAX_COORD) : float{
|
||||
if($input[0] === "~"){
|
||||
$value = $this->getDouble($sender, substr($input, 1));
|
||||
@ -75,12 +61,7 @@ abstract class VanillaCommand extends Command{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CommandSender $sender
|
||||
* @param mixed $value
|
||||
* @param float $min
|
||||
* @param float $max
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
protected function getDouble(CommandSender $sender, $value, float $min = self::MIN_COORD, float $max = self::MAX_COORD) : float{
|
||||
$i = (double) $value;
|
||||
|
@ -105,11 +105,6 @@ class CraftingGrid extends BaseInventory{
|
||||
|
||||
/**
|
||||
* Returns the item at offset x,y, offset by where the starts of the recipe rectangle are.
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
*
|
||||
* @return Item
|
||||
*/
|
||||
public function getIngredient(int $x, int $y) : Item{
|
||||
if($this->startX !== null and $this->startY !== null){
|
||||
@ -121,8 +116,6 @@ class CraftingGrid extends BaseInventory{
|
||||
|
||||
/**
|
||||
* Returns the width of the recipe we're trying to craft, based on items currently in the grid.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRecipeWidth() : int{
|
||||
return $this->xLen ?? 0;
|
||||
@ -130,7 +123,6 @@ class CraftingGrid extends BaseInventory{
|
||||
|
||||
/**
|
||||
* Returns the height of the recipe we're trying to craft, based on items currently in the grid.
|
||||
* @return int
|
||||
*/
|
||||
public function getRecipeHeight() : int{
|
||||
return $this->yLen ?? 0;
|
||||
|
@ -124,8 +124,6 @@ class CraftingManager{
|
||||
|
||||
/**
|
||||
* Returns a pre-compressed CraftingDataPacket for sending to players. Rebuilds the cache if it is not found.
|
||||
*
|
||||
* @return CompressBatchPromise
|
||||
*/
|
||||
public function getCraftingDataPacket() : CompressBatchPromise{
|
||||
if($this->craftingDataCache === null){
|
||||
@ -137,11 +135,6 @@ class CraftingManager{
|
||||
|
||||
/**
|
||||
* Function used to arrange Shapeless Recipe ingredient lists into a consistent order.
|
||||
*
|
||||
* @param Item $i1
|
||||
* @param Item $i2
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function sort(Item $i1, Item $i2) : int{
|
||||
//Use spaceship operator to compare each property, then try the next one if they are equivalent.
|
||||
@ -206,27 +199,18 @@ class CraftingManager{
|
||||
return $this->furnaceRecipes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ShapedRecipe $recipe
|
||||
*/
|
||||
public function registerShapedRecipe(ShapedRecipe $recipe) : void{
|
||||
$this->shapedRecipes[self::hashOutputs($recipe->getResults())][] = $recipe;
|
||||
|
||||
$this->craftingDataCache = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ShapelessRecipe $recipe
|
||||
*/
|
||||
public function registerShapelessRecipe(ShapelessRecipe $recipe) : void{
|
||||
$this->shapelessRecipes[self::hashOutputs($recipe->getResults())][] = $recipe;
|
||||
|
||||
$this->craftingDataCache = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FurnaceRecipe $recipe
|
||||
*/
|
||||
public function registerFurnaceRecipe(FurnaceRecipe $recipe) : void{
|
||||
$input = $recipe->getInput();
|
||||
$this->furnaceRecipes[$input->getId() . ":" . ($input->hasAnyDamageValue() ? "?" : $input->getMeta())] = $recipe;
|
||||
@ -234,10 +218,7 @@ class CraftingManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CraftingGrid $grid
|
||||
* @param Item[] $outputs
|
||||
*
|
||||
* @return CraftingRecipe|null
|
||||
*/
|
||||
public function matchRecipe(CraftingGrid $grid, array $outputs) : ?CraftingRecipe{
|
||||
//TODO: try to match special recipes before anything else (first they need to be implemented!)
|
||||
@ -286,11 +267,6 @@ class CraftingManager{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $input
|
||||
*
|
||||
* @return FurnaceRecipe|null
|
||||
*/
|
||||
public function matchFurnaceRecipe(Item $input) : ?FurnaceRecipe{
|
||||
return $this->furnaceRecipes[$input->getId() . ":" . $input->getMeta()] ?? $this->furnaceRecipes[$input->getId() . ":?"] ?? null;
|
||||
}
|
||||
|
@ -36,18 +36,12 @@ interface CraftingRecipe{
|
||||
/**
|
||||
* Returns a list of results this recipe will produce when the inputs in the given crafting grid are consumed.
|
||||
*
|
||||
* @param CraftingGrid $grid
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
public function getResultsFor(CraftingGrid $grid) : array;
|
||||
|
||||
/**
|
||||
* Returns whether the given crafting grid meets the requirements to craft this recipe.
|
||||
*
|
||||
* @param CraftingGrid $grid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matchesCraftingGrid(CraftingGrid $grid) : bool;
|
||||
}
|
||||
|
@ -33,25 +33,15 @@ class FurnaceRecipe{
|
||||
/** @var Item */
|
||||
private $ingredient;
|
||||
|
||||
/**
|
||||
* @param Item $result
|
||||
* @param Item $ingredient
|
||||
*/
|
||||
public function __construct(Item $result, Item $ingredient){
|
||||
$this->output = clone $result;
|
||||
$this->ingredient = clone $ingredient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getInput() : Item{
|
||||
return clone $this->ingredient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getResult() : Item{
|
||||
return clone $this->output;
|
||||
}
|
||||
|
@ -114,8 +114,6 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CraftingGrid $grid
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
public function getResultsFor(CraftingGrid $grid) : array{
|
||||
@ -155,12 +153,6 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
return $ingredients;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
*
|
||||
* @return Item
|
||||
*/
|
||||
public function getIngredient(int $x, int $y) : Item{
|
||||
$exists = $this->ingredientList[$this->shape[$y]{$x}] ?? null;
|
||||
return $exists !== null ? clone $exists : ItemFactory::air();
|
||||
@ -174,12 +166,6 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
return $this->shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CraftingGrid $grid
|
||||
* @param bool $reverse
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function matchInputMap(CraftingGrid $grid, bool $reverse) : bool{
|
||||
for($y = 0; $y < $this->height; ++$y){
|
||||
for($x = 0; $x < $this->width; ++$x){
|
||||
@ -195,11 +181,6 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CraftingGrid $grid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matchesCraftingGrid(CraftingGrid $grid) : bool{
|
||||
if($this->width !== $grid->getRecipeWidth() or $this->height !== $grid->getRecipeHeight()){
|
||||
return false;
|
||||
|
@ -67,9 +67,6 @@ class ShapelessRecipe implements CraftingRecipe{
|
||||
return Utils::cloneObjectArray($this->ingredients);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIngredientCount() : int{
|
||||
$count = 0;
|
||||
foreach($this->ingredients as $ingredient){
|
||||
@ -79,11 +76,6 @@ class ShapelessRecipe implements CraftingRecipe{
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CraftingGrid $grid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matchesCraftingGrid(CraftingGrid $grid) : bool{
|
||||
//don't pack the ingredients - shapeless recipes require that each ingredient be in a separate slot
|
||||
$input = $grid->getContents();
|
||||
|
@ -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)){
|
||||
|
@ -28,13 +28,7 @@ namespace pocketmine\event;
|
||||
* Events that can be cancelled must use the interface Cancellable
|
||||
*/
|
||||
interface Cancellable{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isCancelled() : bool;
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setCancelled(bool $value = true) : void;
|
||||
}
|
||||
|
@ -31,16 +31,10 @@ trait CancellableTrait{
|
||||
/** @var bool */
|
||||
private $isCancelled = false;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isCancelled() : bool{
|
||||
return $this->isCancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setCancelled(bool $value = true) : void{
|
||||
$this->isCancelled = $value;
|
||||
}
|
||||
|
@ -36,9 +36,6 @@ abstract class Event{
|
||||
/** @var string|null */
|
||||
protected $eventName = null;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
final public function getEventName() : string{
|
||||
return $this->eventName ?? get_class($this);
|
||||
}
|
||||
|
@ -81,10 +81,6 @@ final class EventPriority{
|
||||
public const MONITOR = 0;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function fromString(string $name) : int{
|
||||
|
@ -43,8 +43,6 @@ class HandlerList{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RegisteredListener $listener
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function register(RegisteredListener $listener) : void{
|
||||
@ -89,17 +87,12 @@ class HandlerList{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $priority
|
||||
*
|
||||
* @return RegisteredListener[]
|
||||
*/
|
||||
public function getListenersByPriority(int $priority) : array{
|
||||
return $this->handlerSlots[$priority];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|HandlerList
|
||||
*/
|
||||
public function getParent() : ?HandlerList{
|
||||
return $this->parentList;
|
||||
}
|
||||
|
@ -61,8 +61,6 @@ class HandlerListManager{
|
||||
/**
|
||||
* @param ReflectionClass $class
|
||||
* @phpstan-param \ReflectionClass<Event> $class
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function isValidClass(\ReflectionClass $class) : bool{
|
||||
$tags = Utils::parseDocComment((string) $class->getDocComment());
|
||||
@ -70,10 +68,8 @@ class HandlerListManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ReflectionClass $class
|
||||
* @phpstan-param \ReflectionClass<Event> $class
|
||||
*
|
||||
* @return \ReflectionClass|null
|
||||
* @phpstan-return \ReflectionClass<Event>|null
|
||||
*/
|
||||
private static function resolveNearestHandleableParent(\ReflectionClass $class) : ?\ReflectionClass{
|
||||
@ -88,9 +84,6 @@ class HandlerListManager{
|
||||
*
|
||||
* Calling this method also lazily initializes the $classMap inheritance tree of handler lists.
|
||||
*
|
||||
* @param string $event
|
||||
*
|
||||
* @return HandlerList
|
||||
* @throws \ReflectionException
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
|
@ -44,14 +44,6 @@ class RegisteredListener{
|
||||
/** @var TimingsHandler */
|
||||
private $timings;
|
||||
|
||||
|
||||
/**
|
||||
* @param \Closure $handler
|
||||
* @param int $priority
|
||||
* @param Plugin $plugin
|
||||
* @param bool $handleCancelled
|
||||
* @param TimingsHandler $timings
|
||||
*/
|
||||
public function __construct(\Closure $handler, int $priority, Plugin $plugin, bool $handleCancelled, TimingsHandler $timings){
|
||||
if(!in_array($priority, EventPriority::ALL, true)){
|
||||
throw new \InvalidArgumentException("Invalid priority number $priority");
|
||||
@ -67,23 +59,14 @@ class RegisteredListener{
|
||||
return $this->handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Plugin
|
||||
*/
|
||||
public function getPlugin() : Plugin{
|
||||
return $this->plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPriority() : int{
|
||||
return $this->priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Event $event
|
||||
*/
|
||||
public function callEvent(Event $event) : void{
|
||||
if($event instanceof Cancellable and $event->isCancelled() and !$this->isHandlingCancelled()){
|
||||
return;
|
||||
@ -97,9 +80,6 @@ class RegisteredListener{
|
||||
$this->timings->remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHandlingCancelled() : bool{
|
||||
return $this->handleCancelled;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user