diff --git a/src/Player.php b/src/Player.php index fc8349d8..f3de9b1c 100755 --- a/src/Player.php +++ b/src/Player.php @@ -356,9 +356,12 @@ class Player{ return; } - $packet->PROTOCOL = $this->PROTOCOL; + $packet->PROTOCOL = $this->PROTOCOL; $packet->encode(); + if($packet->pid() == 163 or $packet->pid() == 164 && $this->PROTOCOL < ProtocolInfo7::CURRENT_PROTOCOL_7){ + return; + } $len = strlen($packet->buffer) + 1; $MTU = $this->MTU - 24; if($len > $MTU){ @@ -2228,6 +2231,73 @@ class Player{ } } break; + case ProtocolInfo::PLACE_BLOCK_PACKET: + if (!($this->entity instanceof Entity)) { + break; + } + + $blockVector = new Vector3($packet->x, $packet->y, $packet->z); + + if (($this->spawned === false or $this->blocked === true) and $packet->face >= 0 and $packet->face <= 5) { + $target = $this->level->getBlock($blockVector); + $block = $target->getSide($packet->face); + + $pk = new UpdateBlockPacket; + $pk->x = $target->x; + $pk->y = $target->y; + $pk->z = $target->z; + $pk->block = $target->getID(); + $pk->meta = $target->getMetadata(); + $this->dataPacket($pk); + + $pk = new UpdateBlockPacket; + $pk->x = $block->x; + $pk->y = $block->y; + $pk->z = $block->z; + $pk->block = $block->getID(); + $pk->meta = $block->getMetadata(); + $this->dataPacket($pk); + break; + } + $this->craftingItems = []; + $this->toCraft = []; + $packet->eid = $this->eid; + $data = []; + + if ($packet->face >= 0 and $packet->face <= 5) { //Use Block, place + if ($this->entity->inAction === true) { + $this->entity->inAction = false; + $this->entity->inActionCounter = 0; + $this->entity->updateMetadata(); + } + + if ($this->blocked === true or ($this->entity->position instanceof Vector3 and $blockVector->distance($this->entity->position) > 10)) { + + } else { + $this->server->api->block->playerBlockAction($this, $blockVector, $packet->face, $packet->fx, $packet->fy, $packet->fz); + break; + } + $target = $this->level->getBlock($blockVector); + $block = $target->getSide($packet->face); + + $pk = new UpdateBlockPacket; + $pk->x = $target->x; + $pk->y = $target->y; + $pk->z = $target->z; + $pk->block = $target->getID(); + $pk->meta = $target->getMetadata(); + $this->dataPacket($pk); + + $pk = new UpdateBlockPacket; + $pk->x = $block->x; + $pk->y = $block->y; + $pk->z = $block->z; + $pk->block = $block->getID(); + $pk->meta = $block->getMetadata(); + $this->dataPacket($pk); + break; + } + break; case ProtocolInfo::PLAYER_ACTION_PACKET: if ($this->spawned === false or $this->blocked === true) { break; diff --git a/src/network/protocol/packet/PlaceBlockPacket.php b/src/network/protocol/packet/PlaceBlockPacket.php index 448f83fa..22cbf9dc 100644 --- a/src/network/protocol/packet/PlaceBlockPacket.php +++ b/src/network/protocol/packet/PlaceBlockPacket.php @@ -1,13 +1,13 @@ PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL) { @@ -17,38 +17,24 @@ class PlaceBlockPacket extends RakNetDataPacket{ } public function decode(){ - $this->unknown1 = $this->getInt(); - $this->unknown2 = $this->getInt(); - $this->unknown3 = $this->getInt(); - $this->unknown4 = $this->getByte(); - $this->unknown5 = $this->getByte(); - $this->unknown6 = $this->getByte(); - $this->unknown7 = $this->getByte(); - ConsoleAPI::info("Int1:".$this->unknown1); - ConsoleAPI::info("Int2:".$this->unknown2); - ConsoleAPI::info("Int3:".$this->unknown3); - ConsoleAPI::info("Byte4:".$this->unknown4); - ConsoleAPI::info("Byte5:".$this->unknown5); - ConsoleAPI::info("Byte6:".$this->unknown6); - ConsoleAPI::info("Byte7:".$this->unknown7); + $this->eid = $this->getInt(); + $this->x = $this->getInt(); + $this->z = $this->getInt(); + $this->y = $this->getByte(); + $this->block = $this->getByte(); + $this->meta = $this->getByte(); + $this->face = $this->getByte(); } public function encode(){ $this->reset(); - $this->putInt($this->unknown1); - $this->putInt($this->unknown2); - $this->putInt($this->unknown3); - $this->putByte($this->unknown4); - $this->putByte($this->unknown5); - $this->putByte($this->unknown6); - $this->putByte($this->unknown7); - ConsoleAPI::info("Int1:".$this->unknown1); - ConsoleAPI::info("Int2:".$this->unknown2); - ConsoleAPI::info("Int3:".$this->unknown3); - ConsoleAPI::info("Byte4:".$this->unknown4); - ConsoleAPI::info("Byte5:".$this->unknown5); - ConsoleAPI::info("Byte6:".$this->unknown6); - ConsoleAPI::info("Byte7:".$this->unknown7); + $this->putInt($this->eid); + $this->putInt($this->x); + $this->putInt($this->z); + $this->putByte($this->y); + $this->putByte($this->block); + $this->putByte($this->meta); + $this->putByte($this->face); } } \ No newline at end of file