mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-09 23:39:43 +00:00
Remove CampfireInventory
This commit is contained in:
parent
76528b20c1
commit
15bb0c705c
@ -23,7 +23,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\block\inventory\CampfireInventory;
|
|
||||||
use pocketmine\block\tile\Campfire as TileCampfire;
|
use pocketmine\block\tile\Campfire as TileCampfire;
|
||||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||||
use pocketmine\block\utils\LightableTrait;
|
use pocketmine\block\utils\LightableTrait;
|
||||||
@ -39,6 +38,7 @@ use pocketmine\event\block\CampfireCookEvent;
|
|||||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||||
use pocketmine\event\entity\EntityDamageEvent;
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
use pocketmine\inventory\Inventory;
|
use pocketmine\inventory\Inventory;
|
||||||
|
use pocketmine\inventory\SimpleInventory;
|
||||||
use pocketmine\item\Durable;
|
use pocketmine\item\Durable;
|
||||||
use pocketmine\item\enchantment\VanillaEnchantments;
|
use pocketmine\item\enchantment\VanillaEnchantments;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
@ -72,13 +72,23 @@ class Campfire extends Transparent{
|
|||||||
* @deprecated This was added by mistake. It can't be relied on as the inventory won't be initialized if this block
|
* @deprecated This was added by mistake. It can't be relied on as the inventory won't be initialized if this block
|
||||||
* has never been set in the world.
|
* has never been set in the world.
|
||||||
*/
|
*/
|
||||||
protected CampfireInventory $inventory;
|
protected Inventory $inventory;
|
||||||
|
|
||||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
||||||
parent::__construct($idInfo, $name, $typeInfo);
|
parent::__construct($idInfo, $name, $typeInfo);
|
||||||
//TODO: this should never have been in the block - it creates problems for setting blocks in different positions
|
//TODO: this should never have been in the block - it creates problems for setting blocks in different positions
|
||||||
//as inventories aren't designed to be cloned
|
//as inventories aren't designed to be cloned
|
||||||
$this->inventory = new CampfireInventory();
|
$this->inventory = self::createInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* TODO: we need to explore why this is being created in multiple places
|
||||||
|
*/
|
||||||
|
public static function createInventory() : Inventory{
|
||||||
|
$result = new SimpleInventory(4);
|
||||||
|
$result->setMaxStackSize(1);
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,7 +109,7 @@ class Campfire extends Transparent{
|
|||||||
$this->inventory = $tile->getInventory();
|
$this->inventory = $tile->getInventory();
|
||||||
$this->cookingTimes = $tile->getCookingTimes();
|
$this->cookingTimes = $tile->getCookingTimes();
|
||||||
}else{
|
}else{
|
||||||
$this->inventory = new CampfireInventory();
|
$this->inventory = self::createInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -143,7 +153,7 @@ class Campfire extends Transparent{
|
|||||||
* @deprecated This was added by mistake. It can't be relied on as the inventory won't be initialized if this block
|
* @deprecated This was added by mistake. It can't be relied on as the inventory won't be initialized if this block
|
||||||
* has never been set in the world.
|
* has never been set in the world.
|
||||||
*/
|
*/
|
||||||
public function getInventory() : CampfireInventory{
|
public function getInventory() : Inventory{
|
||||||
return $this->inventory;
|
return $this->inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
<?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\inventory;
|
|
||||||
|
|
||||||
use pocketmine\inventory\SimpleInventory;
|
|
||||||
|
|
||||||
final class CampfireInventory extends SimpleInventory{
|
|
||||||
public function __construct(){
|
|
||||||
parent::__construct(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMaxStackSize() : int{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,7 +23,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\tile;
|
namespace pocketmine\block\tile;
|
||||||
|
|
||||||
use pocketmine\block\inventory\CampfireInventory;
|
use pocketmine\block\Campfire as BlockCampfire;
|
||||||
|
use pocketmine\inventory\Inventory;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
@ -44,16 +45,16 @@ class Campfire extends Spawnable implements ContainerTile{
|
|||||||
private const TAG_THIRD_COOKING_TIME = "ItemTime3"; //TAG_Int
|
private const TAG_THIRD_COOKING_TIME = "ItemTime3"; //TAG_Int
|
||||||
private const TAG_FOURTH_COOKING_TIME = "ItemTime4"; //TAG_Int
|
private const TAG_FOURTH_COOKING_TIME = "ItemTime4"; //TAG_Int
|
||||||
|
|
||||||
protected CampfireInventory $inventory;
|
protected Inventory $inventory;
|
||||||
/** @var array<int, int> */
|
/** @var array<int, int> */
|
||||||
private array $cookingTimes = [];
|
private array $cookingTimes = [];
|
||||||
|
|
||||||
public function __construct(World $world, Vector3 $pos){
|
public function __construct(World $world, Vector3 $pos){
|
||||||
parent::__construct($world, $pos);
|
parent::__construct($world, $pos);
|
||||||
$this->inventory = new CampfireInventory();
|
$this->inventory = BlockCampfire::createInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInventory() : CampfireInventory{
|
public function getInventory() : Inventory{
|
||||||
return $this->inventory;
|
return $this->inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user