make use of new GameRuleType constants

This commit is contained in:
Dylan K. Taylor 2020-05-20 12:35:29 +01:00
parent 66d44aa814
commit fd63f19199
2 changed files with 9 additions and 7 deletions

View File

@ -37,6 +37,7 @@ use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\network\mcpe\protocol\types\CommandOriginData;
use pocketmine\network\mcpe\protocol\types\EntityLink;
use pocketmine\network\mcpe\protocol\types\GameRuleType;
use pocketmine\network\mcpe\protocol\types\PersonaPieceTintColor;
use pocketmine\network\mcpe\protocol\types\PersonaSkinPiece;
use pocketmine\network\mcpe\protocol\types\SkinAnimation;
@ -602,13 +603,13 @@ class NetworkBinaryStream extends BinaryStream{
$type = $this->getUnsignedVarInt();
$value = null;
switch($type){
case 1:
case GameRuleType::BOOL:
$value = $this->getBool();
break;
case 2:
case GameRuleType::INT:
$value = $this->getUnsignedVarInt();
break;
case 3:
case GameRuleType::FLOAT:
$value = $this->getLFloat();
break;
}
@ -632,13 +633,13 @@ class NetworkBinaryStream extends BinaryStream{
$this->putString($name);
$this->putUnsignedVarInt($rule[0]);
switch($rule[0]){
case 1:
case GameRuleType::BOOL:
$this->putBool($rule[1]);
break;
case 2:
case GameRuleType::INT:
$this->putUnsignedVarInt($rule[1]);
break;
case 3:
case GameRuleType::FLOAT:
$this->putLFloat($rule[1]);
break;
}

View File

@ -31,6 +31,7 @@ use pocketmine\nbt\tag\ListTag;
use pocketmine\network\mcpe\NetworkBinaryStream;
use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\protocol\types\EducationEditionOffer;
use pocketmine\network\mcpe\protocol\types\GameRuleType;
use pocketmine\network\mcpe\protocol\types\GeneratorType;
use pocketmine\network\mcpe\protocol\types\MultiplayerGameVisibility;
use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
@ -110,7 +111,7 @@ class StartGamePacket extends DataPacket{
* @phpstan-var array<string, array{0: int, 1: bool|int|float}>
*/
public $gameRules = [ //TODO: implement this
"naturalregeneration" => [1, false] //Hack for client side regeneration
"naturalregeneration" => [GameRuleType::BOOL, false] //Hack for client side regeneration
];
/** @var bool */
public $hasBonusChestEnabled = false;