From be47bf0535011b4c2eda0435a606376b0c325ce9 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 30 Jun 2014 03:32:22 +0200 Subject: [PATCH] Added new files --- .../network/protocol/EntityMetadataPacket.php | 40 +++++++++++++ .../network/protocol/SpawnMobPacket.php | 60 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 src/shoghicp/BigBrother/network/protocol/EntityMetadataPacket.php create mode 100644 src/shoghicp/BigBrother/network/protocol/SpawnMobPacket.php diff --git a/src/shoghicp/BigBrother/network/protocol/EntityMetadataPacket.php b/src/shoghicp/BigBrother/network/protocol/EntityMetadataPacket.php new file mode 100644 index 00000000..4cfd7829 --- /dev/null +++ b/src/shoghicp/BigBrother/network/protocol/EntityMetadataPacket.php @@ -0,0 +1,40 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. +*/ + +namespace shoghicp\BigBrother\network\protocol; + +use shoghicp\BigBrother\network\Packet; +use shoghicp\BigBrother\utils\Binary; + +class EntityMetadataPacket extends Packet{ + + public $eid; + public $metadata; + + public function pid(){ + return 0x1c; + } + + public function encode(){ + $this->putInt($this->eid); + $this->put(Binary::writeMetadata($this->metadata)); + } + + public function decode(){ + + } +} \ No newline at end of file diff --git a/src/shoghicp/BigBrother/network/protocol/SpawnMobPacket.php b/src/shoghicp/BigBrother/network/protocol/SpawnMobPacket.php new file mode 100644 index 00000000..513f6fcc --- /dev/null +++ b/src/shoghicp/BigBrother/network/protocol/SpawnMobPacket.php @@ -0,0 +1,60 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. +*/ + +namespace shoghicp\BigBrother\network\protocol; + +use shoghicp\BigBrother\network\Packet; +use shoghicp\BigBrother\utils\Binary; + +class SpawnMobPacket extends Packet{ + + public $eid; + public $type; + public $x; + public $y; + public $z; + public $yaw; + public $pitch; + public $headPitch; + public $velocityX; + public $velocityY; + public $velocityZ; + public $metadata; + + public function pid(){ + return 0x0f; + } + + public function encode(){ + $this->putVarInt($this->eid); + $this->putByte($this->type); + $this->putInt(intval($this->x * 32)); + $this->putInt(intval($this->y * 32)); + $this->putInt(intval($this->z * 32)); + $this->putByte(($this->yaw / 360) << 8); + $this->putByte(($this->pitch / 360) << 8); + $this->putByte(($this->headPitch / 360) << 8); + $this->putShort($this->velocityX); + $this->putShort($this->velocityY); + $this->putShort($this->velocityZ); + $this->put(Binary::writeMetadata($this->metadata)); + } + + public function decode(){ + + } +} \ No newline at end of file