diff --git a/src/Player.php b/src/Player.php index 1a9949d00..4f85e86af 100644 --- a/src/Player.php +++ b/src/Player.php @@ -1153,7 +1153,7 @@ class Player{ case ProtocolInfo::PING_PACKET: case ProtocolInfo::PONG_PACKET: case ProtocolInfo::MOVE_PLAYER_PACKET: - case ProtocolInfo::MOVE_REQUEST_CHUNK: + case ProtocolInfo::REQUEST_CHUNK_PACKET: case ProtocolInfo::ANIMATE_PACKET: case ProtocolInfo::SET_HEALTH_PACKET: continue; @@ -1588,8 +1588,7 @@ class Player{ 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){ @@ -1631,7 +1630,7 @@ class Player{ $data["posX"] = $packet->posX; $data["posY"] = $packet->posY; $data["posZ"] = $packet->posZ; - + if($packet->face >= 0 and $packet->face <= 5){ //Use Block, place if($this->entity->inAction === true){ $this->entity->inAction = false; @@ -1639,6 +1638,7 @@ class Player{ } if($this->blocked === true or ($this->entity->position instanceof Vector3 and $blockVector->distance($this->entity->position) > 10)){ + }elseif($this->getSlot($this->slot)->getID() !== $packet->item or ($this->getSlot($this->slot)->isTool() === false and $this->getSlot($this->slot)->getMetadata() !== $packet->meta)){ $this->sendInventorySlot($this->slot); }else{ @@ -2042,15 +2042,15 @@ class Player{ $pk->y = $this->windows[$packet->windowid]->y; $pk->z = $this->windows[$packet->windowid]->z; $pk->case1 = 1; - $pk->case2 = 2; + $pk->case2 = 0; $this->server->api->player->broadcastPacket($this->level->players, $pk); } } unset($this->windows[$packet->windowid]); - $this->dataPacket(ProtocolInfo::CONTAINER_CLOSE_PACKET, array( - "windowid" => $packet->windowid, - )); + $pk = new ContainerClosePacket; + $pk->windowid = $packet->windowid; + $this->dataPacket($pk); break; case ProtocolInfo::CONTAINER_SET_SLOT_PACKET: if($this->spawned === false or $this->blocked === true){ diff --git a/src/network/protocol/packet/ContainerClosePacket.php b/src/network/protocol/packet/ContainerClosePacket.php index 06f5a63db..1b962e4f9 100644 --- a/src/network/protocol/packet/ContainerClosePacket.php +++ b/src/network/protocol/packet/ContainerClosePacket.php @@ -27,7 +27,7 @@ class ContainerClosePacket extends RakNetDataPacket{ } public function decode(){ - $this->windowid = $this->getInt(); + $this->windowid = $this->getByte(); } public function encode(){ diff --git a/src/network/protocol/packet/RemoveBlockPacket.php b/src/network/protocol/packet/RemoveBlockPacket.php index f30aa142e..2063852d3 100644 --- a/src/network/protocol/packet/RemoveBlockPacket.php +++ b/src/network/protocol/packet/RemoveBlockPacket.php @@ -32,8 +32,8 @@ class RemoveBlockPacket extends RakNetDataPacket{ public function decode(){ $this->eid = $this->getInt(); $this->x = $this->getInt(); - $this->y = $this->getInt(); $this->z = $this->getInt(); + $this->y = $this->getByte(); } public function encode(){ diff --git a/src/utils/Cache.php b/src/utils/Cache.php index f9dc362c5..3d05eee60 100644 --- a/src/utils/Cache.php +++ b/src/utils/Cache.php @@ -28,7 +28,7 @@ class Cache{ public static function get($identifier){ if(isset(self::$cached[$identifier])){ - self::$cached[$identifier][1] += $minTTL; + self::$cached[$identifier][1] = microtime(true) + self::$cached[$identifier][2]; return self::$cached[$identifier][0]; } return false; diff --git a/src/world/Entity.php b/src/world/Entity.php index cbd1b8f04..1bb29f39f 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -1000,9 +1000,9 @@ class Entity extends Position{ $this->server->api->dhandle("entity.event", array("entity" => $this, "event" => 2)); //Ouch! sound } if($this->player instanceof Player){ - $this->player->dataPacket(ProtocolInfo::SET_HEALTH_PACKET, array( - "health" => $this->health, - )); + $pk = new SetHealthPacket; + $pk->health = $this->health; + $this->player->dataPacket($pk); } if($this->health <= 0 and $this->dead === false){ $this->spawnDrops();