mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-09 15:29:47 +00:00
Rename Container(Trait) -> ContainerTile(Trait)
this allows introducing block variations of these without name conflicts
This commit is contained in:
parent
6578d65cd8
commit
ce4d3aef9e
@ -29,9 +29,9 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\world\World;
|
||||
|
||||
class Barrel extends Spawnable implements Container, Nameable{
|
||||
class Barrel extends Spawnable implements ContainerTile, Nameable{
|
||||
use NameableTrait;
|
||||
use ContainerTrait;
|
||||
use ContainerTileTrait;
|
||||
|
||||
protected Inventory $inventory;
|
||||
|
||||
|
@ -41,11 +41,11 @@ use pocketmine\world\World;
|
||||
use function array_map;
|
||||
use function count;
|
||||
|
||||
class BrewingStand extends Spawnable implements Container, Nameable{
|
||||
class BrewingStand extends Spawnable implements ContainerTile, Nameable{
|
||||
use NameableTrait {
|
||||
addAdditionalSpawnData as addNameSpawnData;
|
||||
}
|
||||
use ContainerTrait;
|
||||
use ContainerTileTrait;
|
||||
|
||||
public const BREW_TIME_TICKS = 400; // Brew time in ticks
|
||||
|
||||
|
@ -34,8 +34,8 @@ use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\network\mcpe\convert\TypeConverter;
|
||||
use pocketmine\world\World;
|
||||
|
||||
class Campfire extends Spawnable implements Container{
|
||||
use ContainerTrait;
|
||||
class Campfire extends Spawnable implements ContainerTile{
|
||||
use ContainerTileTrait;
|
||||
|
||||
private const TAG_FIRST_INPUT_ITEM = "Item1"; //TAG_Compound
|
||||
private const TAG_SECOND_INPUT_ITEM = "Item2"; //TAG_Compound
|
||||
|
@ -33,11 +33,11 @@ use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\World;
|
||||
use function abs;
|
||||
|
||||
class Chest extends Spawnable implements Container, Nameable{
|
||||
class Chest extends Spawnable implements ContainerTile, Nameable{
|
||||
use NameableTrait {
|
||||
addAdditionalSpawnData as addNameSpawnData;
|
||||
}
|
||||
use ContainerTrait {
|
||||
use ContainerTileTrait {
|
||||
onBlockDestroyedHook as containerTraitBlockDestroyedHook;
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,8 @@ use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\world\World;
|
||||
use function count;
|
||||
|
||||
class ChiseledBookshelf extends Tile implements Container{
|
||||
use ContainerTrait;
|
||||
class ChiseledBookshelf extends Tile implements ContainerTile{
|
||||
use ContainerTileTrait;
|
||||
|
||||
private const TAG_LAST_INTERACTED_SLOT = "LastInteractedSlot"; //TAG_Int
|
||||
|
||||
@ -82,7 +82,7 @@ class ChiseledBookshelf extends Tile implements Container{
|
||||
}
|
||||
|
||||
protected function loadItems(CompoundTag $tag) : void{
|
||||
if(($inventoryTag = $tag->getTag(Container::TAG_ITEMS)) instanceof ListTag && $inventoryTag->getTagType() === NBT::TAG_Compound){
|
||||
if(($inventoryTag = $tag->getTag(ContainerTile::TAG_ITEMS)) instanceof ListTag && $inventoryTag->getTagType() === NBT::TAG_Compound){
|
||||
$inventory = $this->inventory;
|
||||
$listeners = $inventory->getListeners()->toArray();
|
||||
$inventory->getListeners()->remove(...$listeners); //prevent any events being fired by initialization
|
||||
@ -107,7 +107,7 @@ class ChiseledBookshelf extends Tile implements Container{
|
||||
$inventory->getListeners()->add(...$listeners);
|
||||
}
|
||||
|
||||
if(($lockTag = $tag->getTag(Container::TAG_LOCK)) instanceof StringTag){
|
||||
if(($lockTag = $tag->getTag(ContainerTile::TAG_LOCK)) instanceof StringTag){
|
||||
$this->lock = $lockTag->getValue();
|
||||
}
|
||||
}
|
||||
@ -126,10 +126,10 @@ class ChiseledBookshelf extends Tile implements Container{
|
||||
}
|
||||
}
|
||||
|
||||
$tag->setTag(Container::TAG_ITEMS, new ListTag($items, NBT::TAG_Compound));
|
||||
$tag->setTag(ContainerTile::TAG_ITEMS, new ListTag($items, NBT::TAG_Compound));
|
||||
|
||||
if($this->lock !== null){
|
||||
$tag->setString(Container::TAG_LOCK, $this->lock);
|
||||
$tag->setString(ContainerTile::TAG_LOCK, $this->lock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\inventory\InventoryHolder;
|
||||
|
||||
interface Container extends InventoryHolder{
|
||||
interface ContainerTile extends InventoryHolder{
|
||||
public const TAG_ITEMS = "Items";
|
||||
public const TAG_LOCK = "Lock";
|
||||
|
@ -33,14 +33,14 @@ use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
/**
|
||||
* This trait implements most methods in the {@link Container} interface. It should only be used by Tiles.
|
||||
* This trait implements most methods in the {@link ContainerTile} interface. It should only be used by Tiles.
|
||||
*/
|
||||
trait ContainerTrait{
|
||||
trait ContainerTileTrait{
|
||||
/** @var string|null */
|
||||
private $lock = null;
|
||||
|
||||
protected function loadItems(CompoundTag $tag) : void{
|
||||
if(($inventoryTag = $tag->getTag(Container::TAG_ITEMS)) instanceof ListTag && $inventoryTag->getTagType() === NBT::TAG_Compound){
|
||||
if(($inventoryTag = $tag->getTag(ContainerTile::TAG_ITEMS)) instanceof ListTag && $inventoryTag->getTagType() === NBT::TAG_Compound){
|
||||
$inventory = $this->getInventory();
|
||||
$listeners = $inventory->getListeners()->toArray();
|
||||
$inventory->getListeners()->remove(...$listeners); //prevent any events being fired by initialization
|
||||
@ -61,7 +61,7 @@ trait ContainerTrait{
|
||||
$inventory->getListeners()->add(...$listeners);
|
||||
}
|
||||
|
||||
if(($lockTag = $tag->getTag(Container::TAG_LOCK)) instanceof StringTag){
|
||||
if(($lockTag = $tag->getTag(ContainerTile::TAG_LOCK)) instanceof StringTag){
|
||||
$this->lock = $lockTag->getValue();
|
||||
}
|
||||
}
|
||||
@ -72,15 +72,15 @@ trait ContainerTrait{
|
||||
$items[] = $item->nbtSerialize($slot);
|
||||
}
|
||||
|
||||
$tag->setTag(Container::TAG_ITEMS, new ListTag($items, NBT::TAG_Compound));
|
||||
$tag->setTag(ContainerTile::TAG_ITEMS, new ListTag($items, NBT::TAG_Compound));
|
||||
|
||||
if($this->lock !== null){
|
||||
$tag->setString(Container::TAG_LOCK, $this->lock);
|
||||
$tag->setString(ContainerTile::TAG_LOCK, $this->lock);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Container::canOpenWith()
|
||||
* @see ContainerTile::canOpenWith()
|
||||
*/
|
||||
public function canOpenWith(string $key) : bool{
|
||||
return $this->lock === null || $this->lock === $key;
|
@ -41,9 +41,9 @@ use pocketmine\world\World;
|
||||
use function array_map;
|
||||
use function max;
|
||||
|
||||
abstract class Furnace extends Spawnable implements Container, Nameable{
|
||||
abstract class Furnace extends Spawnable implements ContainerTile, Nameable{
|
||||
use NameableTrait;
|
||||
use ContainerTrait;
|
||||
use ContainerTileTrait;
|
||||
|
||||
public const TAG_BURN_TIME = "BurnTime";
|
||||
public const TAG_COOK_TIME = "CookTime";
|
||||
|
@ -29,9 +29,9 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\world\World;
|
||||
|
||||
class Hopper extends Spawnable implements Container, Nameable{
|
||||
class Hopper extends Spawnable implements ContainerTile, Nameable{
|
||||
|
||||
use ContainerTrait;
|
||||
use ContainerTileTrait;
|
||||
use NameableTrait;
|
||||
|
||||
private const TAG_TRANSFER_COOLDOWN = "TransferCooldown";
|
||||
|
@ -35,11 +35,11 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\world\World;
|
||||
|
||||
class ShulkerBox extends Spawnable implements Container, Nameable{
|
||||
class ShulkerBox extends Spawnable implements ContainerTile, Nameable{
|
||||
use NameableTrait {
|
||||
addAdditionalSpawnData as addNameSpawnData;
|
||||
}
|
||||
use ContainerTrait;
|
||||
use ContainerTileTrait;
|
||||
|
||||
public const TAG_FACING = "facing";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user