diff --git a/src/Player.php b/src/Player.php index 239684bc..cba2df99 100755 --- a/src/Player.php +++ b/src/Player.php @@ -686,6 +686,7 @@ class Player{ $pk->hotbar = $hotbar; $this->dataPacket($pk); } + /** * @param $type * @param $damage @@ -1948,6 +1949,20 @@ class Player{ $data["posY"] = $packet->posY; $data["posZ"] = $packet->posZ; + //nc: check item desync + $heldItem = $this->getHeldItem(); + if($heldItem->getID() != $packet->item || $heldItem->getMetadata() != $packet->meta){ + ConsoleAPI::warn("{$this->username}'s heldItem doesnt match on clientside and serverside when using item. Resending inventory."); + $this->sendInventory(); + if($packet->face >= 0 && $packet->face <= 5){ + $target = $this->level->getBlock($blockVector); + $block = $target->getSide($packet->face); + $this->addBlockUpdateIntoQueue($target->x, $target->y, $target->z, $target->getID(), $target->getMetadata()); + $this->addBlockUpdateIntoQueue($block->x, $block->y, $block->z, $block->getID(), $block->getMetadata()); + } + break; + } + if($packet->face >= 0 and $packet->face <= 5){ //Use Block, place if($this->entity->inAction === true){ $this->entity->inAction = false; diff --git a/src/network/protocol/packet/UseItemPacket.php b/src/network/protocol/packet/UseItemPacket.php index 0136ed5b..32e2c651 100644 --- a/src/network/protocol/packet/UseItemPacket.php +++ b/src/network/protocol/packet/UseItemPacket.php @@ -25,18 +25,18 @@ class UseItemPacket extends RakNetDataPacket{ $this->z = $this->getInt(); $this->face = $this->getInt(); $this->item = $this->getShort(); - $this->meta = $this->getByte(); //Mojang: fix this + $this->meta = $this->getByte(); $this->eid = $this->getInt(); $this->fx = $this->getFloat(); $this->fy = $this->getFloat(); $this->fz = $this->getFloat(); $this->posX = $this->getFloat(); $this->posY = $this->getFloat(); - $this->posZ = $this->getFloat(); + $this->posZ = $this->getFloat(); } public function encode(){ } -} \ No newline at end of file +}