mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-17 00:44:08 +00:00
Use Item->isNull() more
This commit is contained in:
parent
61cfdac6a1
commit
ef6250967f
@ -226,7 +226,7 @@ abstract class BaseInventory implements Inventory{
|
||||
if(($diff = $slot->getMaxStackSize() - $slot->getCount()) > 0){
|
||||
$item->setCount($item->getCount() - $diff);
|
||||
}
|
||||
}elseif($slot->getId() === Item::AIR){
|
||||
}elseif($slot->isNull()){
|
||||
$item->setCount($item->getCount() - $this->getMaxStackSize());
|
||||
}
|
||||
|
||||
@ -252,7 +252,7 @@ abstract class BaseInventory implements Inventory{
|
||||
|
||||
for($i = 0; $i < $this->getSize(); ++$i){
|
||||
$item = $this->getItem($i);
|
||||
if($item->getId() === Item::AIR or $item->getCount() <= 0){
|
||||
if($item->isNull()){
|
||||
$emptySlots[] = $i;
|
||||
}
|
||||
|
||||
@ -307,7 +307,7 @@ abstract class BaseInventory implements Inventory{
|
||||
|
||||
for($i = 0; $i < $this->getSize(); ++$i){
|
||||
$item = $this->getItem($i);
|
||||
if($item->getId() === Item::AIR or $item->getCount() <= 0){
|
||||
if($item->isNull()){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ class SimpleInventoryTransaction implements InventoryTransaction{
|
||||
*/
|
||||
protected function matchItems(array &$needItems, array &$haveItems) : bool{
|
||||
foreach($this->actions as $key => $action){
|
||||
if($action->getTargetItem()->getId() !== Item::AIR){
|
||||
if(!$action->getTargetItem()->isNull()){
|
||||
$needItems[] = $action->getTargetItem();
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ class SimpleInventoryTransaction implements InventoryTransaction{
|
||||
return false;
|
||||
}
|
||||
|
||||
if($action->getSourceItem()->getId() !== Item::AIR){
|
||||
if(!$action->getSourceItem()->isNull()){
|
||||
$haveItems[] = $action->getSourceItem();
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
|
||||
$d = $item->nbtSerialize($index);
|
||||
|
||||
if($item->getId() === Item::AIR or $item->getCount() <= 0){
|
||||
if($item->isNull()){
|
||||
if($i >= 0){
|
||||
unset($this->namedtag->Items[$i]);
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ class FlowerPot extends Spawnable{
|
||||
}
|
||||
|
||||
public function isEmpty() : bool{
|
||||
return $this->getItem()->getId() === Item::AIR;
|
||||
return $this->getItem()->isNull();
|
||||
}
|
||||
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt){
|
||||
|
@ -159,7 +159,7 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
|
||||
$d = $item->nbtSerialize($index);
|
||||
|
||||
if($item->getId() === Item::AIR or $item->getCount() <= 0){
|
||||
if($item->isNull()){
|
||||
if($i >= 0){
|
||||
unset($this->namedtag->Items[$i]);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class ItemFrame extends Spawnable{
|
||||
}
|
||||
|
||||
public function hasItem() : bool{
|
||||
return $this->getItem()->getId() !== Item::AIR;
|
||||
return !$this->getItem()->isNull();
|
||||
}
|
||||
|
||||
public function getItem() : Item{
|
||||
@ -57,7 +57,7 @@ class ItemFrame extends Spawnable{
|
||||
}
|
||||
|
||||
public function setItem(Item $item = null){
|
||||
if($item !== null and $item->getId() !== Item::AIR){
|
||||
if($item !== null and !$item->isNull()){
|
||||
$this->namedtag->Item = $item->nbtSerialize(-1, "Item");
|
||||
}else{
|
||||
unset($this->namedtag->Item);
|
||||
|
Loading…
x
Reference in New Issue
Block a user