More hasFiniteResources() usages

This commit is contained in:
Dylan K. Taylor 2019-03-31 16:51:43 +01:00
parent f8ce7797db
commit c59a2d1b93
4 changed files with 7 additions and 7 deletions

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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));
}