diff --git a/src/API/PlayerAPI.php b/src/API/PlayerAPI.php index 30c3c975..bcdd7222 100644 --- a/src/API/PlayerAPI.php +++ b/src/API/PlayerAPI.php @@ -42,12 +42,10 @@ class PlayerAPI{ public function handle($data, $event){ switch($event){ case "player.death": - if($data["player"]->PROTOCOL <= ProtocolInfo9::CURRENT_PROTOCOL_9){ + if($data["player"]->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){ $data["player"]->isWorkBench = false; $data["player"]->isStoneCutter = false; - if($data["player"]->PROTOCOL < ProtocolInfo6::CURRENT_PROTOCOL_6){ - $data["player"]->isOre = []; - } + $data["player"]->isOre = []; } if(is_numeric($data["cause"])){ $e = $this->server->api->entity->get($data["cause"]); diff --git a/src/Player.php b/src/Player.php index 4be5f629..4e0f8fc3 100755 --- a/src/Player.php +++ b/src/Player.php @@ -3318,10 +3318,16 @@ class Player{ }elseif($s->getID() !== AIR and $slot->getID() === AIR and ($sl = $this->hasItem($s->getID())) !== false){ $this->armor[$i] = $this->getSlot($sl); $this->setSlot($sl, BlockAPI::getItem(AIR, 0, 0), false); + if($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12 && $this->PROTOCOL > ProtocolInfo8::CURRENT_PROTOCOL_8){ + $this->isOre[DIAMOND_HELMET] = true; + } }elseif($s->getID() !== AIR && $slot->getID() !== AIR and ($slot->getID() !== $s->getID() or $slot->getMetadata() !== $s->getMetadata()) and ($sl = $this->hasItem($s->getID())) !== false){ $item = $this->armor[$i]; $this->armor[$i] = $this->getSlot($sl); $this->setSlot($sl, $item, false); + if($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12 && $this->PROTOCOL > ProtocolInfo8::CURRENT_PROTOCOL_8){ + $this->isOre[DIAMOND_HELMET] = true; + } }else{ $packet->slots[$i] = 255; } diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 6d8e2821..215a065a 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1634,10 +1634,10 @@ class Entity extends Position $part->hurtAndBreak($v2, $this->player, helditem: false); if($part->count <= 0) $this->player->setArmor($slot, BlockAPI::getItem(0, 0, 0), send: false); } - if($this->player->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_11 && $this->player->PROTOCOL > ProtocolInfo8::CURRENT_PROTOCOL_8){ + if($this->player->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12 && $this->player->PROTOCOL > ProtocolInfo8::CURRENT_PROTOCOL_8){ $pk = new HurtArmorPacket(); - $pk->health = $part->meta - $v2; - //$this->player->dataPacket($pk); //MCPE 0.6.0 + $pk->health = $v2; //TODO: Verify the real attack health for it + $this->player->entityQueueDataPacket($pk); } $this->player->sendArmor(); } @@ -1721,16 +1721,22 @@ class Entity extends Position $this->updateMetadata(); $this->dead = true; if($this->player instanceof Player){ - if($this->player->PROTOCOL <= ProtocolInfo8::CURRENT_PROTOCOL_8){ - $pk = new EntityEventPacket; - $pk->eid = $this->eid; - $pk->event = EntityEventPacket::ENTITY_DEAD; - $this->player->entityQueueDataPacket($pk); + if($this->player->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){ $this->player->isWorkbench = false; $this->player->isStoneCutter = false; - if($this->player->PROTOCOL < ProtocolInfo6::CURRENT_PROTOCOL_6){ - $this->player->isOre = []; + if(!self::$keepInventory) { + if ($this->player->PROTOCOL <= ProtocolInfo8::CURRENT_PROTOCOL_8) { + $pk = new EntityEventPacket; + $pk->eid = $this->eid; + $pk->event = EntityEventPacket::ENTITY_DEAD; + $this->player->entityQueueDataPacket($pk); + } elseif (isset($this->player->isOre[DIAMOND_HELMET])) { + $pk = new HurtArmorPacket(); + $pk->health = 900; //TODO Verify the real attack health for it + $this->player->entityQueueDataPacket($pk); + } } + $this->player->isOre = []; } $pk = new MoveEntityPacket_PosRot(); $pk->eid = $this->eid;