mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Block: Migrated all trivial drops code to getDropsForCompatibleTool()
getDrops() should now be overridden only for special cases. There are some non-trivial overrides left that are going to need some extra work to clean up.
This commit is contained in:
parent
8c47a338df
commit
56f1a6ba37
@ -199,7 +199,7 @@ class Bed extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
if($this->isHeadPart()){
|
||||
$tile = $this->getLevel()->getTile($this);
|
||||
if($tile instanceof TileBed){
|
||||
|
@ -38,7 +38,7 @@ class Beetroot extends Crops{
|
||||
return "Beetroot Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
if($this->meta >= 0x07){
|
||||
return [
|
||||
ItemFactory::get(Item::BEETROOT, 0, 1),
|
||||
|
@ -46,7 +46,7 @@ class Bookshelf extends Solid{
|
||||
return BlockToolType::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get(Item::BOOK, 0, 3)
|
||||
];
|
||||
|
@ -33,7 +33,7 @@ class BrownMushroomBlock extends RedMushroomBlock{
|
||||
return "Brown Mushroom Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
Item::get(Item::BROWN_MUSHROOM, 0, mt_rand(0, 2))
|
||||
];
|
||||
|
@ -85,7 +85,7 @@ class Cake extends Transparent implements FoodSource{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class Carrot extends Crops{
|
||||
return "Carrot Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get(Item::CARROT, 0, $this->meta >= 0x07 ? mt_rand(1, 4) : 1)
|
||||
];
|
||||
|
@ -46,7 +46,7 @@ class Clay extends Solid{
|
||||
return "Clay Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get(Item::CLAY_BALL, 0, 4)
|
||||
];
|
||||
|
@ -58,7 +58,7 @@ class Cobweb extends Flowable{
|
||||
$entity->resetFallDistance();
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
//TODO: correct drops
|
||||
return [];
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class Farmland extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get(Item::DIRT, 0, 1)
|
||||
];
|
||||
|
@ -79,7 +79,7 @@ class Fire extends Flowable{
|
||||
}
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -96,8 +96,8 @@ class FlowerPot extends Flowable{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
$items = parent::getDrops($item);
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
$items = parent::getDropsForCompatibleTool($item);
|
||||
|
||||
$tile = $this->getLevel()->getTile($this);
|
||||
if($tile instanceof TileFlowerPot){
|
||||
|
@ -41,7 +41,7 @@ class Glass extends Transparent{
|
||||
return 0.3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -41,7 +41,7 @@ class GlassPane extends Thin{
|
||||
return 0.3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -50,7 +50,7 @@ class Glowstone extends Transparent{
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get(Item::GLOWSTONE_DUST, 0, mt_rand(2, 4))
|
||||
];
|
||||
|
@ -52,7 +52,7 @@ class Grass extends Solid{
|
||||
return BlockToolType::TYPE_SHOVEL;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get(Item::DIRT, 0, 1)
|
||||
];
|
||||
|
@ -69,7 +69,7 @@ class GrassPath extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get(Item::DIRT, 0, 1)
|
||||
];
|
||||
|
@ -46,14 +46,14 @@ class Gravel extends Fallable{
|
||||
return BlockToolType::TYPE_SHOVEL;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
if(mt_rand(1, 10) === 1){
|
||||
return [
|
||||
ItemFactory::get(Item::FLINT, 0, 1)
|
||||
];
|
||||
}
|
||||
|
||||
return parent::getDrops($item);
|
||||
return parent::getDropsForCompatibleTool($item);
|
||||
}
|
||||
|
||||
}
|
@ -74,7 +74,7 @@ class Ice extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -99,8 +99,8 @@ class ItemFrame extends Flowable{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
$drops = parent::getDrops($item);
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
$drops = parent::getDropsForCompatibleTool($item);
|
||||
|
||||
$tile = $this->level->getTile($this);
|
||||
if($tile instanceof TileItemFrame){
|
||||
|
@ -72,7 +72,7 @@ abstract class Liquid extends Transparent{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ class Melon extends Transparent{
|
||||
return BlockToolType::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get(Item::MELON_SLICE, 0, mt_rand(3, 7))
|
||||
];
|
||||
|
@ -83,7 +83,7 @@ class MelonStem extends Crops{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get(Item::MELON_SEEDS, 0, mt_rand(0, 2))
|
||||
];
|
||||
|
@ -45,7 +45,7 @@ class MonsterSpawner extends Transparent{
|
||||
return "Monster Spawner";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -50,7 +50,7 @@ class Mycelium extends Solid{
|
||||
return 0.6;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get(Item::DIRT, 0, 1)
|
||||
];
|
||||
|
@ -85,7 +85,7 @@ class NetherWartPlant extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get($this->getItemId(), 0, ($this->getDamage() === 3 ? mt_rand(2, 4) : 1))
|
||||
];
|
||||
|
@ -38,7 +38,7 @@ class Potato extends Crops{
|
||||
return "Potato Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get(Item::POTATO, 0, $this->getDamage() >= 0x07 ? mt_rand(1, 4) : 1)
|
||||
];
|
||||
|
@ -83,7 +83,7 @@ class PumpkinStem extends Crops{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get(Item::PUMPKIN_SEEDS, 0, mt_rand(0, 2))
|
||||
];
|
||||
|
@ -45,7 +45,7 @@ class RedMushroomBlock extends Solid{
|
||||
return BlockToolType::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
Item::get(Item::RED_MUSHROOM, 0, mt_rand(0, 2))
|
||||
];
|
||||
|
@ -46,7 +46,7 @@ class SeaLantern extends Transparent{
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get(Item::PRISMARINE_CRYSTALS, 0, 3)
|
||||
];
|
||||
|
@ -71,7 +71,7 @@ class Skull extends Flowable{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
$tile = $this->level->getTile($this);
|
||||
if($tile instanceof TileSkull){
|
||||
return [
|
||||
|
@ -95,7 +95,7 @@ class StandingBanner extends Transparent{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
$tile = $this->level->getTile($this);
|
||||
|
||||
$drop = ItemFactory::get(Item::BANNER, ($tile instanceof TileBanner ? $tile->getBaseColor() : 0));
|
||||
|
@ -81,6 +81,8 @@ class TallGrass extends Flowable{
|
||||
];
|
||||
}
|
||||
|
||||
//TODO: check shears
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ class Vine extends Flowable{
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isShears()){
|
||||
return parent::getDrops($item);
|
||||
return $this->getDropsForCompatibleTool($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -38,7 +38,7 @@ class Wheat extends Crops{
|
||||
return "Wheat Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
if($this->meta >= 0x07){
|
||||
return [
|
||||
ItemFactory::get(Item::WHEAT, 0, 1),
|
||||
|
Loading…
x
Reference in New Issue
Block a user