diff --git a/src/pocketmine/network/mcpe/protocol/SetDifficultyPacket.php b/src/pocketmine/network/mcpe/protocol/SetDifficultyPacket.php index cec01b77d..9aa2df4f4 100644 --- a/src/pocketmine/network/mcpe/protocol/SetDifficultyPacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetDifficultyPacket.php @@ -34,6 +34,12 @@ class SetDifficultyPacket extends DataPacket implements ClientboundPacket, Serve /** @var int */ public $difficulty; + public static function create(int $difficulty) : self{ + $result = new self; + $result->difficulty = $difficulty; + return $result; + } + protected function decodePayload() : void{ $this->difficulty = $this->getUnsignedVarInt(); } diff --git a/src/pocketmine/world/World.php b/src/pocketmine/world/World.php index 1f83e08ba..215882257 100644 --- a/src/pocketmine/world/World.php +++ b/src/pocketmine/world/World.php @@ -2772,8 +2772,7 @@ class World implements ChunkManager, Metadatable{ * @param Player ...$targets */ public function sendDifficulty(Player ...$targets){ - $pk = new SetDifficultyPacket(); - $pk->difficulty = $this->getDifficulty(); + $pk = SetDifficultyPacket::create($this->getDifficulty()); if(empty($targets)){ $this->broadcastGlobalPacket($pk); }else{