mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 01:39:52 +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{
|
public function getDropsForCompatibleTool(Item $item) : array{
|
||||||
if($this->isHeadPart()){
|
if($this->isHeadPart()){
|
||||||
return [$this->getItem()];
|
return parent::getDropsForCompatibleTool($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPickedItem() : Item{
|
public function getItem() : Item{
|
||||||
return $this->getItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getItem() : Item{
|
|
||||||
$tile = $this->getLevel()->getTile($this);
|
$tile = $this->getLevel()->getTile($this);
|
||||||
if($tile instanceof TileBed){
|
if($tile instanceof TileBed){
|
||||||
return ItemFactory::get($this->getItemId(), $tile->getColor());
|
return ItemFactory::get($this->getItemId(), $tile->getColor());
|
||||||
|
@ -120,6 +120,10 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getItem() : Item{
|
||||||
|
return ItemFactory::get($this->getItemId(), $this->getVariant());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
* @return int
|
* @return int
|
||||||
@ -127,7 +131,6 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
public function getRuntimeId() : int{
|
public function getRuntimeId() : int{
|
||||||
return BlockFactory::toStaticRuntimeId($this->getId(), $this->getDamage());
|
return BlockFactory::toStaticRuntimeId($this->getId(), $this->getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@ -467,9 +470,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 [
|
return [$this->getItem()];
|
||||||
ItemFactory::get($this->getItemId(), $this->getVariant())
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -480,9 +481,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 [
|
return [$this->getItem()];
|
||||||
ItemFactory::get($this->getItemId(), $this->getVariant())
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -524,7 +523,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
* @return Item
|
* @return Item
|
||||||
*/
|
*/
|
||||||
public function getPickedItem() : 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getItem() : Item{
|
public function getItem() : Item{
|
||||||
$tile = $this->level->getTile($this);
|
$tile = $this->level->getTile($this);
|
||||||
return ItemFactory::get(Item::SKULL, $tile instanceof TileSkull ? $tile->getType() : 0);
|
return ItemFactory::get(Item::SKULL, $tile instanceof TileSkull ? $tile->getType() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDropsForCompatibleTool(Item $item) : array{
|
|
||||||
return [$this->getItem()];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isAffectedBySilkTouch() : bool{
|
public function isAffectedBySilkTouch() : bool{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPickedItem() : Item{
|
|
||||||
return $this->getItem();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user