mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-10 05:34:54 +00:00
DataPacket now encapsulates NetworkBinaryStream instead of extending it
ultimately the goal is to remove the NetworkBinaryStream crap entirely, but this change has most of the same benefits and is less disruptive.
This commit is contained in:
parent
7c2741e4f5
commit
ce0af8b040
@ -303,7 +303,7 @@ class NetworkSession{
|
||||
try{
|
||||
$this->handleDataPacket($pk);
|
||||
}catch(BadPacketException $e){
|
||||
$this->logger->debug($pk->getName() . ": " . base64_encode($pk->getBuffer()));
|
||||
$this->logger->debug($pk->getName() . ": " . base64_encode($pk->getBinaryStream()->getBuffer()));
|
||||
throw new BadPacketException("Error processing " . $pk->getName() . ": " . $e->getMessage(), 0, $e);
|
||||
}
|
||||
}
|
||||
@ -315,7 +315,7 @@ class NetworkSession{
|
||||
public function handleDataPacket(Packet $packet) : void{
|
||||
if(!($packet instanceof ServerboundPacket)){
|
||||
if($packet instanceof GarbageServerboundPacket){
|
||||
$this->logger->debug("Garbage serverbound " . $packet->getName() . ": " . base64_encode($packet->getBuffer()));
|
||||
$this->logger->debug("Garbage serverbound " . $packet->getName() . ": " . base64_encode($packet->getBinaryStream()->getBuffer()));
|
||||
return;
|
||||
}
|
||||
throw new BadPacketException("Unexpected non-serverbound packet");
|
||||
@ -326,15 +326,16 @@ class NetworkSession{
|
||||
|
||||
try{
|
||||
$packet->decode();
|
||||
if(!$packet->feof()){
|
||||
$remains = substr($packet->getBuffer(), $packet->getOffset());
|
||||
$stream = $packet->getBinaryStream();
|
||||
if(!$stream->feof()){
|
||||
$remains = substr($stream->getBuffer(), $stream->getOffset());
|
||||
$this->logger->debug("Still " . strlen($remains) . " bytes unread in " . $packet->getName() . ": " . bin2hex($remains));
|
||||
}
|
||||
|
||||
$ev = new DataPacketReceiveEvent($this, $packet);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled() and !$packet->handle($this->handler)){
|
||||
$this->logger->debug("Unhandled " . $packet->getName() . ": " . base64_encode($packet->getBuffer()));
|
||||
$this->logger->debug("Unhandled " . $packet->getName() . ": " . base64_encode($stream->getBuffer()));
|
||||
}
|
||||
}finally{
|
||||
$timings->stopTiming();
|
||||
|
@ -32,7 +32,7 @@ class PacketBatch extends NetworkBinaryStream{
|
||||
|
||||
public function putPacket(Packet $packet) : void{
|
||||
$packet->encode();
|
||||
$this->putString($packet->getBuffer());
|
||||
$this->putString($packet->getBinaryStream()->getBuffer());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,15 +98,15 @@ class ActorEventPacket extends DataPacket implements ClientboundPacket, Serverbo
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->event = $this->getByte();
|
||||
$this->data = $this->getVarInt();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->event = $this->buf->getByte();
|
||||
$this->data = $this->buf->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putByte($this->event);
|
||||
$this->putVarInt($this->data);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putByte($this->event);
|
||||
$this->buf->putVarInt($this->data);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -38,15 +38,15 @@ class ActorFallPacket extends DataPacket implements ServerboundPacket{
|
||||
public $isInVoid;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->fallDistance = $this->getLFloat();
|
||||
$this->isInVoid = $this->getBool();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->fallDistance = $this->buf->getLFloat();
|
||||
$this->isInVoid = $this->buf->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putLFloat($this->fallDistance);
|
||||
$this->putBool($this->isInVoid);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putLFloat($this->fallDistance);
|
||||
$this->buf->putBool($this->isInVoid);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -36,13 +36,13 @@ class ActorPickRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
public $hotbarSlot;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityUniqueId = $this->getLLong();
|
||||
$this->hotbarSlot = $this->getByte();
|
||||
$this->entityUniqueId = $this->buf->getLLong();
|
||||
$this->hotbarSlot = $this->buf->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putLLong($this->entityUniqueId);
|
||||
$this->putByte($this->hotbarSlot);
|
||||
$this->buf->putLLong($this->entityUniqueId);
|
||||
$this->buf->putByte($this->hotbarSlot);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -174,24 +174,24 @@ class AddActorPacket extends DataPacket implements ClientboundPacket{
|
||||
public $links = [];
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->type = array_search($t = $this->getString(), self::LEGACY_ID_MAP_BC, true);
|
||||
$this->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->type = array_search($t = $this->buf->getString(), self::LEGACY_ID_MAP_BC, true);
|
||||
if($this->type === false){
|
||||
throw new BadPacketException("Can't map ID $t to legacy ID");
|
||||
}
|
||||
$this->position = $this->getVector3();
|
||||
$this->motion = $this->getVector3();
|
||||
$this->pitch = $this->getLFloat();
|
||||
$this->yaw = $this->getLFloat();
|
||||
$this->headYaw = $this->getLFloat();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->motion = $this->buf->getVector3();
|
||||
$this->pitch = $this->buf->getLFloat();
|
||||
$this->yaw = $this->buf->getLFloat();
|
||||
$this->headYaw = $this->buf->getLFloat();
|
||||
|
||||
$attrCount = $this->getUnsignedVarInt();
|
||||
$attrCount = $this->buf->getUnsignedVarInt();
|
||||
for($i = 0; $i < $attrCount; ++$i){
|
||||
$id = $this->getString();
|
||||
$min = $this->getLFloat();
|
||||
$current = $this->getLFloat();
|
||||
$max = $this->getLFloat();
|
||||
$id = $this->buf->getString();
|
||||
$min = $this->buf->getLFloat();
|
||||
$current = $this->buf->getLFloat();
|
||||
$max = $this->buf->getLFloat();
|
||||
$attr = Attribute::get($id);
|
||||
|
||||
if($attr !== null){
|
||||
@ -208,38 +208,38 @@ class AddActorPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
}
|
||||
|
||||
$this->metadata = $this->getEntityMetadata();
|
||||
$linkCount = $this->getUnsignedVarInt();
|
||||
$this->metadata = $this->buf->getEntityMetadata();
|
||||
$linkCount = $this->buf->getUnsignedVarInt();
|
||||
for($i = 0; $i < $linkCount; ++$i){
|
||||
$this->links[] = $this->getEntityLink();
|
||||
$this->links[] = $this->buf->getEntityLink();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
if(!isset(self::LEGACY_ID_MAP_BC[$this->type])){
|
||||
throw new \InvalidArgumentException("Unknown entity numeric ID $this->type");
|
||||
}
|
||||
$this->putString(self::LEGACY_ID_MAP_BC[$this->type]);
|
||||
$this->putVector3($this->position);
|
||||
$this->putVector3Nullable($this->motion);
|
||||
$this->putLFloat($this->pitch);
|
||||
$this->putLFloat($this->yaw);
|
||||
$this->putLFloat($this->headYaw);
|
||||
$this->buf->putString(self::LEGACY_ID_MAP_BC[$this->type]);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putVector3Nullable($this->motion);
|
||||
$this->buf->putLFloat($this->pitch);
|
||||
$this->buf->putLFloat($this->yaw);
|
||||
$this->buf->putLFloat($this->headYaw);
|
||||
|
||||
$this->putUnsignedVarInt(count($this->attributes));
|
||||
$this->buf->putUnsignedVarInt(count($this->attributes));
|
||||
foreach($this->attributes as $attribute){
|
||||
$this->putString($attribute->getId());
|
||||
$this->putLFloat($attribute->getMinValue());
|
||||
$this->putLFloat($attribute->getValue());
|
||||
$this->putLFloat($attribute->getMaxValue());
|
||||
$this->buf->putString($attribute->getId());
|
||||
$this->buf->putLFloat($attribute->getMinValue());
|
||||
$this->buf->putLFloat($attribute->getValue());
|
||||
$this->buf->putLFloat($attribute->getMaxValue());
|
||||
}
|
||||
|
||||
$this->putEntityMetadata($this->metadata);
|
||||
$this->putUnsignedVarInt(count($this->links));
|
||||
$this->buf->putEntityMetadata($this->metadata);
|
||||
$this->buf->putUnsignedVarInt(count($this->links));
|
||||
foreach($this->links as $link){
|
||||
$this->putEntityLink($link);
|
||||
$this->buf->putEntityLink($link);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,11 +34,11 @@ class AddBehaviorTreePacket extends DataPacket implements ClientboundPacket{
|
||||
public $behaviorTreeJson;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->behaviorTreeJson = $this->getString();
|
||||
$this->behaviorTreeJson = $this->buf->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putString($this->behaviorTreeJson);
|
||||
$this->buf->putString($this->behaviorTreeJson);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -44,11 +44,11 @@ class AddEntityPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->uvarint1 = $this->getUnsignedVarInt();
|
||||
$this->uvarint1 = $this->buf->getUnsignedVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt($this->uvarint1);
|
||||
$this->buf->putUnsignedVarInt($this->uvarint1);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -52,23 +52,23 @@ class AddItemActorPacket extends DataPacket implements ClientboundPacket{
|
||||
public $isFromFishing = false;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->item = $this->getSlot();
|
||||
$this->position = $this->getVector3();
|
||||
$this->motion = $this->getVector3();
|
||||
$this->metadata = $this->getEntityMetadata();
|
||||
$this->isFromFishing = $this->getBool();
|
||||
$this->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->item = $this->buf->getSlot();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->motion = $this->buf->getVector3();
|
||||
$this->metadata = $this->buf->getEntityMetadata();
|
||||
$this->isFromFishing = $this->buf->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putSlot($this->item);
|
||||
$this->putVector3($this->position);
|
||||
$this->putVector3Nullable($this->motion);
|
||||
$this->putEntityMetadata($this->metadata);
|
||||
$this->putBool($this->isFromFishing);
|
||||
$this->buf->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putSlot($this->item);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putVector3Nullable($this->motion);
|
||||
$this->buf->putEntityMetadata($this->metadata);
|
||||
$this->buf->putBool($this->isFromFishing);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -43,19 +43,19 @@ class AddPaintingPacket extends DataPacket implements ClientboundPacket{
|
||||
public $title;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->position = $this->getVector3();
|
||||
$this->direction = $this->getVarInt();
|
||||
$this->title = $this->getString();
|
||||
$this->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->direction = $this->buf->getVarInt();
|
||||
$this->title = $this->buf->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putVector3($this->position);
|
||||
$this->putVarInt($this->direction);
|
||||
$this->putString($this->title);
|
||||
$this->buf->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putVarInt($this->direction);
|
||||
$this->buf->putString($this->title);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -88,65 +88,65 @@ class AddPlayerPacket extends DataPacket implements ClientboundPacket{
|
||||
public $buildPlatform = -1;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->uuid = $this->getUUID();
|
||||
$this->username = $this->getString();
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->platformChatId = $this->getString();
|
||||
$this->position = $this->getVector3();
|
||||
$this->motion = $this->getVector3();
|
||||
$this->pitch = $this->getLFloat();
|
||||
$this->yaw = $this->getLFloat();
|
||||
$this->headYaw = $this->getLFloat();
|
||||
$this->item = $this->getSlot();
|
||||
$this->metadata = $this->getEntityMetadata();
|
||||
$this->uuid = $this->buf->getUUID();
|
||||
$this->username = $this->buf->getString();
|
||||
$this->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->platformChatId = $this->buf->getString();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->motion = $this->buf->getVector3();
|
||||
$this->pitch = $this->buf->getLFloat();
|
||||
$this->yaw = $this->buf->getLFloat();
|
||||
$this->headYaw = $this->buf->getLFloat();
|
||||
$this->item = $this->buf->getSlot();
|
||||
$this->metadata = $this->buf->getEntityMetadata();
|
||||
|
||||
$this->uvarint1 = $this->getUnsignedVarInt();
|
||||
$this->uvarint2 = $this->getUnsignedVarInt();
|
||||
$this->uvarint3 = $this->getUnsignedVarInt();
|
||||
$this->uvarint4 = $this->getUnsignedVarInt();
|
||||
$this->uvarint5 = $this->getUnsignedVarInt();
|
||||
$this->uvarint1 = $this->buf->getUnsignedVarInt();
|
||||
$this->uvarint2 = $this->buf->getUnsignedVarInt();
|
||||
$this->uvarint3 = $this->buf->getUnsignedVarInt();
|
||||
$this->uvarint4 = $this->buf->getUnsignedVarInt();
|
||||
$this->uvarint5 = $this->buf->getUnsignedVarInt();
|
||||
|
||||
$this->long1 = $this->getLLong();
|
||||
$this->long1 = $this->buf->getLLong();
|
||||
|
||||
$linkCount = $this->getUnsignedVarInt();
|
||||
$linkCount = $this->buf->getUnsignedVarInt();
|
||||
for($i = 0; $i < $linkCount; ++$i){
|
||||
$this->links[$i] = $this->getEntityLink();
|
||||
$this->links[$i] = $this->buf->getEntityLink();
|
||||
}
|
||||
|
||||
$this->deviceId = $this->getString();
|
||||
$this->buildPlatform = $this->getLInt();
|
||||
$this->deviceId = $this->buf->getString();
|
||||
$this->buildPlatform = $this->buf->getLInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUUID($this->uuid);
|
||||
$this->putString($this->username);
|
||||
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putString($this->platformChatId);
|
||||
$this->putVector3($this->position);
|
||||
$this->putVector3Nullable($this->motion);
|
||||
$this->putLFloat($this->pitch);
|
||||
$this->putLFloat($this->yaw);
|
||||
$this->putLFloat($this->headYaw ?? $this->yaw);
|
||||
$this->putSlot($this->item);
|
||||
$this->putEntityMetadata($this->metadata);
|
||||
$this->buf->putUUID($this->uuid);
|
||||
$this->buf->putString($this->username);
|
||||
$this->buf->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putString($this->platformChatId);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putVector3Nullable($this->motion);
|
||||
$this->buf->putLFloat($this->pitch);
|
||||
$this->buf->putLFloat($this->yaw);
|
||||
$this->buf->putLFloat($this->headYaw ?? $this->yaw);
|
||||
$this->buf->putSlot($this->item);
|
||||
$this->buf->putEntityMetadata($this->metadata);
|
||||
|
||||
$this->putUnsignedVarInt($this->uvarint1);
|
||||
$this->putUnsignedVarInt($this->uvarint2);
|
||||
$this->putUnsignedVarInt($this->uvarint3);
|
||||
$this->putUnsignedVarInt($this->uvarint4);
|
||||
$this->putUnsignedVarInt($this->uvarint5);
|
||||
$this->buf->putUnsignedVarInt($this->uvarint1);
|
||||
$this->buf->putUnsignedVarInt($this->uvarint2);
|
||||
$this->buf->putUnsignedVarInt($this->uvarint3);
|
||||
$this->buf->putUnsignedVarInt($this->uvarint4);
|
||||
$this->buf->putUnsignedVarInt($this->uvarint5);
|
||||
|
||||
$this->putLLong($this->long1);
|
||||
$this->buf->putLLong($this->long1);
|
||||
|
||||
$this->putUnsignedVarInt(count($this->links));
|
||||
$this->buf->putUnsignedVarInt(count($this->links));
|
||||
foreach($this->links as $link){
|
||||
$this->putEntityLink($link);
|
||||
$this->buf->putEntityLink($link);
|
||||
}
|
||||
|
||||
$this->putString($this->deviceId);
|
||||
$this->putLInt($this->buildPlatform);
|
||||
$this->buf->putString($this->deviceId);
|
||||
$this->buf->putLInt($this->buildPlatform);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -76,21 +76,21 @@ class AdventureSettingsPacket extends DataPacket implements ClientboundPacket, S
|
||||
public $entityUniqueId; //This is a little-endian long, NOT a var-long. (WTF Mojang)
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->flags = $this->getUnsignedVarInt();
|
||||
$this->commandPermission = $this->getUnsignedVarInt();
|
||||
$this->flags2 = $this->getUnsignedVarInt();
|
||||
$this->playerPermission = $this->getUnsignedVarInt();
|
||||
$this->customFlags = $this->getUnsignedVarInt();
|
||||
$this->entityUniqueId = $this->getLLong();
|
||||
$this->flags = $this->buf->getUnsignedVarInt();
|
||||
$this->commandPermission = $this->buf->getUnsignedVarInt();
|
||||
$this->flags2 = $this->buf->getUnsignedVarInt();
|
||||
$this->playerPermission = $this->buf->getUnsignedVarInt();
|
||||
$this->customFlags = $this->buf->getUnsignedVarInt();
|
||||
$this->entityUniqueId = $this->buf->getLLong();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt($this->flags);
|
||||
$this->putUnsignedVarInt($this->commandPermission);
|
||||
$this->putUnsignedVarInt($this->flags2);
|
||||
$this->putUnsignedVarInt($this->playerPermission);
|
||||
$this->putUnsignedVarInt($this->customFlags);
|
||||
$this->putLLong($this->entityUniqueId);
|
||||
$this->buf->putUnsignedVarInt($this->flags);
|
||||
$this->buf->putUnsignedVarInt($this->commandPermission);
|
||||
$this->buf->putUnsignedVarInt($this->flags2);
|
||||
$this->buf->putUnsignedVarInt($this->playerPermission);
|
||||
$this->buf->putUnsignedVarInt($this->customFlags);
|
||||
$this->buf->putLLong($this->entityUniqueId);
|
||||
}
|
||||
|
||||
public function getFlag(int $flag) : bool{
|
||||
|
@ -58,18 +58,18 @@ class AnimatePacket extends DataPacket implements ClientboundPacket, Serverbound
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->action = $this->getVarInt();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->action = $this->buf->getVarInt();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
if(($this->action & 0x80) !== 0){
|
||||
$this->float = $this->getLFloat();
|
||||
$this->float = $this->buf->getLFloat();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putVarInt($this->action);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putVarInt($this->action);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
if(($this->action & 0x80) !== 0){
|
||||
$this->putLFloat($this->float);
|
||||
$this->buf->putLFloat($this->float);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,13 +63,13 @@ class AnvilDamagePacket extends DataPacket implements ServerboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->damageAmount = $this->getByte();
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->damageAmount = $this->buf->getByte();
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->damageAmount);
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putByte($this->damageAmount);
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -34,11 +34,11 @@ class AutomationClientConnectPacket extends DataPacket implements ClientboundPac
|
||||
public $serverUri;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->serverUri = $this->getString();
|
||||
$this->serverUri = $this->buf->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putString($this->serverUri);
|
||||
$this->buf->putString($this->serverUri);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -39,11 +39,11 @@ class AvailableActorIdentifiersPacket extends DataPacket implements ClientboundP
|
||||
public $namedtag;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->namedtag = $this->getRemaining();
|
||||
$this->namedtag = $this->buf->getRemaining();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->put(
|
||||
$this->buf->put(
|
||||
$this->namedtag ??
|
||||
self::$DEFAULT_NBT_CACHE ??
|
||||
(self::$DEFAULT_NBT_CACHE = file_get_contents(\pocketmine\RESOURCE_PATH . '/vanilla/entity_identifiers.nbt'))
|
||||
|
@ -114,34 +114,34 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
protected function decodePayload() : void{
|
||||
/** @var string[] $enumValues */
|
||||
$enumValues = [];
|
||||
for($i = 0, $enumValuesCount = $this->getUnsignedVarInt(); $i < $enumValuesCount; ++$i){
|
||||
$enumValues[] = $this->getString();
|
||||
for($i = 0, $enumValuesCount = $this->buf->getUnsignedVarInt(); $i < $enumValuesCount; ++$i){
|
||||
$enumValues[] = $this->buf->getString();
|
||||
}
|
||||
|
||||
/** @var string[] $postfixes */
|
||||
$postfixes = [];
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$postfixes[] = $this->getString();
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$postfixes[] = $this->buf->getString();
|
||||
}
|
||||
|
||||
/** @var CommandEnum[] $enums */
|
||||
$enums = [];
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$enums[] = $enum = $this->getEnum($enumValues);
|
||||
if(isset(self::HARDCODED_ENUM_NAMES[$enum->getName()])){
|
||||
$this->hardcodedEnums[] = $enum;
|
||||
}
|
||||
}
|
||||
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->commandData[] = $this->getCommandData($enums, $postfixes);
|
||||
}
|
||||
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->softEnums[] = $this->getSoftEnum();
|
||||
}
|
||||
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->enumConstraints[] = $this->getEnumConstraint($enums, $enumValues);
|
||||
}
|
||||
}
|
||||
@ -153,12 +153,12 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
protected function getEnum(array $enumValueList) : CommandEnum{
|
||||
$enumName = $this->getString();
|
||||
$enumName = $this->buf->getString();
|
||||
$enumValues = [];
|
||||
|
||||
$listSize = count($enumValueList);
|
||||
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$index = $this->getEnumValueIndex($listSize);
|
||||
if(!isset($enumValueList[$index])){
|
||||
throw new BadPacketException("Invalid enum value index $index");
|
||||
@ -174,12 +174,12 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
protected function getSoftEnum() : CommandEnum{
|
||||
$enumName = $this->getString();
|
||||
$enumName = $this->buf->getString();
|
||||
$enumValues = [];
|
||||
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
//Get the enum value from the initial pile of mess
|
||||
$enumValues[] = $this->getString();
|
||||
$enumValues[] = $this->buf->getString();
|
||||
}
|
||||
|
||||
return new CommandEnum($enumName, $enumValues);
|
||||
@ -189,10 +189,10 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
* @param int[] $enumValueMap
|
||||
*/
|
||||
protected function putEnum(CommandEnum $enum, array $enumValueMap) : void{
|
||||
$this->putString($enum->getName());
|
||||
$this->buf->putString($enum->getName());
|
||||
|
||||
$values = $enum->getValues();
|
||||
$this->putUnsignedVarInt(count($values));
|
||||
$this->buf->putUnsignedVarInt(count($values));
|
||||
$listSize = count($enumValueMap);
|
||||
foreach($values as $value){
|
||||
$index = $enumValueMap[$value] ?? -1;
|
||||
@ -204,12 +204,12 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function putSoftEnum(CommandEnum $enum) : void{
|
||||
$this->putString($enum->getName());
|
||||
$this->buf->putString($enum->getName());
|
||||
|
||||
$values = $enum->getValues();
|
||||
$this->putUnsignedVarInt(count($values));
|
||||
$this->buf->putUnsignedVarInt(count($values));
|
||||
foreach($values as $value){
|
||||
$this->putString($value);
|
||||
$this->buf->putString($value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,21 +218,21 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
*/
|
||||
protected function getEnumValueIndex(int $valueCount) : int{
|
||||
if($valueCount < 256){
|
||||
return $this->getByte();
|
||||
return $this->buf->getByte();
|
||||
}elseif($valueCount < 65536){
|
||||
return $this->getLShort();
|
||||
return $this->buf->getLShort();
|
||||
}else{
|
||||
return $this->getLInt();
|
||||
return $this->buf->getLInt();
|
||||
}
|
||||
}
|
||||
|
||||
protected function putEnumValueIndex(int $index, int $valueCount) : void{
|
||||
if($valueCount < 256){
|
||||
$this->putByte($index);
|
||||
$this->buf->putByte($index);
|
||||
}elseif($valueCount < 65536){
|
||||
$this->putLShort($index);
|
||||
$this->buf->putLShort($index);
|
||||
}else{
|
||||
$this->putLInt($index);
|
||||
$this->buf->putLInt($index);
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,11 +245,11 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
*/
|
||||
protected function getEnumConstraint(array $enums, array $enumValues) : CommandEnumConstraint{
|
||||
//wtf, what was wrong with an offset inside the enum? :(
|
||||
$valueIndex = $this->getLInt();
|
||||
$valueIndex = $this->buf->getLInt();
|
||||
if(!isset($enumValues[$valueIndex])){
|
||||
throw new BadPacketException("Enum constraint refers to unknown enum value index $valueIndex");
|
||||
}
|
||||
$enumIndex = $this->getLInt();
|
||||
$enumIndex = $this->buf->getLInt();
|
||||
if(!isset($enums[$enumIndex])){
|
||||
throw new BadPacketException("Enum constraint refers to unknown enum index $enumIndex");
|
||||
}
|
||||
@ -260,8 +260,8 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
$constraintIds = [];
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$constraintIds[] = $this->getByte();
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$constraintIds[] = $this->buf->getByte();
|
||||
}
|
||||
|
||||
return new CommandEnumConstraint($enum, $valueOffset, $constraintIds);
|
||||
@ -272,11 +272,11 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
* @param int[] $enumValueIndexes string value -> int index
|
||||
*/
|
||||
protected function putEnumConstraint(CommandEnumConstraint $constraint, array $enumIndexes, array $enumValueIndexes) : void{
|
||||
$this->putLInt($enumValueIndexes[$constraint->getAffectedValue()]);
|
||||
$this->putLInt($enumIndexes[$constraint->getEnum()->getName()]);
|
||||
$this->putUnsignedVarInt(count($constraint->getConstraints()));
|
||||
$this->buf->putLInt($enumValueIndexes[$constraint->getAffectedValue()]);
|
||||
$this->buf->putLInt($enumIndexes[$constraint->getEnum()->getName()]);
|
||||
$this->buf->putUnsignedVarInt(count($constraint->getConstraints()));
|
||||
foreach($constraint->getConstraints() as $v){
|
||||
$this->putByte($v);
|
||||
$this->buf->putByte($v);
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,21 +288,21 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
protected function getCommandData(array $enums, array $postfixes) : CommandData{
|
||||
$name = $this->getString();
|
||||
$description = $this->getString();
|
||||
$flags = $this->getByte();
|
||||
$permission = $this->getByte();
|
||||
$aliases = $enums[$this->getLInt()] ?? null;
|
||||
$name = $this->buf->getString();
|
||||
$description = $this->buf->getString();
|
||||
$flags = $this->buf->getByte();
|
||||
$permission = $this->buf->getByte();
|
||||
$aliases = $enums[$this->buf->getLInt()] ?? null;
|
||||
$overloads = [];
|
||||
|
||||
for($overloadIndex = 0, $overloadCount = $this->getUnsignedVarInt(); $overloadIndex < $overloadCount; ++$overloadIndex){
|
||||
for($overloadIndex = 0, $overloadCount = $this->buf->getUnsignedVarInt(); $overloadIndex < $overloadCount; ++$overloadIndex){
|
||||
$overloads[$overloadIndex] = [];
|
||||
for($paramIndex = 0, $paramCount = $this->getUnsignedVarInt(); $paramIndex < $paramCount; ++$paramIndex){
|
||||
for($paramIndex = 0, $paramCount = $this->buf->getUnsignedVarInt(); $paramIndex < $paramCount; ++$paramIndex){
|
||||
$parameter = new CommandParameter();
|
||||
$parameter->paramName = $this->getString();
|
||||
$parameter->paramType = $this->getLInt();
|
||||
$parameter->isOptional = $this->getBool();
|
||||
$parameter->flags = $this->getByte();
|
||||
$parameter->paramName = $this->buf->getString();
|
||||
$parameter->paramType = $this->buf->getLInt();
|
||||
$parameter->isOptional = $this->buf->getBool();
|
||||
$parameter->flags = $this->buf->getByte();
|
||||
|
||||
if(($parameter->paramType & self::ARG_FLAG_ENUM) !== 0){
|
||||
$index = ($parameter->paramType & 0xffff);
|
||||
@ -332,23 +332,23 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
* @param int[] $postfixIndexes
|
||||
*/
|
||||
protected function putCommandData(CommandData $data, array $enumIndexes, array $postfixIndexes) : void{
|
||||
$this->putString($data->name);
|
||||
$this->putString($data->description);
|
||||
$this->putByte($data->flags);
|
||||
$this->putByte($data->permission);
|
||||
$this->buf->putString($data->name);
|
||||
$this->buf->putString($data->description);
|
||||
$this->buf->putByte($data->flags);
|
||||
$this->buf->putByte($data->permission);
|
||||
|
||||
if($data->aliases !== null){
|
||||
$this->putLInt($enumIndexes[$data->aliases->getName()] ?? -1);
|
||||
$this->buf->putLInt($enumIndexes[$data->aliases->getName()] ?? -1);
|
||||
}else{
|
||||
$this->putLInt(-1);
|
||||
$this->buf->putLInt(-1);
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt(count($data->overloads));
|
||||
$this->buf->putUnsignedVarInt(count($data->overloads));
|
||||
foreach($data->overloads as $overload){
|
||||
/** @var CommandParameter[] $overload */
|
||||
$this->putUnsignedVarInt(count($overload));
|
||||
$this->buf->putUnsignedVarInt(count($overload));
|
||||
foreach($overload as $parameter){
|
||||
$this->putString($parameter->paramName);
|
||||
$this->buf->putString($parameter->paramName);
|
||||
|
||||
if($parameter->enum !== null){
|
||||
$type = self::ARG_FLAG_ENUM | self::ARG_FLAG_VALID | ($enumIndexes[$parameter->enum->getName()] ?? -1);
|
||||
@ -362,9 +362,9 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
$type = $parameter->paramType;
|
||||
}
|
||||
|
||||
$this->putLInt($type);
|
||||
$this->putBool($parameter->isOptional);
|
||||
$this->putByte($parameter->flags);
|
||||
$this->buf->putLInt($type);
|
||||
$this->buf->putBool($parameter->isOptional);
|
||||
$this->buf->putByte($parameter->flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -452,32 +452,32 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt(count($enumValueIndexes));
|
||||
$this->buf->putUnsignedVarInt(count($enumValueIndexes));
|
||||
foreach($enumValueIndexes as $enumValue => $index){
|
||||
$this->putString((string) $enumValue); //stupid PHP key casting D:
|
||||
$this->buf->putString((string) $enumValue); //stupid PHP key casting D:
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt(count($postfixIndexes));
|
||||
$this->buf->putUnsignedVarInt(count($postfixIndexes));
|
||||
foreach($postfixIndexes as $postfix => $index){
|
||||
$this->putString((string) $postfix); //stupid PHP key casting D:
|
||||
$this->buf->putString((string) $postfix); //stupid PHP key casting D:
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt(count($enums));
|
||||
$this->buf->putUnsignedVarInt(count($enums));
|
||||
foreach($enums as $enum){
|
||||
$this->putEnum($enum, $enumValueIndexes);
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt(count($this->commandData));
|
||||
$this->buf->putUnsignedVarInt(count($this->commandData));
|
||||
foreach($this->commandData as $data){
|
||||
$this->putCommandData($data, $enumIndexes, $postfixIndexes);
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt(count($this->softEnums));
|
||||
$this->buf->putUnsignedVarInt(count($this->softEnums));
|
||||
foreach($this->softEnums as $enum){
|
||||
$this->putSoftEnum($enum);
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt(count($this->enumConstraints));
|
||||
$this->buf->putUnsignedVarInt(count($this->enumConstraints));
|
||||
foreach($this->enumConstraints as $constraint){
|
||||
$this->putEnumConstraint($constraint, $enumIndexes, $enumValueIndexes);
|
||||
}
|
||||
|
@ -38,11 +38,11 @@ class BiomeDefinitionListPacket extends DataPacket implements ClientboundPacket{
|
||||
public $namedtag;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->namedtag = $this->getRemaining();
|
||||
$this->namedtag = $this->buf->getRemaining();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->put(
|
||||
$this->buf->put(
|
||||
$this->namedtag ??
|
||||
self::$DEFAULT_NBT_CACHE ??
|
||||
(self::$DEFAULT_NBT_CACHE = file_get_contents(\pocketmine\RESOURCE_PATH . '/vanilla/biome_definitions.nbt'))
|
||||
|
@ -47,13 +47,13 @@ class BlockActorDataPacket extends DataPacket implements ClientboundPacket, Serv
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->namedtag = $this->getRemaining();
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->namedtag = $this->buf->getRemaining();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->put($this->namedtag);
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->put($this->namedtag);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -53,15 +53,15 @@ class BlockEventPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->eventType = $this->getVarInt();
|
||||
$this->eventData = $this->getVarInt();
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->eventType = $this->buf->getVarInt();
|
||||
$this->eventData = $this->buf->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->eventType);
|
||||
$this->putVarInt($this->eventData);
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putVarInt($this->eventType);
|
||||
$this->buf->putVarInt($this->eventData);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -42,15 +42,15 @@ class BlockPickRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
public $hotbarSlot;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->getSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ);
|
||||
$this->addUserData = $this->getBool();
|
||||
$this->hotbarSlot = $this->getByte();
|
||||
$this->buf->getSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ);
|
||||
$this->addUserData = $this->buf->getBool();
|
||||
$this->hotbarSlot = $this->buf->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ);
|
||||
$this->putBool($this->addUserData);
|
||||
$this->putByte($this->hotbarSlot);
|
||||
$this->buf->putSignedBlockPosition($this->blockX, $this->blockY, $this->blockZ);
|
||||
$this->buf->putBool($this->addUserData);
|
||||
$this->buf->putByte($this->hotbarSlot);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -59,27 +59,27 @@ class BookEditPacket extends DataPacket implements ServerboundPacket{
|
||||
public $xuid;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->type = $this->getByte();
|
||||
$this->inventorySlot = $this->getByte();
|
||||
$this->type = $this->buf->getByte();
|
||||
$this->inventorySlot = $this->buf->getByte();
|
||||
|
||||
switch($this->type){
|
||||
case self::TYPE_REPLACE_PAGE:
|
||||
case self::TYPE_ADD_PAGE:
|
||||
$this->pageNumber = $this->getByte();
|
||||
$this->text = $this->getString();
|
||||
$this->photoName = $this->getString();
|
||||
$this->pageNumber = $this->buf->getByte();
|
||||
$this->text = $this->buf->getString();
|
||||
$this->photoName = $this->buf->getString();
|
||||
break;
|
||||
case self::TYPE_DELETE_PAGE:
|
||||
$this->pageNumber = $this->getByte();
|
||||
$this->pageNumber = $this->buf->getByte();
|
||||
break;
|
||||
case self::TYPE_SWAP_PAGES:
|
||||
$this->pageNumber = $this->getByte();
|
||||
$this->secondaryPageNumber = $this->getByte();
|
||||
$this->pageNumber = $this->buf->getByte();
|
||||
$this->secondaryPageNumber = $this->buf->getByte();
|
||||
break;
|
||||
case self::TYPE_SIGN_BOOK:
|
||||
$this->title = $this->getString();
|
||||
$this->author = $this->getString();
|
||||
$this->xuid = $this->getString();
|
||||
$this->title = $this->buf->getString();
|
||||
$this->author = $this->buf->getString();
|
||||
$this->xuid = $this->buf->getString();
|
||||
break;
|
||||
default:
|
||||
throw new BadPacketException("Unknown book edit type $this->type!");
|
||||
@ -87,27 +87,27 @@ class BookEditPacket extends DataPacket implements ServerboundPacket{
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->type);
|
||||
$this->putByte($this->inventorySlot);
|
||||
$this->buf->putByte($this->type);
|
||||
$this->buf->putByte($this->inventorySlot);
|
||||
|
||||
switch($this->type){
|
||||
case self::TYPE_REPLACE_PAGE:
|
||||
case self::TYPE_ADD_PAGE:
|
||||
$this->putByte($this->pageNumber);
|
||||
$this->putString($this->text);
|
||||
$this->putString($this->photoName);
|
||||
$this->buf->putByte($this->pageNumber);
|
||||
$this->buf->putString($this->text);
|
||||
$this->buf->putString($this->photoName);
|
||||
break;
|
||||
case self::TYPE_DELETE_PAGE:
|
||||
$this->putByte($this->pageNumber);
|
||||
$this->buf->putByte($this->pageNumber);
|
||||
break;
|
||||
case self::TYPE_SWAP_PAGES:
|
||||
$this->putByte($this->pageNumber);
|
||||
$this->putByte($this->secondaryPageNumber);
|
||||
$this->buf->putByte($this->pageNumber);
|
||||
$this->buf->putByte($this->secondaryPageNumber);
|
||||
break;
|
||||
case self::TYPE_SIGN_BOOK:
|
||||
$this->putString($this->title);
|
||||
$this->putString($this->author);
|
||||
$this->putString($this->xuid);
|
||||
$this->buf->putString($this->title);
|
||||
$this->buf->putString($this->author);
|
||||
$this->buf->putString($this->xuid);
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException("Unknown book edit type $this->type!");
|
||||
|
@ -119,29 +119,29 @@ class BossEventPacket extends DataPacket implements ClientboundPacket, Serverbou
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->bossEid = $this->getEntityUniqueId();
|
||||
$this->eventType = $this->getUnsignedVarInt();
|
||||
$this->bossEid = $this->buf->getEntityUniqueId();
|
||||
$this->eventType = $this->buf->getUnsignedVarInt();
|
||||
switch($this->eventType){
|
||||
case self::TYPE_REGISTER_PLAYER:
|
||||
case self::TYPE_UNREGISTER_PLAYER:
|
||||
$this->playerEid = $this->getEntityUniqueId();
|
||||
$this->playerEid = $this->buf->getEntityUniqueId();
|
||||
break;
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case self::TYPE_SHOW:
|
||||
$this->title = $this->getString();
|
||||
$this->healthPercent = $this->getLFloat();
|
||||
$this->title = $this->buf->getString();
|
||||
$this->healthPercent = $this->buf->getLFloat();
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case self::TYPE_UNKNOWN_6:
|
||||
$this->unknownShort = $this->getLShort();
|
||||
$this->unknownShort = $this->buf->getLShort();
|
||||
case self::TYPE_TEXTURE:
|
||||
$this->color = $this->getUnsignedVarInt();
|
||||
$this->overlay = $this->getUnsignedVarInt();
|
||||
$this->color = $this->buf->getUnsignedVarInt();
|
||||
$this->overlay = $this->buf->getUnsignedVarInt();
|
||||
break;
|
||||
case self::TYPE_HEALTH_PERCENT:
|
||||
$this->healthPercent = $this->getLFloat();
|
||||
$this->healthPercent = $this->buf->getLFloat();
|
||||
break;
|
||||
case self::TYPE_TITLE:
|
||||
$this->title = $this->getString();
|
||||
$this->title = $this->buf->getString();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -149,29 +149,29 @@ class BossEventPacket extends DataPacket implements ClientboundPacket, Serverbou
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityUniqueId($this->bossEid);
|
||||
$this->putUnsignedVarInt($this->eventType);
|
||||
$this->buf->putEntityUniqueId($this->bossEid);
|
||||
$this->buf->putUnsignedVarInt($this->eventType);
|
||||
switch($this->eventType){
|
||||
case self::TYPE_REGISTER_PLAYER:
|
||||
case self::TYPE_UNREGISTER_PLAYER:
|
||||
$this->putEntityUniqueId($this->playerEid);
|
||||
$this->buf->putEntityUniqueId($this->playerEid);
|
||||
break;
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case self::TYPE_SHOW:
|
||||
$this->putString($this->title);
|
||||
$this->putLFloat($this->healthPercent);
|
||||
$this->buf->putString($this->title);
|
||||
$this->buf->putLFloat($this->healthPercent);
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case self::TYPE_UNKNOWN_6:
|
||||
$this->putLShort($this->unknownShort);
|
||||
$this->buf->putLShort($this->unknownShort);
|
||||
case self::TYPE_TEXTURE:
|
||||
$this->putUnsignedVarInt($this->color);
|
||||
$this->putUnsignedVarInt($this->overlay);
|
||||
$this->buf->putUnsignedVarInt($this->color);
|
||||
$this->buf->putUnsignedVarInt($this->overlay);
|
||||
break;
|
||||
case self::TYPE_HEALTH_PERCENT:
|
||||
$this->putLFloat($this->healthPercent);
|
||||
$this->buf->putLFloat($this->healthPercent);
|
||||
break;
|
||||
case self::TYPE_TITLE:
|
||||
$this->putString($this->title);
|
||||
$this->buf->putString($this->title);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -36,13 +36,13 @@ class CameraPacket extends DataPacket implements ClientboundPacket{
|
||||
public $playerUniqueId;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->cameraUniqueId = $this->getEntityUniqueId();
|
||||
$this->playerUniqueId = $this->getEntityUniqueId();
|
||||
$this->cameraUniqueId = $this->buf->getEntityUniqueId();
|
||||
$this->playerUniqueId = $this->buf->getEntityUniqueId();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityUniqueId($this->cameraUniqueId);
|
||||
$this->putEntityUniqueId($this->playerUniqueId);
|
||||
$this->buf->putEntityUniqueId($this->cameraUniqueId);
|
||||
$this->buf->putEntityUniqueId($this->playerUniqueId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -39,15 +39,15 @@ class ChangeDimensionPacket extends DataPacket implements ClientboundPacket{
|
||||
public $respawn = false;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->dimension = $this->getVarInt();
|
||||
$this->position = $this->getVector3();
|
||||
$this->respawn = $this->getBool();
|
||||
$this->dimension = $this->buf->getVarInt();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->respawn = $this->buf->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putVarInt($this->dimension);
|
||||
$this->putVector3($this->position);
|
||||
$this->putBool($this->respawn);
|
||||
$this->buf->putVarInt($this->dimension);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putBool($this->respawn);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -40,11 +40,11 @@ class ChunkRadiusUpdatedPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->radius = $this->getVarInt();
|
||||
$this->radius = $this->buf->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putVarInt($this->radius);
|
||||
$this->buf->putVarInt($this->radius);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -66,24 +66,24 @@ class ClientCacheBlobStatusPacket extends DataPacket implements ServerboundPacke
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$hitCount = $this->getUnsignedVarInt();
|
||||
$missCount = $this->getUnsignedVarInt();
|
||||
$hitCount = $this->buf->getUnsignedVarInt();
|
||||
$missCount = $this->buf->getUnsignedVarInt();
|
||||
for($i = 0; $i < $hitCount; ++$i){
|
||||
$this->hitHashes[] = $this->getLLong();
|
||||
$this->hitHashes[] = $this->buf->getLLong();
|
||||
}
|
||||
for($i = 0; $i < $missCount; ++$i){
|
||||
$this->missHashes[] = $this->getLLong();
|
||||
$this->missHashes[] = $this->buf->getLLong();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt(count($this->hitHashes));
|
||||
$this->putUnsignedVarInt(count($this->missHashes));
|
||||
$this->buf->putUnsignedVarInt(count($this->hitHashes));
|
||||
$this->buf->putUnsignedVarInt(count($this->missHashes));
|
||||
foreach($this->hitHashes as $hash){
|
||||
$this->putLLong($hash);
|
||||
$this->buf->putLLong($hash);
|
||||
}
|
||||
foreach($this->missHashes as $hash){
|
||||
$this->putLLong($hash);
|
||||
$this->buf->putLLong($hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,18 +55,18 @@ class ClientCacheMissResponsePacket extends DataPacket implements ClientboundPac
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$hash = $this->getLLong();
|
||||
$payload = $this->getString();
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$hash = $this->buf->getLLong();
|
||||
$payload = $this->buf->getString();
|
||||
$this->blobs[] = new ChunkCacheBlob($hash, $payload);
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt(count($this->blobs));
|
||||
$this->buf->putUnsignedVarInt(count($this->blobs));
|
||||
foreach($this->blobs as $blob){
|
||||
$this->putLLong($blob->getHash());
|
||||
$this->putString($blob->getPayload());
|
||||
$this->buf->putLLong($blob->getHash());
|
||||
$this->buf->putString($blob->getPayload());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,11 +44,11 @@ class ClientCacheStatusPacket extends DataPacket implements ServerboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->enabled = $this->getBool();
|
||||
$this->enabled = $this->buf->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putBool($this->enabled);
|
||||
$this->buf->putBool($this->enabled);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -73,68 +73,68 @@ class ClientboundMapItemDataPacket extends DataPacket implements ClientboundPack
|
||||
public $colors = [];
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->mapId = $this->getEntityUniqueId();
|
||||
$this->type = $this->getUnsignedVarInt();
|
||||
$this->dimensionId = $this->getByte();
|
||||
$this->isLocked = $this->getBool();
|
||||
$this->mapId = $this->buf->getEntityUniqueId();
|
||||
$this->type = $this->buf->getUnsignedVarInt();
|
||||
$this->dimensionId = $this->buf->getByte();
|
||||
$this->isLocked = $this->buf->getBool();
|
||||
|
||||
if(($this->type & 0x08) !== 0){
|
||||
$count = $this->getUnsignedVarInt();
|
||||
$count = $this->buf->getUnsignedVarInt();
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$this->eids[] = $this->getEntityUniqueId();
|
||||
$this->eids[] = $this->buf->getEntityUniqueId();
|
||||
}
|
||||
}
|
||||
|
||||
if(($this->type & (0x08 | self::BITFLAG_DECORATION_UPDATE | self::BITFLAG_TEXTURE_UPDATE)) !== 0){ //Decoration bitflag or colour bitflag
|
||||
$this->scale = $this->getByte();
|
||||
$this->scale = $this->buf->getByte();
|
||||
}
|
||||
|
||||
if(($this->type & self::BITFLAG_DECORATION_UPDATE) !== 0){
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$object = new MapTrackedObject();
|
||||
$object->type = $this->getLInt();
|
||||
$object->type = $this->buf->getLInt();
|
||||
if($object->type === MapTrackedObject::TYPE_BLOCK){
|
||||
$this->getBlockPosition($object->x, $object->y, $object->z);
|
||||
$this->buf->getBlockPosition($object->x, $object->y, $object->z);
|
||||
}elseif($object->type === MapTrackedObject::TYPE_ENTITY){
|
||||
$object->entityUniqueId = $this->getEntityUniqueId();
|
||||
$object->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
}else{
|
||||
throw new BadPacketException("Unknown map object type $object->type");
|
||||
}
|
||||
$this->trackedEntities[] = $object;
|
||||
}
|
||||
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$icon = $this->getByte();
|
||||
$rotation = $this->getByte();
|
||||
$xOffset = $this->getByte();
|
||||
$yOffset = $this->getByte();
|
||||
$label = $this->getString();
|
||||
$color = Color::fromRGBA(Binary::flipIntEndianness($this->getUnsignedVarInt()));
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$icon = $this->buf->getByte();
|
||||
$rotation = $this->buf->getByte();
|
||||
$xOffset = $this->buf->getByte();
|
||||
$yOffset = $this->buf->getByte();
|
||||
$label = $this->buf->getString();
|
||||
$color = Color::fromRGBA(Binary::flipIntEndianness($this->buf->getUnsignedVarInt()));
|
||||
$this->decorations[] = new MapDecoration($icon, $rotation, $xOffset, $yOffset, $label, $color);
|
||||
}
|
||||
}
|
||||
|
||||
if(($this->type & self::BITFLAG_TEXTURE_UPDATE) !== 0){
|
||||
$this->width = $this->getVarInt();
|
||||
$this->height = $this->getVarInt();
|
||||
$this->xOffset = $this->getVarInt();
|
||||
$this->yOffset = $this->getVarInt();
|
||||
$this->width = $this->buf->getVarInt();
|
||||
$this->height = $this->buf->getVarInt();
|
||||
$this->xOffset = $this->buf->getVarInt();
|
||||
$this->yOffset = $this->buf->getVarInt();
|
||||
|
||||
$count = $this->getUnsignedVarInt();
|
||||
$count = $this->buf->getUnsignedVarInt();
|
||||
if($count !== $this->width * $this->height){
|
||||
throw new BadPacketException("Expected colour count of " . ($this->height * $this->width) . " (height $this->height * width $this->width), got $count");
|
||||
}
|
||||
|
||||
for($y = 0; $y < $this->height; ++$y){
|
||||
for($x = 0; $x < $this->width; ++$x){
|
||||
$this->colors[$y][$x] = Color::fromRGBA(Binary::flipIntEndianness($this->getUnsignedVarInt()));
|
||||
$this->colors[$y][$x] = Color::fromRGBA(Binary::flipIntEndianness($this->buf->getUnsignedVarInt()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityUniqueId($this->mapId);
|
||||
$this->buf->putEntityUniqueId($this->mapId);
|
||||
|
||||
$type = 0;
|
||||
if(($eidsCount = count($this->eids)) > 0){
|
||||
@ -147,57 +147,57 @@ class ClientboundMapItemDataPacket extends DataPacket implements ClientboundPack
|
||||
$type |= self::BITFLAG_TEXTURE_UPDATE;
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt($type);
|
||||
$this->putByte($this->dimensionId);
|
||||
$this->putBool($this->isLocked);
|
||||
$this->buf->putUnsignedVarInt($type);
|
||||
$this->buf->putByte($this->dimensionId);
|
||||
$this->buf->putBool($this->isLocked);
|
||||
|
||||
if(($type & 0x08) !== 0){ //TODO: find out what these are for
|
||||
$this->putUnsignedVarInt($eidsCount);
|
||||
$this->buf->putUnsignedVarInt($eidsCount);
|
||||
foreach($this->eids as $eid){
|
||||
$this->putEntityUniqueId($eid);
|
||||
$this->buf->putEntityUniqueId($eid);
|
||||
}
|
||||
}
|
||||
|
||||
if(($type & (0x08 | self::BITFLAG_TEXTURE_UPDATE | self::BITFLAG_DECORATION_UPDATE)) !== 0){
|
||||
$this->putByte($this->scale);
|
||||
$this->buf->putByte($this->scale);
|
||||
}
|
||||
|
||||
if(($type & self::BITFLAG_DECORATION_UPDATE) !== 0){
|
||||
$this->putUnsignedVarInt(count($this->trackedEntities));
|
||||
$this->buf->putUnsignedVarInt(count($this->trackedEntities));
|
||||
foreach($this->trackedEntities as $object){
|
||||
$this->putLInt($object->type);
|
||||
$this->buf->putLInt($object->type);
|
||||
if($object->type === MapTrackedObject::TYPE_BLOCK){
|
||||
$this->putBlockPosition($object->x, $object->y, $object->z);
|
||||
$this->buf->putBlockPosition($object->x, $object->y, $object->z);
|
||||
}elseif($object->type === MapTrackedObject::TYPE_ENTITY){
|
||||
$this->putEntityUniqueId($object->entityUniqueId);
|
||||
$this->buf->putEntityUniqueId($object->entityUniqueId);
|
||||
}else{
|
||||
throw new \InvalidArgumentException("Unknown map object type $object->type");
|
||||
}
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt($decorationCount);
|
||||
$this->buf->putUnsignedVarInt($decorationCount);
|
||||
foreach($this->decorations as $decoration){
|
||||
$this->putByte($decoration->getIcon());
|
||||
$this->putByte($decoration->getRotation());
|
||||
$this->putByte($decoration->getXOffset());
|
||||
$this->putByte($decoration->getYOffset());
|
||||
$this->putString($decoration->getLabel());
|
||||
$this->putUnsignedVarInt(Binary::flipIntEndianness($decoration->getColor()->toRGBA()));
|
||||
$this->buf->putByte($decoration->getIcon());
|
||||
$this->buf->putByte($decoration->getRotation());
|
||||
$this->buf->putByte($decoration->getXOffset());
|
||||
$this->buf->putByte($decoration->getYOffset());
|
||||
$this->buf->putString($decoration->getLabel());
|
||||
$this->buf->putUnsignedVarInt(Binary::flipIntEndianness($decoration->getColor()->toRGBA()));
|
||||
}
|
||||
}
|
||||
|
||||
if(($type & self::BITFLAG_TEXTURE_UPDATE) !== 0){
|
||||
$this->putVarInt($this->width);
|
||||
$this->putVarInt($this->height);
|
||||
$this->putVarInt($this->xOffset);
|
||||
$this->putVarInt($this->yOffset);
|
||||
$this->buf->putVarInt($this->width);
|
||||
$this->buf->putVarInt($this->height);
|
||||
$this->buf->putVarInt($this->xOffset);
|
||||
$this->buf->putVarInt($this->yOffset);
|
||||
|
||||
$this->putUnsignedVarInt($this->width * $this->height); //list count, but we handle it as a 2D array... thanks for the confusion mojang
|
||||
$this->buf->putUnsignedVarInt($this->width * $this->height); //list count, but we handle it as a 2D array... thanks for the confusion mojang
|
||||
|
||||
for($y = 0; $y < $this->height; ++$y){
|
||||
for($x = 0; $x < $this->width; ++$x){
|
||||
//if mojang had any sense this would just be a regular LE int
|
||||
$this->putUnsignedVarInt(Binary::flipIntEndianness($this->colors[$y][$x]->toRGBA()));
|
||||
$this->buf->putUnsignedVarInt(Binary::flipIntEndianness($this->colors[$y][$x]->toRGBA()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,46 +63,46 @@ class CommandBlockUpdatePacket extends DataPacket implements ServerboundPacket{
|
||||
public $executeOnFirstTick;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->isBlock = $this->getBool();
|
||||
$this->isBlock = $this->buf->getBool();
|
||||
|
||||
if($this->isBlock){
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->commandBlockMode = $this->getUnsignedVarInt();
|
||||
$this->isRedstoneMode = $this->getBool();
|
||||
$this->isConditional = $this->getBool();
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->commandBlockMode = $this->buf->getUnsignedVarInt();
|
||||
$this->isRedstoneMode = $this->buf->getBool();
|
||||
$this->isConditional = $this->buf->getBool();
|
||||
}else{
|
||||
//Minecart with command block
|
||||
$this->minecartEid = $this->getEntityRuntimeId();
|
||||
$this->minecartEid = $this->buf->getEntityRuntimeId();
|
||||
}
|
||||
|
||||
$this->command = $this->getString();
|
||||
$this->lastOutput = $this->getString();
|
||||
$this->name = $this->getString();
|
||||
$this->command = $this->buf->getString();
|
||||
$this->lastOutput = $this->buf->getString();
|
||||
$this->name = $this->buf->getString();
|
||||
|
||||
$this->shouldTrackOutput = $this->getBool();
|
||||
$this->tickDelay = $this->getLInt();
|
||||
$this->executeOnFirstTick = $this->getBool();
|
||||
$this->shouldTrackOutput = $this->buf->getBool();
|
||||
$this->tickDelay = $this->buf->getLInt();
|
||||
$this->executeOnFirstTick = $this->buf->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putBool($this->isBlock);
|
||||
$this->buf->putBool($this->isBlock);
|
||||
|
||||
if($this->isBlock){
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putUnsignedVarInt($this->commandBlockMode);
|
||||
$this->putBool($this->isRedstoneMode);
|
||||
$this->putBool($this->isConditional);
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putUnsignedVarInt($this->commandBlockMode);
|
||||
$this->buf->putBool($this->isRedstoneMode);
|
||||
$this->buf->putBool($this->isConditional);
|
||||
}else{
|
||||
$this->putEntityRuntimeId($this->minecartEid);
|
||||
$this->buf->putEntityRuntimeId($this->minecartEid);
|
||||
}
|
||||
|
||||
$this->putString($this->command);
|
||||
$this->putString($this->lastOutput);
|
||||
$this->putString($this->name);
|
||||
$this->buf->putString($this->command);
|
||||
$this->buf->putString($this->lastOutput);
|
||||
$this->buf->putString($this->name);
|
||||
|
||||
$this->putBool($this->shouldTrackOutput);
|
||||
$this->putLInt($this->tickDelay);
|
||||
$this->putBool($this->executeOnFirstTick);
|
||||
$this->buf->putBool($this->shouldTrackOutput);
|
||||
$this->buf->putLInt($this->tickDelay);
|
||||
$this->buf->putBool($this->executeOnFirstTick);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -46,16 +46,16 @@ class CommandOutputPacket extends DataPacket implements ClientboundPacket{
|
||||
public $unknownString;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->originData = $this->getCommandOriginData();
|
||||
$this->outputType = $this->getByte();
|
||||
$this->successCount = $this->getUnsignedVarInt();
|
||||
$this->originData = $this->buf->getCommandOriginData();
|
||||
$this->outputType = $this->buf->getByte();
|
||||
$this->successCount = $this->buf->getUnsignedVarInt();
|
||||
|
||||
for($i = 0, $size = $this->getUnsignedVarInt(); $i < $size; ++$i){
|
||||
for($i = 0, $size = $this->buf->getUnsignedVarInt(); $i < $size; ++$i){
|
||||
$this->messages[] = $this->getCommandMessage();
|
||||
}
|
||||
|
||||
if($this->outputType === 4){
|
||||
$this->unknownString = $this->getString();
|
||||
$this->unknownString = $this->buf->getString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,38 +65,38 @@ class CommandOutputPacket extends DataPacket implements ClientboundPacket{
|
||||
protected function getCommandMessage() : CommandOutputMessage{
|
||||
$message = new CommandOutputMessage();
|
||||
|
||||
$message->isInternal = $this->getBool();
|
||||
$message->messageId = $this->getString();
|
||||
$message->isInternal = $this->buf->getBool();
|
||||
$message->messageId = $this->buf->getString();
|
||||
|
||||
for($i = 0, $size = $this->getUnsignedVarInt(); $i < $size; ++$i){
|
||||
$message->parameters[] = $this->getString();
|
||||
for($i = 0, $size = $this->buf->getUnsignedVarInt(); $i < $size; ++$i){
|
||||
$message->parameters[] = $this->buf->getString();
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putCommandOriginData($this->originData);
|
||||
$this->putByte($this->outputType);
|
||||
$this->putUnsignedVarInt($this->successCount);
|
||||
$this->buf->putCommandOriginData($this->originData);
|
||||
$this->buf->putByte($this->outputType);
|
||||
$this->buf->putUnsignedVarInt($this->successCount);
|
||||
|
||||
$this->putUnsignedVarInt(count($this->messages));
|
||||
$this->buf->putUnsignedVarInt(count($this->messages));
|
||||
foreach($this->messages as $message){
|
||||
$this->putCommandMessage($message);
|
||||
}
|
||||
|
||||
if($this->outputType === 4){
|
||||
$this->putString($this->unknownString);
|
||||
$this->buf->putString($this->unknownString);
|
||||
}
|
||||
}
|
||||
|
||||
protected function putCommandMessage(CommandOutputMessage $message) : void{
|
||||
$this->putBool($message->isInternal);
|
||||
$this->putString($message->messageId);
|
||||
$this->buf->putBool($message->isInternal);
|
||||
$this->buf->putString($message->messageId);
|
||||
|
||||
$this->putUnsignedVarInt(count($message->parameters));
|
||||
$this->buf->putUnsignedVarInt(count($message->parameters));
|
||||
foreach($message->parameters as $parameter){
|
||||
$this->putString($parameter);
|
||||
$this->buf->putString($parameter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,15 +39,15 @@ class CommandRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
public $isInternal;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->command = $this->getString();
|
||||
$this->originData = $this->getCommandOriginData();
|
||||
$this->isInternal = $this->getBool();
|
||||
$this->command = $this->buf->getString();
|
||||
$this->originData = $this->buf->getCommandOriginData();
|
||||
$this->isInternal = $this->buf->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putString($this->command);
|
||||
$this->putCommandOriginData($this->originData);
|
||||
$this->putBool($this->isInternal);
|
||||
$this->buf->putString($this->command);
|
||||
$this->buf->putCommandOriginData($this->originData);
|
||||
$this->buf->putBool($this->isInternal);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -53,13 +53,13 @@ class CompletedUsingItemPacket extends DataPacket implements ClientboundPacket{
|
||||
public $action;
|
||||
|
||||
public function decodePayload() : void{
|
||||
$this->itemId = $this->getShort();
|
||||
$this->action = $this->getLInt();
|
||||
$this->itemId = $this->buf->getShort();
|
||||
$this->action = $this->buf->getLInt();
|
||||
}
|
||||
|
||||
public function encodePayload() : void{
|
||||
$this->putShort($this->itemId);
|
||||
$this->putLInt($this->action);
|
||||
$this->buf->putShort($this->itemId);
|
||||
$this->buf->putLInt($this->action);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -40,11 +40,11 @@ class ContainerClosePacket extends DataPacket implements ClientboundPacket, Serv
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->windowId = $this->getByte();
|
||||
$this->windowId = $this->buf->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->windowId);
|
||||
$this->buf->putByte($this->windowId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -66,17 +66,17 @@ class ContainerOpenPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->windowId = $this->getByte();
|
||||
$this->type = $this->getByte();
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->windowId = $this->buf->getByte();
|
||||
$this->type = $this->buf->getByte();
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->windowId);
|
||||
$this->putByte($this->type);
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putEntityUniqueId($this->entityUniqueId);
|
||||
$this->buf->putByte($this->windowId);
|
||||
$this->buf->putByte($this->type);
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putEntityUniqueId($this->entityUniqueId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -56,15 +56,15 @@ class ContainerSetDataPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->windowId = $this->getByte();
|
||||
$this->property = $this->getVarInt();
|
||||
$this->value = $this->getVarInt();
|
||||
$this->windowId = $this->buf->getByte();
|
||||
$this->property = $this->buf->getVarInt();
|
||||
$this->value = $this->buf->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->windowId);
|
||||
$this->putVarInt($this->property);
|
||||
$this->putVarInt($this->value);
|
||||
$this->buf->putByte($this->windowId);
|
||||
$this->buf->putVarInt($this->property);
|
||||
$this->buf->putVarInt($this->value);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -67,60 +67,60 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->decodedEntries = [];
|
||||
$recipeCount = $this->getUnsignedVarInt();
|
||||
$recipeCount = $this->buf->getUnsignedVarInt();
|
||||
for($i = 0; $i < $recipeCount; ++$i){
|
||||
$entry = [];
|
||||
$entry["type"] = $recipeType = $this->getVarInt();
|
||||
$entry["type"] = $recipeType = $this->buf->getVarInt();
|
||||
|
||||
switch($recipeType){
|
||||
case self::ENTRY_SHAPELESS:
|
||||
case self::ENTRY_SHULKER_BOX:
|
||||
case self::ENTRY_SHAPELESS_CHEMISTRY:
|
||||
$entry["recipe_id"] = $this->getString();
|
||||
$ingredientCount = $this->getUnsignedVarInt();
|
||||
$entry["recipe_id"] = $this->buf->getString();
|
||||
$ingredientCount = $this->buf->getUnsignedVarInt();
|
||||
/** @var Item */
|
||||
$entry["input"] = [];
|
||||
for($j = 0; $j < $ingredientCount; ++$j){
|
||||
$entry["input"][] = $in = $this->getRecipeIngredient();
|
||||
$entry["input"][] = $in = $this->buf->getRecipeIngredient();
|
||||
$in->setCount(1); //TODO HACK: they send a useless count field which breaks the PM crafting system because it isn't always 1
|
||||
}
|
||||
$resultCount = $this->getUnsignedVarInt();
|
||||
$resultCount = $this->buf->getUnsignedVarInt();
|
||||
$entry["output"] = [];
|
||||
for($k = 0; $k < $resultCount; ++$k){
|
||||
$entry["output"][] = $this->getSlot();
|
||||
$entry["output"][] = $this->buf->getSlot();
|
||||
}
|
||||
$entry["uuid"] = $this->getUUID()->toString();
|
||||
$entry["block"] = $this->getString();
|
||||
$entry["priority"] = $this->getVarInt();
|
||||
$entry["uuid"] = $this->buf->getUUID()->toString();
|
||||
$entry["block"] = $this->buf->getString();
|
||||
$entry["priority"] = $this->buf->getVarInt();
|
||||
|
||||
break;
|
||||
case self::ENTRY_SHAPED:
|
||||
case self::ENTRY_SHAPED_CHEMISTRY:
|
||||
$entry["recipe_id"] = $this->getString();
|
||||
$entry["width"] = $this->getVarInt();
|
||||
$entry["height"] = $this->getVarInt();
|
||||
$entry["recipe_id"] = $this->buf->getString();
|
||||
$entry["width"] = $this->buf->getVarInt();
|
||||
$entry["height"] = $this->buf->getVarInt();
|
||||
$count = $entry["width"] * $entry["height"];
|
||||
$entry["input"] = [];
|
||||
for($j = 0; $j < $count; ++$j){
|
||||
$entry["input"][] = $in = $this->getRecipeIngredient();
|
||||
$entry["input"][] = $in = $this->buf->getRecipeIngredient();
|
||||
$in->setCount(1); //TODO HACK: they send a useless count field which breaks the PM crafting system
|
||||
}
|
||||
$resultCount = $this->getUnsignedVarInt();
|
||||
$resultCount = $this->buf->getUnsignedVarInt();
|
||||
$entry["output"] = [];
|
||||
for($k = 0; $k < $resultCount; ++$k){
|
||||
$entry["output"][] = $this->getSlot();
|
||||
$entry["output"][] = $this->buf->getSlot();
|
||||
}
|
||||
$entry["uuid"] = $this->getUUID()->toString();
|
||||
$entry["block"] = $this->getString();
|
||||
$entry["priority"] = $this->getVarInt();
|
||||
$entry["uuid"] = $this->buf->getUUID()->toString();
|
||||
$entry["block"] = $this->buf->getString();
|
||||
$entry["priority"] = $this->buf->getVarInt();
|
||||
|
||||
break;
|
||||
case self::ENTRY_FURNACE:
|
||||
case self::ENTRY_FURNACE_DATA:
|
||||
$inputId = $this->getVarInt();
|
||||
$inputId = $this->buf->getVarInt();
|
||||
$inputData = -1;
|
||||
if($recipeType === self::ENTRY_FURNACE_DATA){
|
||||
$inputData = $this->getVarInt();
|
||||
$inputData = $this->buf->getVarInt();
|
||||
if($inputData === 0x7fff){
|
||||
$inputData = -1;
|
||||
}
|
||||
@ -130,34 +130,34 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
|
||||
}catch(\InvalidArgumentException $e){
|
||||
throw new BadPacketException($e->getMessage(), 0, $e);
|
||||
}
|
||||
$entry["output"] = $out = $this->getSlot();
|
||||
$entry["output"] = $out = $this->buf->getSlot();
|
||||
if($out->getMeta() === 0x7fff){
|
||||
$entry["output"] = ItemFactory::get($out->getId(), 0); //TODO HACK: some 1.12 furnace recipe outputs have wildcard damage values
|
||||
}
|
||||
$entry["block"] = $this->getString();
|
||||
$entry["block"] = $this->buf->getString();
|
||||
|
||||
break;
|
||||
case self::ENTRY_MULTI:
|
||||
$entry["uuid"] = $this->getUUID()->toString();
|
||||
$entry["uuid"] = $this->buf->getUUID()->toString();
|
||||
break;
|
||||
default:
|
||||
throw new BadPacketException("Unhandled recipe type $recipeType!"); //do not continue attempting to decode
|
||||
}
|
||||
$this->decodedEntries[] = $entry;
|
||||
}
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$input = $this->getVarInt();
|
||||
$ingredient = $this->getVarInt();
|
||||
$output = $this->getVarInt();
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$input = $this->buf->getVarInt();
|
||||
$ingredient = $this->buf->getVarInt();
|
||||
$output = $this->buf->getVarInt();
|
||||
$this->potionTypeRecipes[] = new PotionTypeRecipe($input, $ingredient, $output);
|
||||
}
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$input = $this->getVarInt();
|
||||
$ingredient = $this->getVarInt();
|
||||
$output = $this->getVarInt();
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$input = $this->buf->getVarInt();
|
||||
$ingredient = $this->buf->getVarInt();
|
||||
$output = $this->buf->getVarInt();
|
||||
$this->potionContainerRecipes[] = new PotionContainerChangeRecipe($input, $ingredient, $output);
|
||||
}
|
||||
$this->cleanRecipes = $this->getBool();
|
||||
$this->cleanRecipes = $this->buf->getBool();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -245,35 +245,35 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt(count($this->entries));
|
||||
$this->buf->putUnsignedVarInt(count($this->entries));
|
||||
|
||||
$writer = new NetworkBinaryStream();
|
||||
$counter = 0;
|
||||
foreach($this->entries as $d){
|
||||
$entryType = self::writeEntry($d, $writer, $counter++);
|
||||
if($entryType >= 0){
|
||||
$this->putVarInt($entryType);
|
||||
$this->put($writer->getBuffer());
|
||||
$this->buf->putVarInt($entryType);
|
||||
$this->buf->put($writer->getBuffer());
|
||||
}else{
|
||||
$this->putVarInt(-1);
|
||||
$this->buf->putVarInt(-1);
|
||||
}
|
||||
|
||||
$writer->reset();
|
||||
}
|
||||
$this->putUnsignedVarInt(count($this->potionTypeRecipes));
|
||||
$this->buf->putUnsignedVarInt(count($this->potionTypeRecipes));
|
||||
foreach($this->potionTypeRecipes as $recipe){
|
||||
$this->putVarInt($recipe->getInputPotionType());
|
||||
$this->putVarInt($recipe->getIngredientItemId());
|
||||
$this->putVarInt($recipe->getOutputPotionType());
|
||||
$this->buf->putVarInt($recipe->getInputPotionType());
|
||||
$this->buf->putVarInt($recipe->getIngredientItemId());
|
||||
$this->buf->putVarInt($recipe->getOutputPotionType());
|
||||
}
|
||||
$this->putUnsignedVarInt(count($this->potionContainerRecipes));
|
||||
$this->buf->putUnsignedVarInt(count($this->potionContainerRecipes));
|
||||
foreach($this->potionContainerRecipes as $recipe){
|
||||
$this->putVarInt($recipe->getInputItemId());
|
||||
$this->putVarInt($recipe->getIngredientItemId());
|
||||
$this->putVarInt($recipe->getOutputItemId());
|
||||
$this->buf->putVarInt($recipe->getInputItemId());
|
||||
$this->buf->putVarInt($recipe->getIngredientItemId());
|
||||
$this->buf->putVarInt($recipe->getOutputItemId());
|
||||
}
|
||||
|
||||
$this->putBool($this->cleanRecipes);
|
||||
$this->buf->putBool($this->cleanRecipes);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -45,34 +45,34 @@ class CraftingEventPacket extends DataPacket implements ServerboundPacket{
|
||||
public $output = [];
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->windowId = $this->getByte();
|
||||
$this->type = $this->getVarInt();
|
||||
$this->id = $this->getUUID();
|
||||
$this->windowId = $this->buf->getByte();
|
||||
$this->type = $this->buf->getVarInt();
|
||||
$this->id = $this->buf->getUUID();
|
||||
|
||||
$size = $this->getUnsignedVarInt();
|
||||
$size = $this->buf->getUnsignedVarInt();
|
||||
for($i = 0; $i < $size and $i < 128; ++$i){
|
||||
$this->input[] = $this->getSlot();
|
||||
$this->input[] = $this->buf->getSlot();
|
||||
}
|
||||
|
||||
$size = $this->getUnsignedVarInt();
|
||||
$size = $this->buf->getUnsignedVarInt();
|
||||
for($i = 0; $i < $size and $i < 128; ++$i){
|
||||
$this->output[] = $this->getSlot();
|
||||
$this->output[] = $this->buf->getSlot();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->windowId);
|
||||
$this->putVarInt($this->type);
|
||||
$this->putUUID($this->id);
|
||||
$this->buf->putByte($this->windowId);
|
||||
$this->buf->putVarInt($this->type);
|
||||
$this->buf->putUUID($this->id);
|
||||
|
||||
$this->putUnsignedVarInt(count($this->input));
|
||||
$this->buf->putUnsignedVarInt(count($this->input));
|
||||
foreach($this->input as $item){
|
||||
$this->putSlot($item);
|
||||
$this->buf->putSlot($item);
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt(count($this->output));
|
||||
$this->buf->putUnsignedVarInt(count($this->output));
|
||||
foreach($this->output as $item){
|
||||
$this->putSlot($item);
|
||||
$this->buf->putSlot($item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ use function is_object;
|
||||
use function is_string;
|
||||
use function method_exists;
|
||||
|
||||
abstract class DataPacket extends NetworkBinaryStream implements Packet{
|
||||
abstract class DataPacket implements Packet{
|
||||
|
||||
public const NETWORK_ID = 0;
|
||||
|
||||
@ -43,6 +43,17 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{
|
||||
public $senderSubId = 0;
|
||||
/** @var int */
|
||||
public $recipientSubId = 0;
|
||||
|
||||
/** @var NetworkBinaryStream */
|
||||
protected $buf;
|
||||
|
||||
public function __construct(){
|
||||
$this->buf = new NetworkBinaryStream();
|
||||
}
|
||||
|
||||
public function getBinaryStream() : NetworkBinaryStream{
|
||||
return $this->buf;
|
||||
}
|
||||
|
||||
public function pid() : int{
|
||||
return $this::NETWORK_ID;
|
||||
@ -60,7 +71,7 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{
|
||||
* @throws BadPacketException
|
||||
*/
|
||||
final public function decode() : void{
|
||||
$this->rewind();
|
||||
$this->buf->rewind();
|
||||
try{
|
||||
$this->decodeHeader();
|
||||
$this->decodePayload();
|
||||
@ -74,7 +85,7 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{
|
||||
* @throws \UnexpectedValueException
|
||||
*/
|
||||
protected function decodeHeader() : void{
|
||||
$pid = $this->getUnsignedVarInt();
|
||||
$pid = $this->buf->getUnsignedVarInt();
|
||||
if($pid !== static::NETWORK_ID){
|
||||
//TODO: this means a logical error in the code, but how to prevent it from happening?
|
||||
throw new \UnexpectedValueException("Expected " . static::NETWORK_ID . " for packet ID, got $pid");
|
||||
@ -90,13 +101,13 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{
|
||||
abstract protected function decodePayload() : void;
|
||||
|
||||
final public function encode() : void{
|
||||
$this->reset();
|
||||
$this->buf->reset();
|
||||
$this->encodeHeader();
|
||||
$this->encodePayload();
|
||||
}
|
||||
|
||||
protected function encodeHeader() : void{
|
||||
$this->putUnsignedVarInt(static::NETWORK_ID);
|
||||
$this->buf->putUnsignedVarInt(static::NETWORK_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,24 +115,6 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{
|
||||
*/
|
||||
abstract protected function encodePayload() : void;
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function __debugInfo() : array{
|
||||
$data = [];
|
||||
foreach((array) $this as $k => $v){
|
||||
if($v === $this->getBuffer()){
|
||||
$data[$k] = bin2hex($v);
|
||||
}elseif(is_string($v) or (is_object($v) and method_exists($v, "__toString"))){
|
||||
$data[$k] = Utils::printable((string) $v);
|
||||
}else{
|
||||
$data[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
|
@ -53,16 +53,16 @@ class DisconnectPacket extends DataPacket implements ClientboundPacket, Serverbo
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->hideDisconnectionScreen = $this->getBool();
|
||||
$this->hideDisconnectionScreen = $this->buf->getBool();
|
||||
if(!$this->hideDisconnectionScreen){
|
||||
$this->message = $this->getString();
|
||||
$this->message = $this->buf->getString();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putBool($this->hideDisconnectionScreen);
|
||||
$this->buf->putBool($this->hideDisconnectionScreen);
|
||||
if(!$this->hideDisconnectionScreen){
|
||||
$this->putString($this->message);
|
||||
$this->buf->putString($this->message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,13 +51,13 @@ class EducationSettingsPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->codeBuilderDefaultUri = $this->getString();
|
||||
$this->hasQuiz = $this->getBool();
|
||||
$this->codeBuilderDefaultUri = $this->buf->getString();
|
||||
$this->hasQuiz = $this->buf->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putString($this->codeBuilderDefaultUri);
|
||||
$this->putBool($this->hasQuiz);
|
||||
$this->buf->putString($this->codeBuilderDefaultUri);
|
||||
$this->buf->putBool($this->hasQuiz);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -63,15 +63,15 @@ class EmotePacket extends DataPacket implements ClientboundPacket, ServerboundPa
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->emoteId = $this->getString();
|
||||
$this->flags = $this->getByte();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->emoteId = $this->buf->getString();
|
||||
$this->flags = $this->buf->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putString($this->emoteId);
|
||||
$this->putByte($this->flags);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putString($this->emoteId);
|
||||
$this->buf->putByte($this->flags);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -57,17 +57,17 @@ class EventPacket extends DataPacket implements ClientboundPacket{
|
||||
public $type;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->playerRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->eventData = $this->getVarInt();
|
||||
$this->type = $this->getByte();
|
||||
$this->playerRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->eventData = $this->buf->getVarInt();
|
||||
$this->type = $this->buf->getByte();
|
||||
|
||||
//TODO: nice confusing mess
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityRuntimeId($this->playerRuntimeId);
|
||||
$this->putVarInt($this->eventData);
|
||||
$this->putByte($this->type);
|
||||
$this->buf->putEntityRuntimeId($this->playerRuntimeId);
|
||||
$this->buf->putVarInt($this->eventData);
|
||||
$this->buf->putByte($this->type);
|
||||
|
||||
//TODO: also nice confusing mess
|
||||
}
|
||||
|
@ -37,11 +37,11 @@ class GameRulesChangedPacket extends DataPacket implements ClientboundPacket{
|
||||
public $gameRules = [];
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->gameRules = $this->getGameRules();
|
||||
$this->gameRules = $this->buf->getGameRules();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putGameRules($this->gameRules);
|
||||
$this->buf->putGameRules($this->gameRules);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -38,15 +38,15 @@ class GuiDataPickItemPacket extends DataPacket implements ClientboundPacket{
|
||||
public $hotbarSlot;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->itemDescription = $this->getString();
|
||||
$this->itemEffects = $this->getString();
|
||||
$this->hotbarSlot = $this->getLInt();
|
||||
$this->itemDescription = $this->buf->getString();
|
||||
$this->itemEffects = $this->buf->getString();
|
||||
$this->hotbarSlot = $this->buf->getLInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putString($this->itemDescription);
|
||||
$this->putString($this->itemEffects);
|
||||
$this->putLInt($this->hotbarSlot);
|
||||
$this->buf->putString($this->itemDescription);
|
||||
$this->buf->putString($this->itemEffects);
|
||||
$this->buf->putLInt($this->hotbarSlot);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -34,11 +34,11 @@ class HurtArmorPacket extends DataPacket implements ClientboundPacket{
|
||||
public $health;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->health = $this->getVarInt();
|
||||
$this->health = $this->buf->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putVarInt($this->health);
|
||||
$this->buf->putVarInt($this->health);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -48,25 +48,25 @@ class InteractPacket extends DataPacket implements ServerboundPacket{
|
||||
public $z;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->action = $this->getByte();
|
||||
$this->target = $this->getEntityRuntimeId();
|
||||
$this->action = $this->buf->getByte();
|
||||
$this->target = $this->buf->getEntityRuntimeId();
|
||||
|
||||
if($this->action === self::ACTION_MOUSEOVER){
|
||||
//TODO: should this be a vector3?
|
||||
$this->x = $this->getLFloat();
|
||||
$this->y = $this->getLFloat();
|
||||
$this->z = $this->getLFloat();
|
||||
$this->x = $this->buf->getLFloat();
|
||||
$this->y = $this->buf->getLFloat();
|
||||
$this->z = $this->buf->getLFloat();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->action);
|
||||
$this->putEntityRuntimeId($this->target);
|
||||
$this->buf->putByte($this->action);
|
||||
$this->buf->putEntityRuntimeId($this->target);
|
||||
|
||||
if($this->action === self::ACTION_MOUSEOVER){
|
||||
$this->putLFloat($this->x);
|
||||
$this->putLFloat($this->y);
|
||||
$this->putLFloat($this->z);
|
||||
$this->buf->putLFloat($this->x);
|
||||
$this->buf->putLFloat($this->y);
|
||||
$this->buf->putLFloat($this->z);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,18 +50,18 @@ class InventoryContentPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->windowId = $this->getUnsignedVarInt();
|
||||
$count = $this->getUnsignedVarInt();
|
||||
$this->windowId = $this->buf->getUnsignedVarInt();
|
||||
$count = $this->buf->getUnsignedVarInt();
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$this->items[] = $this->getSlot();
|
||||
$this->items[] = $this->buf->getSlot();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt($this->windowId);
|
||||
$this->putUnsignedVarInt(count($this->items));
|
||||
$this->buf->putUnsignedVarInt($this->windowId);
|
||||
$this->buf->putUnsignedVarInt(count($this->items));
|
||||
foreach($this->items as $item){
|
||||
$this->putSlot($item);
|
||||
$this->buf->putSlot($item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,15 +47,15 @@ class InventorySlotPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->windowId = $this->getUnsignedVarInt();
|
||||
$this->inventorySlot = $this->getUnsignedVarInt();
|
||||
$this->item = $this->getSlot();
|
||||
$this->windowId = $this->buf->getUnsignedVarInt();
|
||||
$this->inventorySlot = $this->buf->getUnsignedVarInt();
|
||||
$this->item = $this->buf->getSlot();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt($this->windowId);
|
||||
$this->putUnsignedVarInt($this->inventorySlot);
|
||||
$this->putSlot($this->item);
|
||||
$this->buf->putUnsignedVarInt($this->windowId);
|
||||
$this->buf->putUnsignedVarInt($this->inventorySlot);
|
||||
$this->buf->putSlot($this->item);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -50,7 +50,7 @@ class InventoryTransactionPacket extends DataPacket implements ClientboundPacket
|
||||
public $trData;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$transactionType = $this->getUnsignedVarInt();
|
||||
$transactionType = $this->buf->getUnsignedVarInt();
|
||||
|
||||
switch($transactionType){
|
||||
case self::TYPE_NORMAL:
|
||||
@ -72,12 +72,12 @@ class InventoryTransactionPacket extends DataPacket implements ClientboundPacket
|
||||
throw new BadPacketException("Unknown transaction type $transactionType");
|
||||
}
|
||||
|
||||
$this->trData->decode($this);
|
||||
$this->trData->decode($this->buf);
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt($this->trData->getTypeId());
|
||||
$this->trData->encode($this);
|
||||
$this->buf->putUnsignedVarInt($this->trData->getTypeId());
|
||||
$this->trData->encode($this->buf);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -39,11 +39,11 @@ class ItemFrameDropItemPacket extends DataPacket implements ServerboundPacket{
|
||||
public $z;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -44,15 +44,15 @@ class LabTablePacket extends DataPacket implements ClientboundPacket, Serverboun
|
||||
public $reactionType;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->uselessByte = $this->getByte();
|
||||
$this->getSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->reactionType = $this->getByte();
|
||||
$this->uselessByte = $this->buf->getByte();
|
||||
$this->buf->getSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->reactionType = $this->buf->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->uselessByte);
|
||||
$this->putSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putByte($this->reactionType);
|
||||
$this->buf->putByte($this->uselessByte);
|
||||
$this->buf->putSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putByte($this->reactionType);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -44,17 +44,17 @@ class LecternUpdatePacket extends DataPacket implements ServerboundPacket{
|
||||
public $dropBook;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->page = $this->getByte();
|
||||
$this->totalPages = $this->getByte();
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->dropBook = $this->getBool();
|
||||
$this->page = $this->buf->getByte();
|
||||
$this->totalPages = $this->buf->getByte();
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->dropBook = $this->buf->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->page);
|
||||
$this->putByte($this->totalPages);
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putBool($this->dropBook);
|
||||
$this->buf->putByte($this->page);
|
||||
$this->buf->putByte($this->totalPages);
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putBool($this->dropBook);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -101,30 +101,30 @@ class LevelChunkPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->chunkX = $this->getVarInt();
|
||||
$this->chunkZ = $this->getVarInt();
|
||||
$this->subChunkCount = $this->getUnsignedVarInt();
|
||||
$this->cacheEnabled = $this->getBool();
|
||||
$this->chunkX = $this->buf->getVarInt();
|
||||
$this->chunkZ = $this->buf->getVarInt();
|
||||
$this->subChunkCount = $this->buf->getUnsignedVarInt();
|
||||
$this->cacheEnabled = $this->buf->getBool();
|
||||
if($this->cacheEnabled){
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->usedBlobHashes[] = $this->getLLong();
|
||||
for($i = 0, $count = $this->buf->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->usedBlobHashes[] = $this->buf->getLLong();
|
||||
}
|
||||
}
|
||||
$this->extraPayload = $this->getString();
|
||||
$this->extraPayload = $this->buf->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putVarInt($this->chunkX);
|
||||
$this->putVarInt($this->chunkZ);
|
||||
$this->putUnsignedVarInt($this->subChunkCount);
|
||||
$this->putBool($this->cacheEnabled);
|
||||
$this->buf->putVarInt($this->chunkX);
|
||||
$this->buf->putVarInt($this->chunkZ);
|
||||
$this->buf->putUnsignedVarInt($this->subChunkCount);
|
||||
$this->buf->putBool($this->cacheEnabled);
|
||||
if($this->cacheEnabled){
|
||||
$this->putUnsignedVarInt(count($this->usedBlobHashes));
|
||||
$this->buf->putUnsignedVarInt(count($this->usedBlobHashes));
|
||||
foreach($this->usedBlobHashes as $hash){
|
||||
$this->putLLong($hash);
|
||||
$this->buf->putLLong($hash);
|
||||
}
|
||||
}
|
||||
$this->putString($this->extraPayload);
|
||||
$this->buf->putString($this->extraPayload);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -54,13 +54,13 @@ class LevelEventGenericPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->eventId = $this->getVarInt();
|
||||
$this->eventData = $this->getRemaining();
|
||||
$this->eventId = $this->buf->getVarInt();
|
||||
$this->eventData = $this->buf->getRemaining();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putVarInt($this->eventId);
|
||||
$this->put($this->eventData);
|
||||
$this->buf->putVarInt($this->eventId);
|
||||
$this->buf->put($this->eventData);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -134,15 +134,15 @@ class LevelEventPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->evid = $this->getVarInt();
|
||||
$this->position = $this->getVector3();
|
||||
$this->data = $this->getVarInt();
|
||||
$this->evid = $this->buf->getVarInt();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->data = $this->buf->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putVarInt($this->evid);
|
||||
$this->putVector3Nullable($this->position);
|
||||
$this->putVarInt($this->data);
|
||||
$this->buf->putVarInt($this->evid);
|
||||
$this->buf->putVector3Nullable($this->position);
|
||||
$this->buf->putVarInt($this->data);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -336,21 +336,21 @@ class LevelSoundEventPacket extends DataPacket implements ClientboundPacket, Ser
|
||||
public $disableRelativeVolume = false;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->sound = $this->getUnsignedVarInt();
|
||||
$this->position = $this->getVector3();
|
||||
$this->extraData = $this->getVarInt();
|
||||
$this->entityType = $this->getString();
|
||||
$this->isBabyMob = $this->getBool();
|
||||
$this->disableRelativeVolume = $this->getBool();
|
||||
$this->sound = $this->buf->getUnsignedVarInt();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->extraData = $this->buf->getVarInt();
|
||||
$this->entityType = $this->buf->getString();
|
||||
$this->isBabyMob = $this->buf->getBool();
|
||||
$this->disableRelativeVolume = $this->buf->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt($this->sound);
|
||||
$this->putVector3($this->position);
|
||||
$this->putVarInt($this->extraData);
|
||||
$this->putString($this->entityType);
|
||||
$this->putBool($this->isBabyMob);
|
||||
$this->putBool($this->disableRelativeVolume);
|
||||
$this->buf->putUnsignedVarInt($this->sound);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putVarInt($this->extraData);
|
||||
$this->buf->putString($this->entityType);
|
||||
$this->buf->putBool($this->isBabyMob);
|
||||
$this->buf->putBool($this->disableRelativeVolume);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -48,21 +48,21 @@ class LevelSoundEventPacketV1 extends DataPacket{
|
||||
public $disableRelativeVolume = false;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->sound = $this->getByte();
|
||||
$this->position = $this->getVector3();
|
||||
$this->extraData = $this->getVarInt();
|
||||
$this->entityType = $this->getVarInt();
|
||||
$this->isBabyMob = $this->getBool();
|
||||
$this->disableRelativeVolume = $this->getBool();
|
||||
$this->sound = $this->buf->getByte();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->extraData = $this->buf->getVarInt();
|
||||
$this->entityType = $this->buf->getVarInt();
|
||||
$this->isBabyMob = $this->buf->getBool();
|
||||
$this->disableRelativeVolume = $this->buf->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->sound);
|
||||
$this->putVector3($this->position);
|
||||
$this->putVarInt($this->extraData);
|
||||
$this->putVarInt($this->entityType);
|
||||
$this->putBool($this->isBabyMob);
|
||||
$this->putBool($this->disableRelativeVolume);
|
||||
$this->buf->putByte($this->sound);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putVarInt($this->extraData);
|
||||
$this->buf->putVarInt($this->entityType);
|
||||
$this->buf->putBool($this->isBabyMob);
|
||||
$this->buf->putBool($this->disableRelativeVolume);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -48,21 +48,21 @@ class LevelSoundEventPacketV2 extends DataPacket{
|
||||
public $disableRelativeVolume = false;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->sound = $this->getByte();
|
||||
$this->position = $this->getVector3();
|
||||
$this->extraData = $this->getVarInt();
|
||||
$this->entityType = $this->getString();
|
||||
$this->isBabyMob = $this->getBool();
|
||||
$this->disableRelativeVolume = $this->getBool();
|
||||
$this->sound = $this->buf->getByte();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->extraData = $this->buf->getVarInt();
|
||||
$this->entityType = $this->buf->getString();
|
||||
$this->isBabyMob = $this->buf->getBool();
|
||||
$this->disableRelativeVolume = $this->buf->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->sound);
|
||||
$this->putVector3($this->position);
|
||||
$this->putVarInt($this->extraData);
|
||||
$this->putString($this->entityType);
|
||||
$this->putBool($this->isBabyMob);
|
||||
$this->putBool($this->disableRelativeVolume);
|
||||
$this->buf->putByte($this->sound);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putVarInt($this->extraData);
|
||||
$this->buf->putString($this->entityType);
|
||||
$this->buf->putBool($this->isBabyMob);
|
||||
$this->buf->putBool($this->disableRelativeVolume);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -109,7 +109,7 @@ class LoginPacket extends DataPacket implements ServerboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->protocol = $this->getInt();
|
||||
$this->protocol = $this->buf->getInt();
|
||||
$this->decodeConnectionRequest();
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ class LoginPacket extends DataPacket implements ServerboundPacket{
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
protected function decodeConnectionRequest() : void{
|
||||
$buffer = new BinaryStream($this->getString());
|
||||
$buffer = new BinaryStream($this->buf->getString());
|
||||
|
||||
$chainData = json_decode($buffer->get($buffer->getLInt()), true);
|
||||
if(!is_array($chainData)){
|
||||
|
@ -36,13 +36,13 @@ class MapCreateLockedCopyPacket extends DataPacket implements ServerboundPacket{
|
||||
public $newMapId;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->originalMapId = $this->getEntityUniqueId();
|
||||
$this->newMapId = $this->getEntityUniqueId();
|
||||
$this->originalMapId = $this->buf->getEntityUniqueId();
|
||||
$this->newMapId = $this->buf->getEntityUniqueId();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityUniqueId($this->originalMapId);
|
||||
$this->putEntityUniqueId($this->newMapId);
|
||||
$this->buf->putEntityUniqueId($this->originalMapId);
|
||||
$this->buf->putEntityUniqueId($this->newMapId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -34,11 +34,11 @@ class MapInfoRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
public $mapId;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->mapId = $this->getEntityUniqueId();
|
||||
$this->mapId = $this->buf->getEntityUniqueId();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityUniqueId($this->mapId);
|
||||
$this->buf->putEntityUniqueId($this->mapId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -56,19 +56,19 @@ class MobArmorEquipmentPacket extends DataPacket implements ClientboundPacket, S
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->head = $this->getSlot();
|
||||
$this->chest = $this->getSlot();
|
||||
$this->legs = $this->getSlot();
|
||||
$this->feet = $this->getSlot();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->head = $this->buf->getSlot();
|
||||
$this->chest = $this->buf->getSlot();
|
||||
$this->legs = $this->buf->getSlot();
|
||||
$this->feet = $this->buf->getSlot();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putSlot($this->head);
|
||||
$this->putSlot($this->chest);
|
||||
$this->putSlot($this->legs);
|
||||
$this->putSlot($this->feet);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putSlot($this->head);
|
||||
$this->buf->putSlot($this->chest);
|
||||
$this->buf->putSlot($this->legs);
|
||||
$this->buf->putSlot($this->feet);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -67,21 +67,21 @@ class MobEffectPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->eventId = $this->getByte();
|
||||
$this->effectId = $this->getVarInt();
|
||||
$this->amplifier = $this->getVarInt();
|
||||
$this->particles = $this->getBool();
|
||||
$this->duration = $this->getVarInt();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->eventId = $this->buf->getByte();
|
||||
$this->effectId = $this->buf->getVarInt();
|
||||
$this->amplifier = $this->buf->getVarInt();
|
||||
$this->particles = $this->buf->getBool();
|
||||
$this->duration = $this->buf->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putByte($this->eventId);
|
||||
$this->putVarInt($this->effectId);
|
||||
$this->putVarInt($this->amplifier);
|
||||
$this->putBool($this->particles);
|
||||
$this->putVarInt($this->duration);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putByte($this->eventId);
|
||||
$this->buf->putVarInt($this->effectId);
|
||||
$this->buf->putVarInt($this->amplifier);
|
||||
$this->buf->putBool($this->particles);
|
||||
$this->buf->putVarInt($this->duration);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -53,19 +53,19 @@ class MobEquipmentPacket extends DataPacket implements ClientboundPacket, Server
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->item = $this->getSlot();
|
||||
$this->inventorySlot = $this->getByte();
|
||||
$this->hotbarSlot = $this->getByte();
|
||||
$this->windowId = $this->getByte();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->item = $this->buf->getSlot();
|
||||
$this->inventorySlot = $this->buf->getByte();
|
||||
$this->hotbarSlot = $this->buf->getByte();
|
||||
$this->windowId = $this->buf->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putSlot($this->item);
|
||||
$this->putByte($this->inventorySlot);
|
||||
$this->putByte($this->hotbarSlot);
|
||||
$this->putByte($this->windowId);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putSlot($this->item);
|
||||
$this->buf->putByte($this->inventorySlot);
|
||||
$this->buf->putByte($this->hotbarSlot);
|
||||
$this->buf->putByte($this->windowId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -43,13 +43,13 @@ class ModalFormRequestPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->formId = $this->getUnsignedVarInt();
|
||||
$this->formData = $this->getString();
|
||||
$this->formId = $this->buf->getUnsignedVarInt();
|
||||
$this->formData = $this->buf->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt($this->formId);
|
||||
$this->putString($this->formData);
|
||||
$this->buf->putUnsignedVarInt($this->formId);
|
||||
$this->buf->putString($this->formData);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -36,13 +36,13 @@ class ModalFormResponsePacket extends DataPacket implements ServerboundPacket{
|
||||
public $formData; //json
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->formId = $this->getUnsignedVarInt();
|
||||
$this->formData = $this->getString();
|
||||
$this->formId = $this->buf->getUnsignedVarInt();
|
||||
$this->formData = $this->buf->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt($this->formId);
|
||||
$this->putString($this->formData);
|
||||
$this->buf->putUnsignedVarInt($this->formId);
|
||||
$this->buf->putString($this->formData);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -48,21 +48,21 @@ class MoveActorAbsolutePacket extends DataPacket implements ClientboundPacket, S
|
||||
public $zRot;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->flags = $this->getByte();
|
||||
$this->position = $this->getVector3();
|
||||
$this->xRot = $this->getByteRotation();
|
||||
$this->yRot = $this->getByteRotation();
|
||||
$this->zRot = $this->getByteRotation();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->flags = $this->buf->getByte();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->xRot = $this->buf->getByteRotation();
|
||||
$this->yRot = $this->buf->getByteRotation();
|
||||
$this->zRot = $this->buf->getByteRotation();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putByte($this->flags);
|
||||
$this->putVector3($this->position);
|
||||
$this->putByteRotation($this->xRot);
|
||||
$this->putByteRotation($this->yRot);
|
||||
$this->putByteRotation($this->zRot);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putByte($this->flags);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putByteRotation($this->xRot);
|
||||
$this->buf->putByteRotation($this->yRot);
|
||||
$this->buf->putByteRotation($this->zRot);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -60,7 +60,7 @@ class MoveActorDeltaPacket extends DataPacket implements ClientboundPacket{
|
||||
*/
|
||||
private function maybeReadCoord(int $flag) : int{
|
||||
if(($this->flags & $flag) !== 0){
|
||||
return $this->getVarInt();
|
||||
return $this->buf->getVarInt();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -70,14 +70,14 @@ class MoveActorDeltaPacket extends DataPacket implements ClientboundPacket{
|
||||
*/
|
||||
private function maybeReadRotation(int $flag) : float{
|
||||
if(($this->flags & $flag) !== 0){
|
||||
return $this->getByteRotation();
|
||||
return $this->buf->getByteRotation();
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->flags = $this->getLShort();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->flags = $this->buf->getLShort();
|
||||
$this->xDiff = $this->maybeReadCoord(self::FLAG_HAS_X);
|
||||
$this->yDiff = $this->maybeReadCoord(self::FLAG_HAS_Y);
|
||||
$this->zDiff = $this->maybeReadCoord(self::FLAG_HAS_Z);
|
||||
@ -88,19 +88,19 @@ class MoveActorDeltaPacket extends DataPacket implements ClientboundPacket{
|
||||
|
||||
private function maybeWriteCoord(int $flag, int $val) : void{
|
||||
if(($this->flags & $flag) !== 0){
|
||||
$this->putVarInt($val);
|
||||
$this->buf->putVarInt($val);
|
||||
}
|
||||
}
|
||||
|
||||
private function maybeWriteRotation(int $flag, float $val) : void{
|
||||
if(($this->flags & $flag) !== 0){
|
||||
$this->putByteRotation($val);
|
||||
$this->buf->putByteRotation($val);
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putLShort($this->flags);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putLShort($this->flags);
|
||||
$this->maybeWriteCoord(self::FLAG_HAS_X, $this->xDiff);
|
||||
$this->maybeWriteCoord(self::FLAG_HAS_Y, $this->yDiff);
|
||||
$this->maybeWriteCoord(self::FLAG_HAS_Z, $this->zDiff);
|
||||
|
@ -58,32 +58,32 @@ class MovePlayerPacket extends DataPacket implements ClientboundPacket, Serverbo
|
||||
public $teleportItem = 0;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->position = $this->getVector3();
|
||||
$this->pitch = $this->getLFloat();
|
||||
$this->yaw = $this->getLFloat();
|
||||
$this->headYaw = $this->getLFloat();
|
||||
$this->mode = $this->getByte();
|
||||
$this->onGround = $this->getBool();
|
||||
$this->ridingEid = $this->getEntityRuntimeId();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->pitch = $this->buf->getLFloat();
|
||||
$this->yaw = $this->buf->getLFloat();
|
||||
$this->headYaw = $this->buf->getLFloat();
|
||||
$this->mode = $this->buf->getByte();
|
||||
$this->onGround = $this->buf->getBool();
|
||||
$this->ridingEid = $this->buf->getEntityRuntimeId();
|
||||
if($this->mode === MovePlayerPacket::MODE_TELEPORT){
|
||||
$this->teleportCause = $this->getLInt();
|
||||
$this->teleportItem = $this->getLInt();
|
||||
$this->teleportCause = $this->buf->getLInt();
|
||||
$this->teleportItem = $this->buf->getLInt();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putVector3($this->position);
|
||||
$this->putLFloat($this->pitch);
|
||||
$this->putLFloat($this->yaw);
|
||||
$this->putLFloat($this->headYaw); //TODO
|
||||
$this->putByte($this->mode);
|
||||
$this->putBool($this->onGround);
|
||||
$this->putEntityRuntimeId($this->ridingEid);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putLFloat($this->pitch);
|
||||
$this->buf->putLFloat($this->yaw);
|
||||
$this->buf->putLFloat($this->headYaw); //TODO
|
||||
$this->buf->putByte($this->mode);
|
||||
$this->buf->putBool($this->onGround);
|
||||
$this->buf->putEntityRuntimeId($this->ridingEid);
|
||||
if($this->mode === MovePlayerPacket::MODE_TELEPORT){
|
||||
$this->putLInt($this->teleportCause);
|
||||
$this->putLInt($this->teleportItem);
|
||||
$this->buf->putLInt($this->teleportCause);
|
||||
$this->buf->putLInt($this->teleportItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,11 +48,11 @@ class MultiplayerSettingsPacket extends DataPacket implements ServerboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->action = $this->getVarInt();
|
||||
$this->action = $this->buf->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putVarInt($this->action);
|
||||
$this->buf->putVarInt($this->action);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -49,13 +49,13 @@ class NetworkChunkPublisherUpdatePacket extends DataPacket implements Clientboun
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->getSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->radius = $this->getUnsignedVarInt();
|
||||
$this->buf->getSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->radius = $this->buf->getUnsignedVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putUnsignedVarInt($this->radius);
|
||||
$this->buf->putSignedBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putUnsignedVarInt($this->radius);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -47,11 +47,11 @@ class NetworkSettingsPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->compressionThreshold = $this->getLShort();
|
||||
$this->compressionThreshold = $this->buf->getLShort();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putLShort($this->compressionThreshold);
|
||||
$this->buf->putLShort($this->compressionThreshold);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -36,13 +36,13 @@ class NetworkStackLatencyPacket extends DataPacket implements ClientboundPacket,
|
||||
public $needResponse;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->timestamp = $this->getLLong();
|
||||
$this->needResponse = $this->getBool();
|
||||
$this->timestamp = $this->buf->getLLong();
|
||||
$this->needResponse = $this->buf->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putLLong($this->timestamp);
|
||||
$this->putBool($this->needResponse);
|
||||
$this->buf->putLLong($this->timestamp);
|
||||
$this->buf->putBool($this->needResponse);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -40,17 +40,17 @@ class NpcRequestPacket extends DataPacket implements ServerboundPacket{
|
||||
public $actionType;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->requestType = $this->getByte();
|
||||
$this->commandString = $this->getString();
|
||||
$this->actionType = $this->getByte();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->requestType = $this->buf->getByte();
|
||||
$this->commandString = $this->buf->getString();
|
||||
$this->actionType = $this->buf->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putByte($this->requestType);
|
||||
$this->putString($this->commandString);
|
||||
$this->putByte($this->actionType);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putByte($this->requestType);
|
||||
$this->buf->putString($this->commandString);
|
||||
$this->buf->putByte($this->actionType);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -34,11 +34,11 @@ class OnScreenTextureAnimationPacket extends DataPacket implements ClientboundPa
|
||||
public $effectId;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->effectId = $this->getLInt(); //unsigned
|
||||
$this->effectId = $this->buf->getLInt(); //unsigned
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putLInt($this->effectId);
|
||||
$this->buf->putLInt($this->effectId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -25,27 +25,11 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\BadPacketException;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
|
||||
interface Packet{
|
||||
|
||||
public function setOffset(int $offset) : void;
|
||||
|
||||
/**
|
||||
* TODO: this can't have a native return type yet because of incompatibility with BinaryUtils
|
||||
* really this should be addressed by making packets not extend BinaryStream, but that's a task for another day.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setBuffer(string $buffer = "", int $offset = 0);
|
||||
|
||||
public function getOffset() : int;
|
||||
|
||||
public function getBuffer() : string;
|
||||
|
||||
/**
|
||||
* Returns whether the offset has reached the end of the buffer.
|
||||
*/
|
||||
public function feof() : bool;
|
||||
public function getBinaryStream() : NetworkBinaryStream;
|
||||
|
||||
public function pid() : int;
|
||||
|
||||
|
@ -191,7 +191,7 @@ class PacketPool{
|
||||
public static function getPacket(string $buffer) : Packet{
|
||||
$offset = 0;
|
||||
$pk = static::getPacketById(Binary::readUnsignedVarInt($buffer, $offset));
|
||||
$pk->setBuffer($buffer, $offset);
|
||||
$pk->getBinaryStream()->setBuffer($buffer, $offset);
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
@ -38,15 +38,15 @@ class PhotoTransferPacket extends DataPacket implements ClientboundPacket{
|
||||
public $bookId; //photos are stored in a sibling directory to the games folder (screenshots/(some UUID)/bookID/example.png)
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->photoName = $this->getString();
|
||||
$this->photoData = $this->getString();
|
||||
$this->bookId = $this->getString();
|
||||
$this->photoName = $this->buf->getString();
|
||||
$this->photoData = $this->buf->getString();
|
||||
$this->bookId = $this->buf->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putString($this->photoName);
|
||||
$this->putString($this->photoData);
|
||||
$this->putString($this->bookId);
|
||||
$this->buf->putString($this->photoName);
|
||||
$this->buf->putString($this->photoData);
|
||||
$this->buf->putString($this->bookId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -44,20 +44,20 @@ class PlaySoundPacket extends DataPacket implements ClientboundPacket{
|
||||
public $pitch;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->soundName = $this->getString();
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->soundName = $this->buf->getString();
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->x /= 8;
|
||||
$this->y /= 8;
|
||||
$this->z /= 8;
|
||||
$this->volume = $this->getLFloat();
|
||||
$this->pitch = $this->getLFloat();
|
||||
$this->volume = $this->buf->getLFloat();
|
||||
$this->pitch = $this->buf->getLFloat();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putString($this->soundName);
|
||||
$this->putBlockPosition((int) ($this->x * 8), (int) ($this->y * 8), (int) ($this->z * 8));
|
||||
$this->putLFloat($this->volume);
|
||||
$this->putLFloat($this->pitch);
|
||||
$this->buf->putString($this->soundName);
|
||||
$this->buf->putBlockPosition((int) ($this->x * 8), (int) ($this->y * 8), (int) ($this->z * 8));
|
||||
$this->buf->putLFloat($this->volume);
|
||||
$this->buf->putLFloat($this->pitch);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -49,7 +49,7 @@ class PlayStatusPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->status = $this->getInt();
|
||||
$this->status = $this->buf->getInt();
|
||||
}
|
||||
|
||||
public function canBeSentBeforeLogin() : bool{
|
||||
@ -57,7 +57,7 @@ class PlayStatusPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putInt($this->status);
|
||||
$this->buf->putInt($this->status);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -71,17 +71,17 @@ class PlayerActionPacket extends DataPacket implements ServerboundPacket{
|
||||
public $face;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->action = $this->getVarInt();
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->face = $this->getVarInt();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
$this->action = $this->buf->getVarInt();
|
||||
$this->buf->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->face = $this->buf->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putVarInt($this->action);
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putVarInt($this->face);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putVarInt($this->action);
|
||||
$this->buf->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->buf->putVarInt($this->face);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -128,33 +128,33 @@ class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->yaw = $this->getLFloat();
|
||||
$this->pitch = $this->getLFloat();
|
||||
$this->position = $this->getVector3();
|
||||
$this->moveVecX = $this->getLFloat();
|
||||
$this->moveVecZ = $this->getLFloat();
|
||||
$this->headYaw = $this->getLFloat();
|
||||
$this->inputFlags = $this->getUnsignedVarLong();
|
||||
$this->inputMode = $this->getUnsignedVarInt();
|
||||
$this->playMode = $this->getUnsignedVarInt();
|
||||
$this->yaw = $this->buf->getLFloat();
|
||||
$this->pitch = $this->buf->getLFloat();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->moveVecX = $this->buf->getLFloat();
|
||||
$this->moveVecZ = $this->buf->getLFloat();
|
||||
$this->headYaw = $this->buf->getLFloat();
|
||||
$this->inputFlags = $this->buf->getUnsignedVarLong();
|
||||
$this->inputMode = $this->buf->getUnsignedVarInt();
|
||||
$this->playMode = $this->buf->getUnsignedVarInt();
|
||||
if($this->playMode === PlayMode::VR){
|
||||
$this->vrGazeDirection = $this->getVector3();
|
||||
$this->vrGazeDirection = $this->buf->getVector3();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putLFloat($this->yaw);
|
||||
$this->putLFloat($this->pitch);
|
||||
$this->putVector3($this->position);
|
||||
$this->putLFloat($this->moveVecX);
|
||||
$this->putLFloat($this->moveVecZ);
|
||||
$this->putLFloat($this->headYaw);
|
||||
$this->putUnsignedVarLong($this->inputFlags);
|
||||
$this->putUnsignedVarInt($this->inputMode);
|
||||
$this->putUnsignedVarInt($this->playMode);
|
||||
$this->buf->putLFloat($this->yaw);
|
||||
$this->buf->putLFloat($this->pitch);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putLFloat($this->moveVecX);
|
||||
$this->buf->putLFloat($this->moveVecZ);
|
||||
$this->buf->putLFloat($this->headYaw);
|
||||
$this->buf->putUnsignedVarLong($this->inputFlags);
|
||||
$this->buf->putUnsignedVarInt($this->inputMode);
|
||||
$this->buf->putUnsignedVarInt($this->playMode);
|
||||
if($this->playMode === PlayMode::VR){
|
||||
assert($this->vrGazeDirection !== null);
|
||||
$this->putVector3($this->vrGazeDirection);
|
||||
$this->buf->putVector3($this->vrGazeDirection);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,15 +47,15 @@ class PlayerHotbarPacket extends DataPacket implements ClientboundPacket, Server
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->selectedHotbarSlot = $this->getUnsignedVarInt();
|
||||
$this->windowId = $this->getByte();
|
||||
$this->selectHotbarSlot = $this->getBool();
|
||||
$this->selectedHotbarSlot = $this->buf->getUnsignedVarInt();
|
||||
$this->windowId = $this->buf->getByte();
|
||||
$this->selectHotbarSlot = $this->buf->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt($this->selectedHotbarSlot);
|
||||
$this->putByte($this->windowId);
|
||||
$this->putBool($this->selectHotbarSlot);
|
||||
$this->buf->putUnsignedVarInt($this->selectedHotbarSlot);
|
||||
$this->buf->putByte($this->windowId);
|
||||
$this->buf->putBool($this->selectHotbarSlot);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -40,17 +40,17 @@ class PlayerInputPacket extends DataPacket implements ServerboundPacket{
|
||||
public $sneaking;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->motionX = $this->getLFloat();
|
||||
$this->motionY = $this->getLFloat();
|
||||
$this->jumping = $this->getBool();
|
||||
$this->sneaking = $this->getBool();
|
||||
$this->motionX = $this->buf->getLFloat();
|
||||
$this->motionY = $this->buf->getLFloat();
|
||||
$this->jumping = $this->buf->getBool();
|
||||
$this->sneaking = $this->buf->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putLFloat($this->motionX);
|
||||
$this->putLFloat($this->motionY);
|
||||
$this->putBool($this->jumping);
|
||||
$this->putBool($this->sneaking);
|
||||
$this->buf->putLFloat($this->motionX);
|
||||
$this->buf->putLFloat($this->motionY);
|
||||
$this->buf->putBool($this->jumping);
|
||||
$this->buf->putBool($this->sneaking);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -61,23 +61,23 @@ class PlayerListPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->type = $this->getByte();
|
||||
$count = $this->getUnsignedVarInt();
|
||||
$this->type = $this->buf->getByte();
|
||||
$count = $this->buf->getUnsignedVarInt();
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$entry = new PlayerListEntry();
|
||||
|
||||
if($this->type === self::TYPE_ADD){
|
||||
$entry->uuid = $this->getUUID();
|
||||
$entry->entityUniqueId = $this->getEntityUniqueId();
|
||||
$entry->username = $this->getString();
|
||||
$entry->xboxUserId = $this->getString();
|
||||
$entry->platformChatId = $this->getString();
|
||||
$entry->buildPlatform = $this->getLInt();
|
||||
$entry->skinData = $this->getSkin();
|
||||
$entry->isTeacher = $this->getBool();
|
||||
$entry->isHost = $this->getBool();
|
||||
$entry->uuid = $this->buf->getUUID();
|
||||
$entry->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
$entry->username = $this->buf->getString();
|
||||
$entry->xboxUserId = $this->buf->getString();
|
||||
$entry->platformChatId = $this->buf->getString();
|
||||
$entry->buildPlatform = $this->buf->getLInt();
|
||||
$entry->skinData = $this->buf->getSkin();
|
||||
$entry->isTeacher = $this->buf->getBool();
|
||||
$entry->isHost = $this->buf->getBool();
|
||||
}else{
|
||||
$entry->uuid = $this->getUUID();
|
||||
$entry->uuid = $this->buf->getUUID();
|
||||
}
|
||||
|
||||
$this->entries[$i] = $entry;
|
||||
@ -85,21 +85,21 @@ class PlayerListPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->type);
|
||||
$this->putUnsignedVarInt(count($this->entries));
|
||||
$this->buf->putByte($this->type);
|
||||
$this->buf->putUnsignedVarInt(count($this->entries));
|
||||
foreach($this->entries as $entry){
|
||||
if($this->type === self::TYPE_ADD){
|
||||
$this->putUUID($entry->uuid);
|
||||
$this->putEntityUniqueId($entry->entityUniqueId);
|
||||
$this->putString($entry->username);
|
||||
$this->putString($entry->xboxUserId);
|
||||
$this->putString($entry->platformChatId);
|
||||
$this->putLInt($entry->buildPlatform);
|
||||
$this->putSkin($entry->skinData);
|
||||
$this->putBool($entry->isTeacher);
|
||||
$this->putBool($entry->isHost);
|
||||
$this->buf->putUUID($entry->uuid);
|
||||
$this->buf->putEntityUniqueId($entry->entityUniqueId);
|
||||
$this->buf->putString($entry->username);
|
||||
$this->buf->putString($entry->xboxUserId);
|
||||
$this->buf->putString($entry->platformChatId);
|
||||
$this->buf->putLInt($entry->buildPlatform);
|
||||
$this->buf->putSkin($entry->skinData);
|
||||
$this->buf->putBool($entry->isTeacher);
|
||||
$this->buf->putBool($entry->isHost);
|
||||
}else{
|
||||
$this->putUUID($entry->uuid);
|
||||
$this->buf->putUUID($entry->uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,17 +42,17 @@ class PlayerSkinPacket extends DataPacket implements ClientboundPacket, Serverbo
|
||||
public $skin;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->uuid = $this->getUUID();
|
||||
$this->skin = $this->getSkin();
|
||||
$this->newSkinName = $this->getString();
|
||||
$this->oldSkinName = $this->getString();
|
||||
$this->uuid = $this->buf->getUUID();
|
||||
$this->skin = $this->buf->getSkin();
|
||||
$this->newSkinName = $this->buf->getString();
|
||||
$this->oldSkinName = $this->buf->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUUID($this->uuid);
|
||||
$this->putSkin($this->skin);
|
||||
$this->putString($this->newSkinName);
|
||||
$this->putString($this->oldSkinName);
|
||||
$this->buf->putUUID($this->uuid);
|
||||
$this->buf->putSkin($this->skin);
|
||||
$this->buf->putString($this->newSkinName);
|
||||
$this->buf->putString($this->oldSkinName);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -35,16 +35,16 @@ class PurchaseReceiptPacket extends DataPacket implements ServerboundPacket{
|
||||
public $entries = [];
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$count = $this->getUnsignedVarInt();
|
||||
$count = $this->buf->getUnsignedVarInt();
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$this->entries[] = $this->getString();
|
||||
$this->entries[] = $this->buf->getString();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt(count($this->entries));
|
||||
$this->buf->putUnsignedVarInt(count($this->entries));
|
||||
foreach($this->entries as $entry){
|
||||
$this->putString($entry);
|
||||
$this->buf->putString($entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,11 +40,11 @@ class RemoveActorPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityUniqueId = $this->buf->getEntityUniqueId();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityUniqueId($this->entityUniqueId);
|
||||
$this->buf->putEntityUniqueId($this->entityUniqueId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -44,11 +44,11 @@ class RemoveEntityPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->uvarint1 = $this->getUnsignedVarInt();
|
||||
$this->uvarint1 = $this->buf->getUnsignedVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt($this->uvarint1);
|
||||
$this->buf->putUnsignedVarInt($this->uvarint1);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -34,11 +34,11 @@ class RemoveObjectivePacket extends DataPacket implements ClientboundPacket{
|
||||
public $objectiveName;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->objectiveName = $this->getString();
|
||||
$this->objectiveName = $this->buf->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putString($this->objectiveName);
|
||||
$this->buf->putString($this->objectiveName);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -34,11 +34,11 @@ class RequestChunkRadiusPacket extends DataPacket implements ServerboundPacket{
|
||||
public $radius;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->radius = $this->getVarInt();
|
||||
$this->radius = $this->buf->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putVarInt($this->radius);
|
||||
$this->buf->putVarInt($this->radius);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -50,17 +50,17 @@ class ResourcePackChunkDataPacket extends DataPacket implements ClientboundPacke
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->packId = $this->getString();
|
||||
$this->chunkIndex = $this->getLInt();
|
||||
$this->progress = $this->getLLong();
|
||||
$this->data = $this->getString();
|
||||
$this->packId = $this->buf->getString();
|
||||
$this->chunkIndex = $this->buf->getLInt();
|
||||
$this->progress = $this->buf->getLLong();
|
||||
$this->data = $this->buf->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putString($this->packId);
|
||||
$this->putLInt($this->chunkIndex);
|
||||
$this->putLLong($this->progress);
|
||||
$this->putString($this->data);
|
||||
$this->buf->putString($this->packId);
|
||||
$this->buf->putLInt($this->chunkIndex);
|
||||
$this->buf->putLLong($this->progress);
|
||||
$this->buf->putString($this->data);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -36,13 +36,13 @@ class ResourcePackChunkRequestPacket extends DataPacket implements ServerboundPa
|
||||
public $chunkIndex;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->packId = $this->getString();
|
||||
$this->chunkIndex = $this->getLInt();
|
||||
$this->packId = $this->buf->getString();
|
||||
$this->chunkIndex = $this->buf->getLInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putString($this->packId);
|
||||
$this->putLInt($this->chunkIndex);
|
||||
$this->buf->putString($this->packId);
|
||||
$this->buf->putLInt($this->chunkIndex);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -42,18 +42,18 @@ class ResourcePackClientResponsePacket extends DataPacket implements Serverbound
|
||||
public $packIds = [];
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->status = $this->getByte();
|
||||
$entryCount = $this->getLShort();
|
||||
$this->status = $this->buf->getByte();
|
||||
$entryCount = $this->buf->getLShort();
|
||||
while($entryCount-- > 0){
|
||||
$this->packIds[] = $this->getString();
|
||||
$this->packIds[] = $this->buf->getString();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->status);
|
||||
$this->putLShort(count($this->packIds));
|
||||
$this->buf->putByte($this->status);
|
||||
$this->buf->putLShort(count($this->packIds));
|
||||
foreach($this->packIds as $id){
|
||||
$this->putString($id);
|
||||
$this->buf->putString($id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,23 +57,23 @@ class ResourcePackDataInfoPacket extends DataPacket implements ClientboundPacket
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->packId = $this->getString();
|
||||
$this->maxChunkSize = $this->getLInt();
|
||||
$this->chunkCount = $this->getLInt();
|
||||
$this->compressedPackSize = $this->getLLong();
|
||||
$this->sha256 = $this->getString();
|
||||
$this->isPremium = $this->getBool();
|
||||
$this->packType = $this->getByte();
|
||||
$this->packId = $this->buf->getString();
|
||||
$this->maxChunkSize = $this->buf->getLInt();
|
||||
$this->chunkCount = $this->buf->getLInt();
|
||||
$this->compressedPackSize = $this->buf->getLLong();
|
||||
$this->sha256 = $this->buf->getString();
|
||||
$this->isPremium = $this->buf->getBool();
|
||||
$this->packType = $this->buf->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putString($this->packId);
|
||||
$this->putLInt($this->maxChunkSize);
|
||||
$this->putLInt($this->chunkCount);
|
||||
$this->putLLong($this->compressedPackSize);
|
||||
$this->putString($this->sha256);
|
||||
$this->putBool($this->isPremium);
|
||||
$this->putByte($this->packType);
|
||||
$this->buf->putString($this->packId);
|
||||
$this->buf->putLInt($this->maxChunkSize);
|
||||
$this->buf->putLInt($this->chunkCount);
|
||||
$this->buf->putLLong($this->compressedPackSize);
|
||||
$this->buf->putString($this->sha256);
|
||||
$this->buf->putBool($this->isPremium);
|
||||
$this->buf->putByte($this->packType);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -61,36 +61,36 @@ class ResourcePackStackPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->mustAccept = $this->getBool();
|
||||
$behaviorPackCount = $this->getUnsignedVarInt();
|
||||
$this->mustAccept = $this->buf->getBool();
|
||||
$behaviorPackCount = $this->buf->getUnsignedVarInt();
|
||||
while($behaviorPackCount-- > 0){
|
||||
$this->behaviorPackStack[] = ResourcePackStackEntry::read($this);
|
||||
$this->behaviorPackStack[] = ResourcePackStackEntry::read($this->buf);
|
||||
}
|
||||
|
||||
$resourcePackCount = $this->getUnsignedVarInt();
|
||||
$resourcePackCount = $this->buf->getUnsignedVarInt();
|
||||
while($resourcePackCount-- > 0){
|
||||
$this->resourcePackStack[] = ResourcePackStackEntry::read($this);
|
||||
$this->resourcePackStack[] = ResourcePackStackEntry::read($this->buf);
|
||||
}
|
||||
|
||||
$this->isExperimental = $this->getBool();
|
||||
$this->baseGameVersion = $this->getString();
|
||||
$this->isExperimental = $this->buf->getBool();
|
||||
$this->baseGameVersion = $this->buf->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putBool($this->mustAccept);
|
||||
$this->buf->putBool($this->mustAccept);
|
||||
|
||||
$this->putUnsignedVarInt(count($this->behaviorPackStack));
|
||||
$this->buf->putUnsignedVarInt(count($this->behaviorPackStack));
|
||||
foreach($this->behaviorPackStack as $entry){
|
||||
$entry->write($this);
|
||||
$entry->write($this->buf);
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt(count($this->resourcePackStack));
|
||||
$this->buf->putUnsignedVarInt(count($this->resourcePackStack));
|
||||
foreach($this->resourcePackStack as $entry){
|
||||
$entry->write($this);
|
||||
$entry->write($this->buf);
|
||||
}
|
||||
|
||||
$this->putBool($this->isExperimental);
|
||||
$this->putString($this->baseGameVersion);
|
||||
$this->buf->putBool($this->isExperimental);
|
||||
$this->buf->putString($this->baseGameVersion);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
@ -57,29 +57,29 @@ class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->mustAccept = $this->getBool();
|
||||
$this->hasScripts = $this->getBool();
|
||||
$behaviorPackCount = $this->getLShort();
|
||||
$this->mustAccept = $this->buf->getBool();
|
||||
$this->hasScripts = $this->buf->getBool();
|
||||
$behaviorPackCount = $this->buf->getLShort();
|
||||
while($behaviorPackCount-- > 0){
|
||||
$this->behaviorPackEntries[] = ResourcePackInfoEntry::read($this);
|
||||
$this->behaviorPackEntries[] = ResourcePackInfoEntry::read($this->buf);
|
||||
}
|
||||
|
||||
$resourcePackCount = $this->getLShort();
|
||||
$resourcePackCount = $this->buf->getLShort();
|
||||
while($resourcePackCount-- > 0){
|
||||
$this->resourcePackEntries[] = ResourcePackInfoEntry::read($this);
|
||||
$this->resourcePackEntries[] = ResourcePackInfoEntry::read($this->buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putBool($this->mustAccept);
|
||||
$this->putBool($this->hasScripts);
|
||||
$this->putLShort(count($this->behaviorPackEntries));
|
||||
$this->buf->putBool($this->mustAccept);
|
||||
$this->buf->putBool($this->hasScripts);
|
||||
$this->buf->putLShort(count($this->behaviorPackEntries));
|
||||
foreach($this->behaviorPackEntries as $entry){
|
||||
$entry->write($this);
|
||||
$entry->write($this->buf);
|
||||
}
|
||||
$this->putLShort(count($this->resourcePackEntries));
|
||||
$this->buf->putLShort(count($this->resourcePackEntries));
|
||||
foreach($this->resourcePackEntries as $entry){
|
||||
$entry->write($this);
|
||||
$entry->write($this->buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,15 +51,15 @@ class RespawnPacket extends DataPacket implements ClientboundPacket, Serverbound
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->position = $this->getVector3();
|
||||
$this->respawnState = $this->getByte();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->position = $this->buf->getVector3();
|
||||
$this->respawnState = $this->buf->getByte();
|
||||
$this->entityRuntimeId = $this->buf->getEntityRuntimeId();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putVector3($this->position);
|
||||
$this->putByte($this->respawnState);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->buf->putVector3($this->position);
|
||||
$this->buf->putByte($this->respawnState);
|
||||
$this->buf->putEntityRuntimeId($this->entityRuntimeId);
|
||||
}
|
||||
|
||||
public function handle(PacketHandler $handler) : bool{
|
||||
|
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