Replace disallowed operators in src/inventory/

This commit is contained in:
Dylan K. Taylor
2022-01-20 19:20:32 +00:00
parent b85fe0e72a
commit e986a0a4f2
3 changed files with 5 additions and 5 deletions

View File

@ -146,7 +146,7 @@ abstract class BaseInventory implements Inventory{
$checkTags = $exact || $item->hasNamedTag(); $checkTags = $exact || $item->hasNamedTag();
foreach($this->getContents() as $index => $i){ foreach($this->getContents() as $index => $i){
if($item->equals($i, $checkDamage, $checkTags) and ($i->getCount() === $count or (!$exact and $i->getCount() > $count))){ if($item->equals($i, $checkDamage, $checkTags) && ($i->getCount() === $count || (!$exact && $i->getCount() > $count))){
return $index; return $index;
} }
} }
@ -224,7 +224,7 @@ abstract class BaseInventory implements Inventory{
$emptySlots[] = $i; $emptySlots[] = $i;
} }
if($slot->canStackWith($item) and $item->getCount() < $item->getMaxStackSize()){ if($slot->canStackWith($item) && $item->getCount() < $item->getMaxStackSize()){
$amount = min($item->getMaxStackSize() - $item->getCount(), $slot->getCount(), $this->getMaxStackSize()); $amount = min($item->getMaxStackSize() - $item->getCount(), $slot->getCount(), $this->getMaxStackSize());
if($amount > 0){ if($amount > 0){
$slot->setCount($slot->getCount() - $amount); $slot->setCount($slot->getCount() - $amount);
@ -367,7 +367,7 @@ abstract class BaseInventory implements Inventory{
} }
public function slotExists(int $slot) : bool{ public function slotExists(int $slot) : bool{
return $slot >= 0 and $slot < $this->getSize(); return $slot >= 0 && $slot < $this->getSize();
} }
public function getListeners() : ObjectSet{ public function getListeners() : ObjectSet{

View File

@ -49,7 +49,7 @@ class PlayerInventory extends SimpleInventory{
} }
public function isHotbarSlot(int $slot) : bool{ public function isHotbarSlot(int $slot) : bool{
return $slot >= 0 and $slot <= $this->getHotbarSize(); return $slot >= 0 && $slot <= $this->getHotbarSize();
} }
/** /**

View File

@ -92,7 +92,7 @@ class CraftingTransaction extends InventoryTransaction{
$haveCount = 0; $haveCount = 0;
foreach($txItems as $j => $txItem){ foreach($txItems as $j => $txItem){
if($txItem->equals($recipeItem, !$wildcards or !$recipeItem->hasAnyDamageValue(), !$wildcards or $recipeItem->hasNamedTag())){ if($txItem->equals($recipeItem, !$wildcards || !$recipeItem->hasAnyDamageValue(), !$wildcards || $recipeItem->hasNamedTag())){
$haveCount += $txItem->getCount(); $haveCount += $txItem->getCount();
unset($txItems[$j]); unset($txItems[$j]);
} }