diff --git a/src/Player.php b/src/Player.php index e71d31a5..a7ffee7c 100755 --- a/src/Player.php +++ b/src/Player.php @@ -1266,7 +1266,6 @@ class Player{ if(EventHandler::callEvent(new DataPacketReceiveEvent($this, $packet)) === BaseEvent::DENY){ return; } - switch($packet->pid()){ case 0x01: break; @@ -1359,8 +1358,6 @@ class Player{ return; } - $this->server->send2Discord($this->username . " joined the game"); - $this->auth = true; if(!$this->data->exists("inventory") or ($this->gamemode & 0x01) === 0x01){ if(($this->gamemode & 0x01) === 0x01){ @@ -1610,7 +1607,10 @@ class Player{ //$this->lastChunk = [$packet->chunkX, $packet->chunkZ]; break; case ProtocolInfo::UPDATE_BLOCK_PACKET: - $this->level->setBlock(new Vector3($packet->x, $packet->y, $packet->z), BlockAPI::get($packet->block, $packet->meta)); + if($this->gamemode & 0x01 === 0){ + $this->level->setBlock(new Vector3($packet->x, $packet->y, $packet->z), BlockAPI::get($packet->block, $packet->meta)); + } + break; case ProtocolInfo::USE_ITEM_PACKET: if(!($this->entity instanceof Entity)){ @@ -1658,7 +1658,6 @@ 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; diff --git a/src/entity/Entity.php b/src/entity/Entity.php index fb8fbb37..37e99346 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -628,9 +628,9 @@ class Entity extends Position $fall = $this->level->getBlock(new Vector3(intval($this->x - 0.5), intval(ceil($this->y)), intval($this->z - 0.5))); $down = $this->level->getBlock(new Vector3(intval($this->x - 0.5), intval(ceil($this->y) - 1), intval($this->z - 0.5))); if($fall->isFullBlock === false or $down->isFullBlock === false){ - $this->server->api->entity->drop($this, BlockAPI::getItem($this->data["Tile"] & 0xFFFF, 0, 1), true); + $this->server->api->entity->drop($this, BlockAPI::getItem($this->data["Tile"] & 0xFFFF, $this->data["Metadata"], 1), true); } else{ - $this->level->setBlock($fall, BlockAPI::get($this->data["Tile"]), true, false, true); + $this->level->setBlock($fall, BlockAPI::get($this->data["Tile"], $this->data["Metadata"]), true, false, true); } $this->server->api->handle("entity.motion", $this); $this->close(); @@ -969,13 +969,13 @@ class Entity extends Position $player->dataPacket($pk); break; case ENTITY_FALLING: - $pk = new AddEntityPacket(); + $pk = new AddEntityPacket(); //TODO fix $pk->eid = $this->eid; $pk->type = $this->type; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; - $pk->did = - $this->data["Tile"]; + $pk->did = -($this->data["Tile"] | $this->data["Metadata"] << 0x10); $player->dataPacket($pk); $pk = new SetEntityMotionPacket(); @@ -1251,10 +1251,7 @@ class Entity extends Position public function sendMotion() { $pk = new SetEntityMotionPacket(); - $pk->eid = $this->eid; - $pk->speedX = $this->speedX; - $pk->speedY = $this->speedY; - $pk->speedZ = $this->speedZ; + $pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]]; $this->server->api->player->broadcastPacket($this->level->players, $pk); } diff --git a/src/entity/ai/EntityAI.php b/src/entity/ai/EntityAI.php index 96ff9c09..14a4648c 100644 --- a/src/entity/ai/EntityAI.php +++ b/src/entity/ai/EntityAI.php @@ -55,7 +55,7 @@ class EntityAI } public function updateTasks(){ - if(!isset($entity) or !($this->entity instanceof Entity)){ + if(!isset($this->entity) or !($this->entity instanceof Entity)){ return; } foreach($this->tasks as $t){ diff --git a/src/material/block/GenericBlock.php b/src/material/block/GenericBlock.php index 7fbb33a2..ba5ffaa2 100644 --- a/src/material/block/GenericBlock.php +++ b/src/material/block/GenericBlock.php @@ -61,6 +61,7 @@ class GenericBlock extends Block{ "y" => $this->y + 0.5, "z" => $this->z + 0.5, "Tile" => $this->id, + "Metadata" => $this->getMetadata() ); $server = ServerAPI::request(); $this->level->setBlock($this, new AirBlock(), false, false, true); diff --git a/src/network/protocol/packet/UpdateBlockPacket.php b/src/network/protocol/packet/UpdateBlockPacket.php index 020fc63b..230e969b 100644 --- a/src/network/protocol/packet/UpdateBlockPacket.php +++ b/src/network/protocol/packet/UpdateBlockPacket.php @@ -12,7 +12,6 @@ class UpdateBlockPacket extends RakNetDataPacket{ } public function decode(){ - } public function encode(){ diff --git a/src/network/protocol/packet/UseItemPacket.php b/src/network/protocol/packet/UseItemPacket.php index 0136ed5b..b4807724 100644 --- a/src/network/protocol/packet/UseItemPacket.php +++ b/src/network/protocol/packet/UseItemPacket.php @@ -25,7 +25,7 @@ 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->getShort(); $this->eid = $this->getInt(); $this->fx = $this->getFloat(); $this->fy = $this->getFloat();