mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Added Tile::saveNBT(), moved Player::broadcastPacket() to Server
This commit is contained in:
@ -30,6 +30,7 @@ use pocketmine\math\Vector3 as Vector3;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\Byte;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
use pocketmine\nbt\tag\Enum;
|
||||
use pocketmine\nbt\tag\Int;
|
||||
use pocketmine\nbt\tag\Short;
|
||||
use pocketmine\nbt\tag\String;
|
||||
@ -53,6 +54,14 @@ class Chest extends Spawnable implements InventoryHolder, Container{
|
||||
$this->checkPairing();
|
||||
}
|
||||
|
||||
public function saveNBT(){
|
||||
$this->namedtag->Inventory = new Enum("Inventory", []);
|
||||
$this->namedtag->Inventory->setTagType(NBT::TAG_Compound);
|
||||
for($index = 0; $index < $this->getSize(); ++$index){
|
||||
$this->setItem($index, $this->inventory->getItem($index));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@ -67,7 +76,7 @@ class Chest extends Spawnable implements InventoryHolder, Container{
|
||||
*/
|
||||
protected function getSlotIndex($index){
|
||||
foreach($this->namedtag->Items as $i => $slot){
|
||||
if($slot["Slot"] === $s){
|
||||
if($slot["Slot"] === $index){
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user