mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
wtf PhpStorm
This commit is contained in:
parent
5e88fda824
commit
fefc9b5278
118
src/pocketmine/block/tile/BrewingStand.php
Normal file
118
src/pocketmine/block/tile/BrewingStand.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?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\inventory\BrewingStandInventory;
|
||||
use pocketmine\inventory\CallbackInventoryChangeListener;
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\world\World;
|
||||
|
||||
class BrewingStand extends Spawnable implements Container, Nameable{
|
||||
|
||||
use ContainerTrait;
|
||||
use NameableTrait;
|
||||
|
||||
private const TAG_BREW_TIME = "BrewTime"; //TAG_Short
|
||||
private const TAG_BREW_TIME_PE = "CookTime"; //TAG_Short
|
||||
private const TAG_MAX_FUEL_TIME = "FuelTotal"; //TAG_Short
|
||||
private const TAG_REMAINING_FUEL_TIME = "Fuel"; //TAG_Short
|
||||
private const TAG_REMAINING_FUEL_TIME_PE = "FuelAmount"; //TAG_Short
|
||||
|
||||
/** @var BrewingStandInventory */
|
||||
private $inventory;
|
||||
|
||||
/** @var int */
|
||||
private $brewTime = 0;
|
||||
/** @var int */
|
||||
private $maxFuelTime = 0;
|
||||
/** @var int */
|
||||
private $remainingFuelTime = 0;
|
||||
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
$this->inventory = new BrewingStandInventory($this);
|
||||
$this->inventory->addChangeListeners(CallbackInventoryChangeListener::onAnyChange(function(Inventory $unused){
|
||||
$this->world->scheduleDelayedBlockUpdate($this->getBlock(), 0);
|
||||
}));
|
||||
parent::__construct($world, $pos);
|
||||
}
|
||||
|
||||
public function readSaveData(CompoundTag $nbt) : void{
|
||||
$this->loadName($nbt);
|
||||
$this->loadItems($nbt);
|
||||
|
||||
$this->brewTime = $nbt->getShort(self::TAG_BREW_TIME, $nbt->getShort(self::TAG_BREW_TIME_PE, 0));
|
||||
$this->maxFuelTime = $nbt->getShort(self::TAG_MAX_FUEL_TIME, 0);
|
||||
$this->remainingFuelTime = $nbt->getShort(self::TAG_REMAINING_FUEL_TIME, $nbt->getShort(self::TAG_REMAINING_FUEL_TIME_PE, 0));
|
||||
if($this->maxFuelTime === 0){
|
||||
$this->maxFuelTime = $this->remainingFuelTime;
|
||||
}
|
||||
if($this->remainingFuelTime === 0){
|
||||
$this->maxFuelTime = $this->remainingFuelTime = $this->brewTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected function writeSaveData(CompoundTag $nbt) : void{
|
||||
$this->saveName($nbt);
|
||||
$this->saveItems($nbt);
|
||||
|
||||
$nbt->setShort(self::TAG_BREW_TIME_PE, $this->brewTime);
|
||||
$nbt->setShort(self::TAG_MAX_FUEL_TIME, $this->maxFuelTime);
|
||||
$nbt->setShort(self::TAG_REMAINING_FUEL_TIME_PE, $this->remainingFuelTime);
|
||||
}
|
||||
|
||||
public function getDefaultName() : string{
|
||||
return "Brewing Stand";
|
||||
}
|
||||
|
||||
public function close() : void{
|
||||
if(!$this->closed){
|
||||
$this->inventory->removeAllViewers(true);
|
||||
$this->inventory = null;
|
||||
|
||||
parent::close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BrewingStandInventory
|
||||
*/
|
||||
public function getInventory(){
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BrewingStandInventory
|
||||
*/
|
||||
public function getRealInventory(){
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
public function onUpdate() : bool{
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
}
|
38
src/pocketmine/inventory/BrewingStandInventory.php
Normal file
38
src/pocketmine/inventory/BrewingStandInventory.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?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\inventory;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\types\WindowTypes;
|
||||
|
||||
class BrewingStandInventory extends ContainerInventory{
|
||||
|
||||
public function __construct(Vector3 $holder, int $size = 5, array $items = []){
|
||||
parent::__construct($holder, $size, $items);
|
||||
}
|
||||
|
||||
public function getNetworkType() : int{
|
||||
return WindowTypes::BREWING_STAND;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user