Merge branch 'next-minor'

This commit is contained in:
Dylan K. Taylor 2020-03-09 14:38:15 +00:00
commit b4b1877ce5
3 changed files with 4 additions and 12 deletions

View File

@ -1512,7 +1512,7 @@ abstract class Entity{
protected function sendSpawnPacket(Player $player) : void{
$pk = new AddActorPacket();
$pk->entityRuntimeId = $this->getId();
$pk->type = static::NETWORK_ID;
$pk->type = AddActorPacket::LEGACY_ID_MAP_BC[static::NETWORK_ID];
$pk->position = $this->location->asVector3();
$pk->motion = $this->getMotion();
$pk->yaw = $this->location->yaw;

View File

@ -151,7 +151,7 @@ class AddActorPacket extends DataPacket implements ClientboundPacket{
public $entityUniqueId = null; //TODO
/** @var int */
public $entityRuntimeId;
/** @var int */
/** @var string */
public $type;
/** @var Vector3 */
public $position;
@ -177,10 +177,7 @@ class AddActorPacket extends DataPacket implements ClientboundPacket{
protected function decodePayload(NetworkBinaryStream $in) : void{
$this->entityUniqueId = $in->getEntityUniqueId();
$this->entityRuntimeId = $in->getEntityRuntimeId();
$this->type = array_search($t = $in->getString(), self::LEGACY_ID_MAP_BC, true);
if($this->type === false){
throw new BadPacketException("Can't map ID $t to legacy ID");
}
$this->type = $in->getString();
$this->position = $in->getVector3();
$this->motion = $in->getVector3();
$this->pitch = $in->getLFloat();
@ -219,10 +216,7 @@ class AddActorPacket extends DataPacket implements ClientboundPacket{
protected function encodePayload(NetworkBinaryStream $out) : void{
$out->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$out->putEntityRuntimeId($this->entityRuntimeId);
if(!isset(self::LEGACY_ID_MAP_BC[$this->type])){
throw new \InvalidArgumentException("Unknown entity numeric ID $this->type");
}
$out->putString(self::LEGACY_ID_MAP_BC[$this->type]);
$out->putString($this->type);
$out->putVector3($this->position);
$out->putVector3Nullable($this->motion);
$out->putLFloat($this->pitch);

View File

@ -87,7 +87,6 @@ class PluginDescription{
/**
* @param string|mixed[] $yamlString
* @phpstan-param string|array<string, mixed> $yamlString
*/
public function __construct($yamlString){
$this->loadMap(!is_array($yamlString) ? yaml_parse($yamlString) : $yamlString);
@ -95,7 +94,6 @@ class PluginDescription{
/**
* @param mixed[] $plugin
* @phpstan-param array<string, mixed> $plugin
* @throws PluginException
*/
private function loadMap(array $plugin) : void{