Files
PocketMine-MP/src/block/tile/Barrel.php
2022-06-04 18:16:32 +01:00

77 lines
1.8 KiB
PHP

<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block\tile;
use pocketmine\block\inventory\BarrelInventory;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\world\World;
class Barrel extends Spawnable implements Container, Nameable{
use NameableTrait;
use ContainerTrait;
protected BarrelInventory $inventory;
public function __construct(World $world, Vector3 $pos){
parent::__construct($world, $pos);
$this->inventory = new BarrelInventory($this->position);
}
public function readSaveData(CompoundTag $nbt) : void{
$this->loadName($nbt);
$this->loadItems($nbt);
}
protected function writeSaveData(CompoundTag $nbt) : void{
$this->saveName($nbt);
$this->saveItems($nbt);
}
public function close() : void{
if(!$this->closed){
$this->inventory->removeAllViewers();
parent::close();
}
}
/**
* @return BarrelInventory
*/
public function getInventory(){
return $this->inventory;
}
/**
* @return BarrelInventory
*/
public function getRealInventory(){
return $this->inventory;
}
public function getDefaultName() : string{
return "Barrel";
}
}