mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
More hasFiniteResources() usages
This commit is contained in:
parent
f8ce7797db
commit
c59a2d1b93
@ -1527,7 +1527,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
}
|
||||
|
||||
public function getDrops() : array{
|
||||
if(!$this->isCreative()){
|
||||
if($this->hasFiniteResources()){
|
||||
return parent::getDrops();
|
||||
}
|
||||
|
||||
@ -1535,7 +1535,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
}
|
||||
|
||||
public function getXpDropAmount() : int{
|
||||
if(!$this->isCreative()){
|
||||
if($this->hasFiniteResources()){
|
||||
return parent::getXpDropAmount();
|
||||
}
|
||||
|
||||
@ -2052,7 +2052,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
}else{
|
||||
$this->inventory->swap($this->inventory->getHeldItemIndex(), $existing);
|
||||
}
|
||||
}elseif($this->isCreative(true)){ //TODO: plugins won't know this isn't going to execute
|
||||
}elseif(!$this->hasFiniteResources()){ //TODO: plugins won't know this isn't going to execute
|
||||
$firstEmpty = $this->inventory->firstEmpty();
|
||||
if($firstEmpty === -1){ //full inventory
|
||||
$this->inventory->setItemInHand($item);
|
||||
|
@ -100,7 +100,7 @@ class Painting extends Entity{
|
||||
|
||||
if($this->lastDamageCause instanceof EntityDamageByEntityEvent){
|
||||
$killer = $this->lastDamageCause->getDamager();
|
||||
if($killer instanceof Player and $killer->isCreative()){
|
||||
if($killer instanceof Player and !$killer->hasFiniteResources()){
|
||||
$drops = false;
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class CreativeInventoryAction extends InventoryAction{
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(Player $source) : bool{
|
||||
return $source->isCreative(true) and
|
||||
return !$source->hasFiniteResources() and
|
||||
($this->actionType === self::TYPE_DELETE_ITEM or Item::getCreativeItemIndex($this->sourceItem) !== -1);
|
||||
}
|
||||
|
||||
|
@ -1672,12 +1672,12 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
|
||||
$drops = [];
|
||||
if($player === null or !$player->isCreative()){
|
||||
if($player === null or $player->hasFiniteResources()){
|
||||
$drops = array_merge(...array_map(function(Block $block) use ($item) : array{ return $block->getDrops($item); }, $affectedBlocks));
|
||||
}
|
||||
|
||||
$xpDrop = 0;
|
||||
if($player !== null and !$player->isCreative()){
|
||||
if($player !== null and $player->hasFiniteResources()){
|
||||
$xpDrop = array_sum(array_map(function(Block $block) use ($item) : int{ return $block->getXpDropForTool($item); }, $affectedBlocks));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user