Bascially supprt armor for MCPE 0.6.1 & 0.7.0

This commit is contained in:
yefengeeeeeeeeeee 2026-07-13 18:55:10 +08:00
parent bec37f62f8
commit 896eb736f0
3 changed files with 24 additions and 14 deletions

View file

@ -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"]);

View file

@ -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;
}

View file

@ -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;