mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 19:37:17 +00:00
Added armor change $source parameter
This commit is contained in:
parent
706e1099a1
commit
762c27affe
@ -1722,21 +1722,19 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$s = Item::get($s + 256, 0, 1);
|
||||
}
|
||||
$slot = $this->inventory->getArmorItem($i);
|
||||
if($slot->getID() !== Item::AIR and $s->getID() === Item::AIR){
|
||||
$this->inventory->setArmorItem($i, Item::get(Item::AIR, 0, 1));
|
||||
if($slot->getID() !== Item::AIR and $s->getID() === Item::AIR){ //Removes a piece of armor
|
||||
$this->inventory->setArmorItem($i, Item::get(Item::AIR, 0, 1), $this);
|
||||
$this->inventory->addItem($slot);
|
||||
$this->inventory->sendArmorContents($this);
|
||||
}elseif($s->getID() !== Item::AIR and $slot->getID() === Item::AIR and ($sl = $this->inventory->first($s)) !== -1){
|
||||
if($this->inventory->setArmorItem($i, $this->inventory->getItem($sl)) === false){
|
||||
$this->inventory->sendContents($this);
|
||||
if($this->inventory->setArmorItem($i, $this->inventory->getItem($sl), $this) === false){
|
||||
$this->inventory->sendArmorContents($this);
|
||||
}else{
|
||||
$this->inventory->setItem($sl, Item::get(Item::AIR, 0, 1), $this);
|
||||
$this->inventory->sendArmorContents($this);
|
||||
}
|
||||
}elseif($s->getID() !== Item::AIR and $slot->getID() !== Item::AIR and ($slot->getID() !== $s->getID() or $slot->getDamage() !== $s->getDamage()) and ($sl = $this->inventory->first($s)) !== -1){
|
||||
if($this->inventory->setArmorItem($i, $this->inventory->getItem($sl)) === false){
|
||||
$this->inventory->sendContents($this);
|
||||
if($this->inventory->setArmorItem($i, $this->inventory->getItem($sl), $this) === false){
|
||||
$this->inventory->sendArmorContents($this);
|
||||
}else{
|
||||
$this->inventory->setItem($sl, $slot, $this);
|
||||
|
@ -160,8 +160,8 @@ class PlayerInventory extends BaseInventory{
|
||||
return $this->getItem($this->getSize() + $index);
|
||||
}
|
||||
|
||||
public function setArmorItem($index, Item $item){
|
||||
return $this->setItem($this->getSize() + $index, $item);
|
||||
public function setArmorItem($index, Item $item, $source = null){
|
||||
return $this->setItem($this->getSize() + $index, $item, $source);
|
||||
}
|
||||
|
||||
public function getHelmet(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user