From 53928f4e88531f5c793d663c9af258ab5abef0b9 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Sun, 25 Sep 2022 00:08:55 +0300 Subject: [PATCH] players are now pushable, renamed 2 previously unknown variables(thanks to atipls' mcpealpha c# core) --- src/entity/Entity.php | 13 +++-- .../protocol/packet/AddPlayerPacket.php | 15 +++++- .../protocol/packet/PlayerInputPacket.php | 47 +++++++++---------- 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 3838db29..b4a4b91b 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -25,6 +25,9 @@ class Entity extends Position{ public $class; public $attach; public $closed; + /** + * @var Player + */ public $player; public $fallY; public $fallStart; @@ -599,8 +602,8 @@ class Entity extends Position{ $pk->z = $this->z; $pk->yaw = 0; $pk->pitch = 0; - $pk->unknown1 = 0; - $pk->unknown2 = 0; + $pk->itemID = 0; + $pk->itemAuxValue = 0; $pk->metadata = $this->getMetadata(); $player->dataPacket($pk); @@ -821,6 +824,10 @@ class Entity extends Position{ } public function sendMoveUpdate(){ + if($this->class === ENTITY_PLAYER){ + $this->player->teleport(new Vector3($this->x, $this->y, $this->z)); + return; + } $pk = new MoveEntityPacket_PosRot; $pk->eid = $this->eid; $pk->x = $this->x; @@ -837,7 +844,7 @@ class Entity extends Position{ if($health < $this->health){ $harm = true; $dmg = $this->health - $health; - if(is_numeric($cause) && ($entity = $this->server->api->entity->get($cause)) != false && !($this->player instanceof Player)){ + if(is_numeric($cause) && ($entity = $this->server->api->entity->get($cause)) != false){ $d = $entity->x - $this->x; for($d1 = $entity->z - $this->z; $d * $d + $d1 * $d1 < 0.0001; $d1 = (Utils::randomFloat() - Utils::randomFloat()) * 0.01) { diff --git a/src/network/protocol/packet/AddPlayerPacket.php b/src/network/protocol/packet/AddPlayerPacket.php index 6c1df270..044f119a 100644 --- a/src/network/protocol/packet/AddPlayerPacket.php +++ b/src/network/protocol/packet/AddPlayerPacket.php @@ -9,8 +9,19 @@ class AddPlayerPacket extends RakNetDataPacket{ public $z; public $pitch; public $yaw; + public $itemID; + public $itemAuxValue; + /** + *@deprecated use $itemID instead + */ public $unknown1; + /** + *@deprecated use $itemAuxValue instead + */ public $unknown2; + /** + *@var array + */ public $metadata; public function pid(){ @@ -31,8 +42,8 @@ class AddPlayerPacket extends RakNetDataPacket{ $this->putFloat($this->z); $this->putByte($this->yaw); $this->putByte($this->pitch); - $this->putShort($this->unknown1); - $this->putShort($this->unknown2); + $this->putShort($this->itemID); + $this->putShort($this->itemAuxValue); //Example: bow shooting power $this->put(Utils::writeMetadata($this->metadata)); } diff --git a/src/network/protocol/packet/PlayerInputPacket.php b/src/network/protocol/packet/PlayerInputPacket.php index 21037eb7..62eac6dc 100644 --- a/src/network/protocol/packet/PlayerInputPacket.php +++ b/src/network/protocol/packet/PlayerInputPacket.php @@ -1,24 +1,23 @@ -unk1 = $this->getFloat(); - $this->unk2 = $this->getFloat(); - $this->unk3 = $this->getByte(); - $this->unk4 = $this->getByte(); - console("values: {$this->unk1}, {$this->unk2}, {$this->unk3}, {$this->unk4}"); - } - -} - +unk1 = $this->getFloat(); + $this->unk2 = $this->getFloat(); + $this->unk3 = $this->getByte(); + $this->unk4 = $this->getByte(); + } + +} +