mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
Clean up item handling of blocks
This commit is contained in:
parent
ed1c511c3c
commit
1427da0aeb
@ -184,17 +184,13 @@ class Bed extends Transparent{
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
if($this->isHeadPart()){
|
||||
return [$this->getItem()];
|
||||
return parent::getDropsForCompatibleTool($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getPickedItem() : Item{
|
||||
return $this->getItem();
|
||||
}
|
||||
|
||||
private function getItem() : Item{
|
||||
public function getItem() : Item{
|
||||
$tile = $this->getLevel()->getTile($this);
|
||||
if($tile instanceof TileBed){
|
||||
return ItemFactory::get($this->getItemId(), $tile->getColor());
|
||||
|
@ -120,6 +120,10 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getItem() : Item{
|
||||
return ItemFactory::get($this->getItemId(), $this->getVariant());
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @return int
|
||||
@ -127,7 +131,6 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
public function getRuntimeId() : int{
|
||||
return BlockFactory::toStaticRuntimeId($this->getId(), $this->getDamage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@ -467,9 +470,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
* @return Item[]
|
||||
*/
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get($this->getItemId(), $this->getVariant())
|
||||
];
|
||||
return [$this->getItem()];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -480,9 +481,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
* @return Item[]
|
||||
*/
|
||||
public function getSilkTouchDrops(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get($this->getItemId(), $this->getVariant())
|
||||
];
|
||||
return [$this->getItem()];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -524,7 +523,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
* @return Item
|
||||
*/
|
||||
public function getPickedItem() : Item{
|
||||
return ItemFactory::get($this->getItemId(), $this->getVariant());
|
||||
return $this->getItem();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,20 +83,12 @@ class Skull extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
private function getItem() : Item{
|
||||
public function getItem() : Item{
|
||||
$tile = $this->level->getTile($this);
|
||||
return ItemFactory::get(Item::SKULL, $tile instanceof TileSkull ? $tile->getType() : 0);
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [$this->getItem()];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getPickedItem() : Item{
|
||||
return $this->getItem();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user