mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Added VanillaItems::AIR()
we don't usually add VanillaItems entries for blocks since they already exist in VanillaBlocks, but air has a special use case specifically as an itemstack, so we make an exception for this case.
This commit is contained in:
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\ObjectSet;
|
||||
use function array_slice;
|
||||
@ -89,7 +89,7 @@ abstract class BaseInventory implements Inventory{
|
||||
|
||||
public function setItem(int $index, Item $item) : void{
|
||||
if($item->isNull()){
|
||||
$item = ItemFactory::air();
|
||||
$item = VanillaItems::AIR();
|
||||
}else{
|
||||
$item = clone $item;
|
||||
}
|
||||
@ -290,7 +290,7 @@ abstract class BaseInventory implements Inventory{
|
||||
}
|
||||
|
||||
public function clear(int $index) : void{
|
||||
$this->setItem($index, ItemFactory::air());
|
||||
$this->setItem($index, VanillaItems::AIR());
|
||||
}
|
||||
|
||||
public function clearAll() : void{
|
||||
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\VanillaItems;
|
||||
|
||||
/**
|
||||
* This class provides a complete implementation of a regular inventory.
|
||||
@ -49,7 +49,7 @@ class SimpleInventory extends BaseInventory{
|
||||
}
|
||||
|
||||
public function getItem(int $index) : Item{
|
||||
return $this->slots[$index] !== null ? clone $this->slots[$index] : ItemFactory::air();
|
||||
return $this->slots[$index] !== null ? clone $this->slots[$index] : VanillaItems::AIR();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,7 +62,7 @@ class SimpleInventory extends BaseInventory{
|
||||
if($slot !== null){
|
||||
$contents[$i] = clone $slot;
|
||||
}elseif($includeEmpty){
|
||||
$contents[$i] = ItemFactory::air();
|
||||
$contents[$i] = VanillaItems::AIR();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ use pocketmine\inventory\BaseInventory;
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\inventory\transaction\action\SlotChangeAction;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\VanillaItems;
|
||||
|
||||
/**
|
||||
* This class facilitates generating SlotChangeActions to build an inventory transaction.
|
||||
@ -62,7 +62,7 @@ final class TransactionBuilderInventory extends BaseInventory{
|
||||
|
||||
protected function internalSetItem(int $index, Item $item) : void{
|
||||
if(!$item->equalsExact($this->actualInventory->getItem($index))){
|
||||
$this->changedSlots[$index] = $item->isNull() ? ItemFactory::air() : clone $item;
|
||||
$this->changedSlots[$index] = $item->isNull() ? VanillaItems::AIR() : clone $item;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\inventory\transaction\action;
|
||||
use pocketmine\inventory\CreativeInventory;
|
||||
use pocketmine\inventory\transaction\TransactionValidationException;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
/**
|
||||
@ -36,7 +36,7 @@ use pocketmine\player\Player;
|
||||
class CreateItemAction extends InventoryAction{
|
||||
|
||||
public function __construct(Item $sourceItem){
|
||||
parent::__construct($sourceItem, ItemFactory::air());
|
||||
parent::__construct($sourceItem, VanillaItems::AIR());
|
||||
}
|
||||
|
||||
public function validate(Player $source) : void{
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\inventory\transaction\action;
|
||||
|
||||
use pocketmine\inventory\transaction\TransactionValidationException;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
/**
|
||||
@ -35,7 +35,7 @@ use pocketmine\player\Player;
|
||||
class DestroyItemAction extends InventoryAction{
|
||||
|
||||
public function __construct(Item $targetItem){
|
||||
parent::__construct(ItemFactory::air(), $targetItem);
|
||||
parent::__construct(VanillaItems::AIR(), $targetItem);
|
||||
}
|
||||
|
||||
public function validate(Player $source) : void{
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\inventory\transaction\action;
|
||||
use pocketmine\event\player\PlayerDropItemEvent;
|
||||
use pocketmine\inventory\transaction\TransactionValidationException;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
/**
|
||||
@ -35,7 +35,7 @@ use pocketmine\player\Player;
|
||||
class DropItemAction extends InventoryAction{
|
||||
|
||||
public function __construct(Item $targetItem){
|
||||
parent::__construct(ItemFactory::air(), $targetItem);
|
||||
parent::__construct(VanillaItems::AIR(), $targetItem);
|
||||
}
|
||||
|
||||
public function validate(Player $source) : void{
|
||||
|
Reference in New Issue
Block a user