From 1a9ec65983a585d7d489d8024e0dd1958099dede Mon Sep 17 00:00:00 2001 From: "Luca P." Date: Sat, 22 Aug 2015 15:58:45 +0200 Subject: [PATCH 01/14] Spelling fix --- src/pocketmine/utils/ServerKiller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/utils/ServerKiller.php b/src/pocketmine/utils/ServerKiller.php index d5c710f07..2e3326ebb 100644 --- a/src/pocketmine/utils/ServerKiller.php +++ b/src/pocketmine/utils/ServerKiller.php @@ -33,11 +33,11 @@ class ServerKiller extends Thread{ public function run(){ sleep($this->time); - echo "\nTook to long to stop, server was killed forcefully!\n"; + echo "\nTook too long to stop, server was killed forcefully!\n"; @\pocketmine\kill(getmypid()); } public function getThreadName(){ return "Server Killer"; } -} \ No newline at end of file +} From 0b9b1738b314af0d9562213da05d15c159ef96b7 Mon Sep 17 00:00:00 2001 From: Sjoerd Date: Thu, 27 Aug 2015 10:44:44 +0200 Subject: [PATCH 02/14] Block cache not cleared with a call to clearcache While trying to figure out Github and looking for a different bug I found this small bug in the code. The ClearCache function on Level.php did not correctly clear the blockcache. --- src/pocketmine/level/Level.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index f1881148e..b1d5ed97c 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -855,7 +855,7 @@ class Level implements ChunkManager, Metadatable{ } if(count($this->blockCache) > 2048){ - $this->chunkCache = []; + $this->blockCache = []; } } From 0348d181d4dfea065a430778b0f748575d8bf4fd Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Sat, 29 Aug 2015 18:03:40 +0800 Subject: [PATCH 03/14] Remove unused parameter in Level::requestChunk --- src/pocketmine/level/Level.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index f1881148e..177435ffe 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -2251,7 +2251,7 @@ class Level implements ChunkManager, Metadatable{ $this->server->getPluginManager()->callEvent(new SpawnChangeEvent($this, $previousSpawn)); } - public function requestChunk($x, $z, Player $player, $order = LevelProvider::ORDER_ZXY){ + public function requestChunk($x, $z, Player $player){ $index = Level::chunkHash($x, $z); if(!isset($this->chunkSendQueue[$index])){ $this->chunkSendQueue[$index] = []; From 9adcc19154e1a448ff5ff894a9ff804f17b066f1 Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Mon, 31 Aug 2015 22:05:49 +0930 Subject: [PATCH 04/14] @PEMapModder Removed redundant parameters for Living::knockBack. Closes #3427. --- src/pocketmine/entity/Living.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index 4bfe52ccf..d336fae22 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -132,7 +132,18 @@ abstract class Living extends Entity implements Damageable{ $this->attackTime = 10; //0.5 seconds cooldown } - public function knockBack(Entity $attacker, $damage, $x, $z, $base = 0.4){ + /** + * Note: Variadic function is used to preserve BC + * @param int $x + * @param int $z + * @param float $base Default 0.4 + */ + public function knockBack($x, $z, $base = 0.4){ + if(func_num_args() >= 4){ + $args = func_get_args(); + list(, , $x, $z) = $args; + $base = isset($args[4]) ? $args[4] : 0.4; + } $f = sqrt($x * $x + $z * $z); if($f <= 0){ return; From a18826473b45e446e6213dd1c912002e12ff20ed Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 31 Aug 2015 17:48:28 +0200 Subject: [PATCH 05/14] Added enderman teleport sound --- .../level/sound/EndermanTeleportSound.php | 31 +++++++++++++++++++ .../network/protocol/LevelEventPacket.php | 1 + 2 files changed, 32 insertions(+) create mode 100644 src/pocketmine/level/sound/EndermanTeleportSound.php diff --git a/src/pocketmine/level/sound/EndermanTeleportSound.php b/src/pocketmine/level/sound/EndermanTeleportSound.php new file mode 100644 index 000000000..c4e43130e --- /dev/null +++ b/src/pocketmine/level/sound/EndermanTeleportSound.php @@ -0,0 +1,31 @@ + Date: Mon, 31 Aug 2015 17:48:52 +0200 Subject: [PATCH 06/14] Revert commit that removed useful parameter for plugins that made backwards-incompatible changes Revert "@PEMapModder Removed redundant parameters for Living::knockBack. Closes #3427." This reverts commit 9adcc19154e1a448ff5ff894a9ff804f17b066f1. --- src/pocketmine/entity/Living.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index d336fae22..4bfe52ccf 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -132,18 +132,7 @@ abstract class Living extends Entity implements Damageable{ $this->attackTime = 10; //0.5 seconds cooldown } - /** - * Note: Variadic function is used to preserve BC - * @param int $x - * @param int $z - * @param float $base Default 0.4 - */ - public function knockBack($x, $z, $base = 0.4){ - if(func_num_args() >= 4){ - $args = func_get_args(); - list(, , $x, $z) = $args; - $base = isset($args[4]) ? $args[4] : 0.4; - } + public function knockBack(Entity $attacker, $damage, $x, $z, $base = 0.4){ $f = sqrt($x * $x + $z * $z); if($f <= 0){ return; From 5baa87e9febc7312406e8ca263af292136c01ad4 Mon Sep 17 00:00:00 2001 From: Sjoerd Date: Fri, 4 Sep 2015 23:40:19 +0200 Subject: [PATCH 07/14] First item in the hotbar is not loaded correctly When you logon the first hotbar item contains the first item of the inventory, but it should contain the previously selected item. --- src/pocketmine/Player.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 5ab3ba015..ae38135f3 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1769,7 +1769,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade if($this->isCreative()){ $this->inventory->setHeldItemSlot(0); }else{ - $this->inventory->setHeldItemSlot(0); + $this->inventory->setHeldItemSlot($this->inventory->getHotbarSlotIndex(0)); } $pk = new PlayStatusPacket(); From cb222601fde55c1393065095915c6fe334327fad Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 11 Sep 2015 16:50:57 +0200 Subject: [PATCH 08/14] Haters gonna hate, also fix misleading interface default parameter --- src/pocketmine/event/Cancellable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/event/Cancellable.php b/src/pocketmine/event/Cancellable.php index ea7f18268..81d2abca9 100644 --- a/src/pocketmine/event/Cancellable.php +++ b/src/pocketmine/event/Cancellable.php @@ -28,5 +28,5 @@ namespace pocketmine\event; interface Cancellable{ public function isCancelled(); - public function setCancelled($forceCancel = false); -} \ No newline at end of file + public function setCancelled($value = true); +} From a1a132741596823772582bb83bd8c6f22ca4c864 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 12 Sep 2015 00:56:54 +0200 Subject: [PATCH 09/14] Removed signed parameter in BinaryStream->getShort() in favor of getSignedShort() --- src/pocketmine/utils/BinaryStream.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/utils/BinaryStream.php b/src/pocketmine/utils/BinaryStream.php index 40aeb192c..d4ec2a96e 100644 --- a/src/pocketmine/utils/BinaryStream.php +++ b/src/pocketmine/utils/BinaryStream.php @@ -105,14 +105,22 @@ class BinaryStream extends \stdClass{ $this->buffer .= Binary::writeLInt($v); } - public function getShort($signed = true){ - return $signed ? Binary::readSignedShort($this->get(2)) : Binary::readShort($this->get(2)); + public function getSignedShort(){ + return Binary::readSignedShort($this->get(2)); } public function putShort($v){ $this->buffer .= Binary::writeShort($v); } + public function getShort(){ + return Binary::readShort($this->get(2)); + } + + public function putSignedShort($v){ + $this->buffer .= Binary::writeShort($v); + } + public function getFloat(){ return Binary::readFloat($this->get(4)); } @@ -188,7 +196,7 @@ class BinaryStream extends \stdClass{ } public function getSlot(){ - $id = $this->getShort(true); + $id = $this->getSignedShort(); if($id <= 0){ return Item::get(0, 0, 0); From 0d6f13cb4f04638cedb40fe714dc71fee142b4a2 Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Sat, 12 Sep 2015 20:53:35 +0800 Subject: [PATCH 10/14] Update Player.php --- src/pocketmine/Player.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 5f2e6710c..73031e1c7 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -263,7 +263,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } public function getClientSecret(){ - return $this->clientSecretId; + return $this->clientSecret; } public function isBanned(){ From c7b915639db3b3915b24865b1a837aaf794af00d Mon Sep 17 00:00:00 2001 From: LouisBHirst Date: Sun, 13 Sep 2015 11:43:51 -0400 Subject: [PATCH 11/14] getOnlinePlayers() only returns the players already connected --- src/pocketmine/Player.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index ae38135f3..9dc8a8e36 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1624,7 +1624,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->uuid = Utils::dataToUUID($this->randomClientId, $this->iusername, $this->getAddress()); - if(count($this->server->getOnlinePlayers()) > $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)){ + if(count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)){ break; } From 24f8de2cc3a82c6651b93040f2a1e8d04961d977 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 14 Sep 2015 20:25:46 +0200 Subject: [PATCH 12/14] Bad hack, TODO REMOVE, workarounds client bug by sending inventory contents specifically for creative players <-- this commit is full of sadness --- src/pocketmine/Player.php | 1 + src/pocketmine/inventory/PlayerInventory.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index cd46b5c1e..b202e0f05 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1706,6 +1706,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new StartGamePacket(); $pk->seed = -1; + $pk->dimension = 0; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; diff --git a/src/pocketmine/inventory/PlayerInventory.php b/src/pocketmine/inventory/PlayerInventory.php index db3cac450..e788421c6 100644 --- a/src/pocketmine/inventory/PlayerInventory.php +++ b/src/pocketmine/inventory/PlayerInventory.php @@ -383,10 +383,17 @@ class PlayerInventory extends BaseInventory{ } $pk = new ContainerSetContentPacket(); - $pk; $pk->slots = []; - for($i = 0; $i < $this->getSize(); ++$i){ //Do not send armor by error here - $pk->slots[$i] = $this->getItem($i); + $holder = $this->getHolder(); + if($holder instanceof Player and $holder->isCreative()){ + //TODO: Remove this workaround because of broken client + foreach(Item::getCreativeItems() as $i => $item){ + $pk->slots[$i] = Item::getCreativeItem($i); + } + }else{ + for($i = 0; $i < $this->getSize(); ++$i){ //Do not send armor by error here + $pk->slots[$i] = $this->getItem($i); + } } foreach($target as $player){ @@ -416,7 +423,6 @@ class PlayerInventory extends BaseInventory{ } $pk = new ContainerSetSlotPacket(); - $pk; $pk->slot = $index; $pk->item = clone $this->getItem($index); From ed559fdf98456b9bb6ff77c1bf09da397f91ecf8 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Tue, 15 Sep 2015 12:23:15 +0200 Subject: [PATCH 13/14] Fixed not sending UUIDs properly --- src/pocketmine/scheduler/SendUsageTask.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/scheduler/SendUsageTask.php b/src/pocketmine/scheduler/SendUsageTask.php index 632d0563a..fbd285afa 100644 --- a/src/pocketmine/scheduler/SendUsageTask.php +++ b/src/pocketmine/scheduler/SendUsageTask.php @@ -25,6 +25,7 @@ use pocketmine\network\protocol\Info; use pocketmine\Server; use pocketmine\utils\Utils; use pocketmine\utils\VersionString; +use pocketmine\utils\UUID; class SendUsageTask extends AsyncTask{ @@ -39,9 +40,9 @@ class SendUsageTask extends AsyncTask{ $endpoint = "http://" . $server->getProperty("anonymous-statistics.host", "stats.pocketmine.net") . "/"; $data = []; - $data["uniqueServerId"] = $server->getServerUniqueId(); - $data["uniqueMachineId"] = Utils::getMachineUniqueId(); - $data["uniqueRequestId"] = Utils::dataToUUID($server->getServerUniqueId(), microtime(true)); + $data["uniqueServerId"] = $server->getServerUniqueId()->toString(); + $data["uniqueMachineId"] = Utils::getMachineUniqueId()->toString(); + $data["uniqueRequestId"] = UUID::fromData($server->getServerUniqueId(), microtime(true))->toString(); switch($type){ case self::TYPE_OPEN: From 9665dfd63eb75afafacee9e657dac6baaa3ee0fb Mon Sep 17 00:00:00 2001 From: 0929hitoshi Date: Wed, 16 Sep 2015 01:21:07 +0900 Subject: [PATCH 14/14] Changing the return value of getName --- src/pocketmine/tile/EnchantTable.php | 2 +- src/pocketmine/tile/Furnace.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/tile/EnchantTable.php b/src/pocketmine/tile/EnchantTable.php index 09e3cfc48..a94ae40bc 100644 --- a/src/pocketmine/tile/EnchantTable.php +++ b/src/pocketmine/tile/EnchantTable.php @@ -29,7 +29,7 @@ class EnchantTable extends Spawnable implements Nameable{ public function getName(){ - return isset($this->namedtag->CustomName) ? $this->namedtag->CustomName->getValue() : "Chest"; + return isset($this->namedtag->CustomName) ? $this->namedtag->CustomName->getValue() : "Enchanting Table"; } public function hasName(){ diff --git a/src/pocketmine/tile/Furnace.php b/src/pocketmine/tile/Furnace.php index e24a0bb86..6da32496c 100644 --- a/src/pocketmine/tile/Furnace.php +++ b/src/pocketmine/tile/Furnace.php @@ -71,7 +71,7 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{ } public function getName(){ - return isset($this->namedtag->CustomName) ? $this->namedtag->CustomName->getValue() : "Chest"; + return isset($this->namedtag->CustomName) ? $this->namedtag->CustomName->getValue() : "Furnace"; } public function hasName(){