Block: Rename getItem() to asItem()

this has clearer meaning and is less likely to collide with other things.
This commit is contained in:
Dylan K. Taylor 2019-02-24 10:23:40 +00:00
parent ff35736bf9
commit 0bd1c1529e
7 changed files with 10 additions and 10 deletions

View File

@ -202,7 +202,7 @@ class Bed extends Transparent{
return []; return [];
} }
public function getItem() : Item{ public function asItem() : Item{
return ItemFactory::get($this->idInfo->getItemId(), $this->color->getMagicNumber()); return ItemFactory::get($this->idInfo->getItemId(), $this->color->getMagicNumber());
} }

View File

@ -107,7 +107,7 @@ class Block extends Position implements BlockIds, Metadatable{
return $this->idInfo->getBlockId(); return $this->idInfo->getBlockId();
} }
public function getItem() : Item{ public function asItem() : Item{
return ItemFactory::get($this->idInfo->getItemId(), $this->idInfo->getVariant()); return ItemFactory::get($this->idInfo->getItemId(), $this->idInfo->getVariant());
} }
@ -511,7 +511,7 @@ class Block extends Position implements BlockIds, Metadatable{
* @return Item[] * @return Item[]
*/ */
public function getDropsForCompatibleTool(Item $item) : array{ public function getDropsForCompatibleTool(Item $item) : array{
return [$this->getItem()]; return [$this->asItem()];
} }
/** /**
@ -522,7 +522,7 @@ class Block extends Position implements BlockIds, Metadatable{
* @return Item[] * @return Item[]
*/ */
public function getSilkTouchDrops(Item $item) : array{ public function getSilkTouchDrops(Item $item) : array{
return [$this->getItem()]; return [$this->asItem()];
} }
/** /**
@ -564,7 +564,7 @@ class Block extends Position implements BlockIds, Metadatable{
* @return Item * @return Item
*/ */
public function getPickedItem() : Item{ public function getPickedItem() : Item{
return $this->getItem(); return $this->asItem();
} }
/** /**

View File

@ -82,7 +82,7 @@ class NetherWartPlant extends Flowable{
public function getDropsForCompatibleTool(Item $item) : array{ public function getDropsForCompatibleTool(Item $item) : array{
return [ return [
$this->getItem()->setCount($this->age === 3 ? mt_rand(2, 4) : 1) $this->asItem()->setCount($this->age === 3 ? mt_rand(2, 4) : 1)
]; ];
} }

View File

@ -95,7 +95,7 @@ class Skull extends Flowable{
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
} }
public function getItem() : Item{ public function asItem() : Item{
return ItemFactory::get(Item::SKULL, $this->type); return ItemFactory::get(Item::SKULL, $this->type);
} }

View File

@ -136,6 +136,6 @@ abstract class Slab extends Transparent{
} }
public function getDropsForCompatibleTool(Item $item) : array{ public function getDropsForCompatibleTool(Item $item) : array{
return [$this->getItem()->setCount($this->slabType === SlabType::DOUBLE() ? 2 : 1)]; return [$this->asItem()->setCount($this->slabType === SlabType::DOUBLE() ? 2 : 1)];
} }
} }

View File

@ -66,7 +66,7 @@ abstract class Stem extends Crops{
public function getDropsForCompatibleTool(Item $item) : array{ public function getDropsForCompatibleTool(Item $item) : array{
return [ return [
$this->getItem()->setCount(mt_rand(0, 2)) $this->asItem()->setCount(mt_rand(0, 2))
]; ];
} }
} }

View File

@ -110,7 +110,7 @@ class FallingBlock extends Entity{
$block = $this->level->getBlock($pos); $block = $this->level->getBlock($pos);
if($block->getId() > 0 and $block->isTransparent() and !$block->canBeReplaced()){ if($block->getId() > 0 and $block->isTransparent() and !$block->canBeReplaced()){
//FIXME: anvils are supposed to destroy torches //FIXME: anvils are supposed to destroy torches
$this->getLevel()->dropItem($this, $this->block->getItem()); $this->getLevel()->dropItem($this, $this->block->asItem());
}else{ }else{
$ev = new EntityBlockChangeEvent($this, $block, $blockTarget ?? $this->block); $ev = new EntityBlockChangeEvent($this, $block, $blockTarget ?? $this->block);
$ev->call(); $ev->call();