mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Remove circular dependency between Item and NBT modules (#121)
This commit is contained in:
@ -277,9 +277,9 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
if($item["Slot"] >= 0 and $item["Slot"] < 9){ //Hotbar
|
||||
$this->inventory->setHotbarSlotIndex($item["Slot"], isset($item["TrueSlot"]) ? $item["TrueSlot"] : -1);
|
||||
}elseif($item["Slot"] >= 100 and $item["Slot"] < 104){ //Armor
|
||||
$this->inventory->setItem($this->inventory->getSize() + $item["Slot"] - 100, NBT::getItemHelper($item));
|
||||
$this->inventory->setItem($this->inventory->getSize() + $item["Slot"] - 100, ItemItem::nbtDeserialize($item));
|
||||
}else{
|
||||
$this->inventory->setItem($item["Slot"] - 9, NBT::getItemHelper($item));
|
||||
$this->inventory->setItem($item["Slot"] - 9, ItemItem::nbtDeserialize($item));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -407,7 +407,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
if($hotbarSlot !== -1){
|
||||
$item = $this->inventory->getItem($hotbarSlot);
|
||||
if($item->getId() !== 0 and $item->getCount() > 0){
|
||||
$tag = NBT::putItemHelper($item, $slot);
|
||||
$tag = $item->nbtSerialize($slot);
|
||||
$tag->TrueSlot = new ByteTag("TrueSlot", $hotbarSlot);
|
||||
$this->namedtag->Inventory[$slot] = $tag;
|
||||
|
||||
@ -429,14 +429,14 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
//$slotCount = (($this instanceof Player and ($this->gamemode & 0x01) === 1) ? Player::CREATIVE_SLOTS : Player::SURVIVAL_SLOTS) + 9;
|
||||
for($slot = 9; $slot < $slotCount; ++$slot){
|
||||
$item = $this->inventory->getItem($slot - 9);
|
||||
$this->namedtag->Inventory[$slot] = NBT::putItemHelper($item, $slot);
|
||||
$this->namedtag->Inventory[$slot] = $item->nbtSerialize($slot);
|
||||
}
|
||||
|
||||
//Armor
|
||||
for($slot = 100; $slot < 104; ++$slot){
|
||||
$item = $this->inventory->getItem($this->inventory->getSize() + $slot - 100);
|
||||
if($item instanceof ItemItem and $item->getId() !== ItemItem::AIR){
|
||||
$this->namedtag->Inventory[$slot] = NBT::putItemHelper($item, $slot);
|
||||
$this->namedtag->Inventory[$slot] = $item->nbtSerialize($slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user