mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 05:55:33 +00:00
Changed Block->getDrops() to return Item[]
This commit is contained in:
parent
c8ed2406d7
commit
d8f0dd6db8
@ -79,13 +79,13 @@ class Anvil extends Fallable{
|
||||
return $this->getLevel()->setBlock($block, $this, true, true);
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[$this->id, $this->meta & 0x0c, 1],
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x0c, 1),
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -43,6 +43,8 @@ class Bed extends Transparent{
|
||||
|
||||
protected $id = self::BED_BLOCK;
|
||||
|
||||
protected $itemId = Item::BED;
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
@ -212,21 +214,21 @@ class Bed extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($this->isHeadPart()){
|
||||
$tile = $this->getLevel()->getTile($this);
|
||||
if($tile instanceof TileBed){
|
||||
return [
|
||||
[Item::BED, $tile->getColor(), 1]
|
||||
Item::get($this->getItemId(), $tile->getColor(), 1)
|
||||
];
|
||||
}else{
|
||||
return [
|
||||
[Item::BED, 14, 1] //Red
|
||||
Item::get($this->getItemId(), 14, 1) //Red
|
||||
];
|
||||
}
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,15 +37,16 @@ class Beetroot extends Crops{
|
||||
return "Beetroot Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$drops = [];
|
||||
public function getDrops(Item $item) : array{
|
||||
if($this->meta >= 0x07){
|
||||
$drops[] = [Item::BEETROOT, 0, 1];
|
||||
$drops[] = [Item::BEETROOT_SEEDS, 0, mt_rand(0, 3)];
|
||||
}else{
|
||||
$drops[] = [Item::BEETROOT_SEEDS, 0, 1];
|
||||
return [
|
||||
Item::get(Item::BEETROOT, 0, 1),
|
||||
Item::get(Item::BEETROOT_SEEDS, 0, mt_rand(0, 3))
|
||||
];
|
||||
}
|
||||
|
||||
return $drops;
|
||||
return [
|
||||
Item::get(Item::BEETROOT_SEEDS, 0, 1)
|
||||
];
|
||||
}
|
||||
}
|
@ -654,11 +654,11 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
* @return array
|
||||
* @return Item[]
|
||||
*/
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[$this->getItemId(), $this->getDamage(), 1],
|
||||
Item::get($this->getItemId(), $this->getDamage(), 1),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,9 @@ class Bookshelf extends Solid{
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[Item::BOOK, 0, 3]
|
||||
Item::get(Item::BOOK, 0, 3)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -50,13 +50,11 @@ class Bricks extends Solid{
|
||||
return "Bricks";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::BRICK_BLOCK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -118,12 +118,13 @@ class BurningFurnace extends Solid{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$drops = [];
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
$drops[] = [Item::FURNACE, 0, 1];
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}
|
||||
|
||||
return $drops;
|
||||
return [];
|
||||
}
|
||||
}
|
@ -125,9 +125,9 @@ class Cactus extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}
|
||||
}
|
@ -85,7 +85,7 @@ class Cake extends Transparent implements FoodSource{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -37,14 +37,9 @@ class Carrot extends Crops{
|
||||
return "Carrot Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$drops = [];
|
||||
if($this->meta >= 0x07){
|
||||
$drops[] = [Item::CARROT, 0, mt_rand(1, 4)];
|
||||
}else{
|
||||
$drops[] = [Item::CARROT, 0, 1];
|
||||
}
|
||||
|
||||
return $drops;
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get(Item::CARROT, 0, $this->meta >= 0x07 ? mt_rand(1, 4) : 1)
|
||||
];
|
||||
}
|
||||
}
|
@ -169,9 +169,9 @@ class Chest extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,9 @@ class Clay extends Solid{
|
||||
return "Clay Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[Item::CLAY, 0, 4],
|
||||
Item::get(Item::CLAY_BALL, 0, 4)
|
||||
];
|
||||
}
|
||||
}
|
@ -46,14 +46,12 @@ class Coal extends Solid{
|
||||
return "Coal Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::COAL_BLOCK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
|
@ -46,14 +46,14 @@ class CoalOre extends Solid{
|
||||
return "Coal Ore";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::COAL, 0, 1],
|
||||
Item::get(Item::COAL, 0, 1)
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
@ -46,13 +46,11 @@ class Cobblestone extends Solid{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::COBBLESTONE, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -55,7 +55,7 @@ class Cobweb extends Flowable{
|
||||
$entity->resetFallDistance();
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
//TODO: correct drops
|
||||
return [];
|
||||
}
|
||||
|
@ -55,12 +55,6 @@ class CraftingTable extends Solid{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
|
@ -46,13 +46,11 @@ class Diamond extends Solid{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_IRON){
|
||||
return [
|
||||
[Item::DIAMOND_BLOCK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -46,13 +46,13 @@ class DiamondOre extends Solid{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_IRON){
|
||||
return [
|
||||
[Item::DIAMOND, 0, 1],
|
||||
Item::get(Item::DIAMOND, 0, 1)
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -104,19 +104,19 @@ class DoublePlant extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if(!$item->isShears() and ($this->meta === 2 or $this->meta === 3)){ //grass or fern
|
||||
if(mt_rand(0, 24) === 0){
|
||||
return [
|
||||
[Item::SEEDS, 0, 1]
|
||||
Item::get(Item::SEEDS, 0, 1)
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
[$this->id, $this->meta & 0x07, 1]
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x07, 1)
|
||||
];
|
||||
}
|
||||
}
|
@ -56,14 +56,14 @@ class DoubleStoneSlab extends Solid{
|
||||
return "Double " . $names[$this->meta & 0x07] . " Slab";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::STONE_SLAB, $this->meta & 0x07, 2],
|
||||
Item::get(Item::STONE_SLAB, $this->getDamage() & 0x07, 2),
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
@ -54,9 +54,9 @@ class DoubleWoodenSlab extends Solid{
|
||||
return "Double " . ($names[$this->meta & 0x07] ?? "") . " Wooden Slab";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[Item::WOODEN_SLAB, $this->meta & 0x07, 2],
|
||||
Item::get(Item::WOODEN_SLAB, $this->getDamage() & 0x07, 2)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -46,13 +46,11 @@ class Emerald extends Solid{
|
||||
return "Emerald Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_IRON){
|
||||
return [
|
||||
[Item::EMERALD_BLOCK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -46,13 +46,13 @@ class EmeraldOre extends Solid{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_IRON){
|
||||
return [
|
||||
[Item::EMERALD, 0, 1],
|
||||
Item::get(Item::EMERALD, 0, 1),
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -90,13 +90,13 @@ class EnchantingTable extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -58,9 +58,9 @@ class Farmland extends Transparent{
|
||||
);
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[Item::DIRT, 0, 1],
|
||||
Item::get(Item::DIRT, 0, 1)
|
||||
];
|
||||
}
|
||||
}
|
@ -75,9 +75,9 @@ class FenceGate extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ class Fire extends Flowable{
|
||||
}
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ class FlowerPot extends Flowable{
|
||||
const STATE_FULL = 1;
|
||||
|
||||
protected $id = self::FLOWER_POT_BLOCK;
|
||||
protected $itemId = Item::FLOWER_POT;
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
$this->meta = $meta;
|
||||
@ -121,14 +122,17 @@ class FlowerPot extends Flowable{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$items = [[Item::FLOWER_POT, 0, 1]];
|
||||
public function getDrops(Item $item) : array{
|
||||
$items = parent::getDrops($item);
|
||||
|
||||
$tile = $this->getLevel()->getTile($this);
|
||||
if($tile instanceof TileFlowerPot){
|
||||
if(($item = $tile->getItem())->getId() !== Item::AIR){
|
||||
$items[] = [$item->getId(), $item->getDamage(), 1];
|
||||
$item = $tile->getItem();
|
||||
if($item->getId() !== Item::AIR){
|
||||
$items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class Glass extends Transparent{
|
||||
return 0.3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -41,7 +41,7 @@ class GlassPane extends Thin{
|
||||
return 0.3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -52,13 +52,13 @@ class GlazedTerracotta extends Solid{
|
||||
return $this->getLevel()->setBlock($block, $this, true, true);
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[$this->getId(), 0, 1],
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -50,9 +50,9 @@ class Glowstone extends Transparent{
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[Item::GLOWSTONE_DUST, 0, mt_rand(2, 4)],
|
||||
Item::get(Item::GLOWSTONE_DUST, 0, mt_rand(2, 4))
|
||||
];
|
||||
}
|
||||
}
|
@ -46,13 +46,11 @@ class Gold extends Solid{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_IRON){
|
||||
return [
|
||||
[Item::GOLD_BLOCK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -46,13 +46,11 @@ class GoldOre extends Solid{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_IRON){
|
||||
return [
|
||||
[Item::GOLD_ORE, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -52,9 +52,9 @@ class Grass extends Solid{
|
||||
return Tool::TYPE_SHOVEL;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[Item::DIRT, 0, 1],
|
||||
Item::get(Item::DIRT, 0, 1),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,9 @@ class GrassPath extends Transparent{
|
||||
return 0.6;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[Item::DIRT, 0, 1],
|
||||
Item::get(Item::DIRT, 0, 1)
|
||||
];
|
||||
}
|
||||
}
|
@ -46,15 +46,15 @@ class Gravel extends Fallable{
|
||||
return Tool::TYPE_SHOVEL;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if(mt_rand(1, 10) === 1){
|
||||
return [
|
||||
[Item::FLINT, 0, 1],
|
||||
Item::get(Item::FLINT, 0, 1)
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
[Item::GRAVEL, 0, 1],
|
||||
Item::get(Item::GRAVEL, 0, 1)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,9 @@ class HayBale extends Solid{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ class Ice extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -46,13 +46,11 @@ class Iron extends Solid{
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_STONE){
|
||||
return [
|
||||
[Item::IRON_BLOCK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -46,14 +46,14 @@ class IronBars extends Thin{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::IRON_BARS, 0, 1],
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ class IronDoor extends Door{
|
||||
|
||||
protected $id = self::IRON_DOOR_BLOCK;
|
||||
|
||||
protected $itemId = Item::IRON_DOOR;
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
@ -46,13 +48,11 @@ class IronDoor extends Door{
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::IRON_DOOR, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -46,13 +46,11 @@ class IronOre extends Solid{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_STONE){
|
||||
return [
|
||||
[Item::IRON_ORE, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -35,6 +35,8 @@ use pocketmine\tile\Tile;
|
||||
class ItemFrame extends Flowable{
|
||||
protected $id = Block::ITEM_FRAME_BLOCK;
|
||||
|
||||
protected $itemId = Item::ITEM_FRAME;
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
@ -137,9 +139,9 @@ class ItemFrame extends Flowable{
|
||||
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[Item::ITEM_FRAME, 0, 1]
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -149,9 +149,9 @@ class Ladder extends Transparent{
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}
|
||||
}
|
@ -46,14 +46,12 @@ class Lapis extends Solid{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_STONE){
|
||||
return [
|
||||
[Item::LAPIS_BLOCK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
@ -46,14 +46,14 @@ class LapisOre extends Solid{
|
||||
return "Lapis Lazuli Ore";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_STONE){
|
||||
return [
|
||||
[Item::DYE, 4, mt_rand(4, 8)],
|
||||
Item::get(Item::DYE, 4, mt_rand(4, 8))
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
@ -164,16 +164,19 @@ class Leaves extends Transparent{
|
||||
return $this->getLevel()->setBlock($this, $this, true);
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
$drops = [];
|
||||
|
||||
$variantMeta = $this->getDamage() & 0x03;
|
||||
|
||||
if($item->isShears()){
|
||||
$drops[] = [$this->id, $this->meta & 0x03, 1];
|
||||
$drops[] = Item::get($this->getItemId(), $variantMeta, 1);
|
||||
}else{
|
||||
if(mt_rand(1, 20) === 1){ //Saplings
|
||||
$drops[] = [Item::SAPLING, $this->meta & 0x03, 1];
|
||||
$drops[] = Item::get(Item::SAPLING, $variantMeta, 1);
|
||||
}
|
||||
if(($this->meta & 0x03) === self::OAK and mt_rand(1, 200) === 1){ //Apples
|
||||
$drops[] = [Item::APPLE, 0, 1];
|
||||
if($variantMeta === self::OAK and mt_rand(1, 200) === 1){ //Apples
|
||||
$drops[] = Item::get(Item::APPLE, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,19 +35,22 @@ class Leaves2 extends Leaves{
|
||||
self::ACACIA => "Acacia Leaves",
|
||||
self::DARK_OAK => "Dark Oak Leaves",
|
||||
];
|
||||
return $names[$this->meta & 0x01];
|
||||
return $names[$this->meta & 0x03] ?? "Unknown";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$drops = [];
|
||||
public function getDrops(Item $item) : array{
|
||||
$variantMeta = $this->getDamage() & 0x03;
|
||||
|
||||
if($item->isShears()){
|
||||
$drops[] = [$this->id, $this->meta & 0x01, 1];
|
||||
}else{
|
||||
if(mt_rand(1, 20) === 1){ //Saplings
|
||||
$drops[] = [Item::SAPLING, ($this->meta & 0x01) + 4, 1];
|
||||
}
|
||||
return [
|
||||
Item::get($this->getItemId(), $variantMeta, 1)
|
||||
];
|
||||
}elseif(mt_rand(1, 20) === 1){ //Saplings
|
||||
return [
|
||||
Item::get(Item::SAPLING, $variantMeta + 4, 1)
|
||||
];
|
||||
}
|
||||
|
||||
return $drops;
|
||||
return [];
|
||||
}
|
||||
}
|
@ -446,7 +446,7 @@ abstract class Liquid extends Transparent{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -46,9 +46,9 @@ class Melon extends Transparent{
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[Item::MELON_SLICE, 0, mt_rand(3, 7)],
|
||||
Item::get(Item::MELON_SLICE, 0, mt_rand(3, 7))
|
||||
];
|
||||
}
|
||||
}
|
@ -82,9 +82,9 @@ class MelonStem extends Crops{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[Item::MELON_SEEDS, 0, mt_rand(0, 2)],
|
||||
Item::get(Item::MELON_SEEDS, 0, mt_rand(0, 2))
|
||||
];
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ class MonsterSpawner extends Solid{
|
||||
return "Monster Spawner";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -26,33 +26,11 @@ namespace pocketmine\block;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class MossyCobblestone extends Solid{
|
||||
class MossyCobblestone extends Cobblestone{
|
||||
|
||||
protected $id = self::MOSSY_COBBLESTONE;
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName() : string{
|
||||
return "Moss Stone";
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getToolType() : int{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::MOSSY_COBBLESTONE, $this->meta, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -50,9 +50,9 @@ class Mycelium extends Solid{
|
||||
return 0.6;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[Item::DIRT, 0, 1],
|
||||
Item::get(Item::DIRT, 0, 1)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\item\Tool;
|
||||
|
||||
class NetherBrick extends Solid{
|
||||
|
||||
protected $id = self::NETHER_BRICK;
|
||||
protected $id = self::NETHER_BRICK_BLOCK;
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
$this->meta = $meta;
|
||||
@ -46,13 +46,11 @@ class NetherBrick extends Solid{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::NETHER_BRICK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
@ -49,13 +50,13 @@ class NetherBrickFence extends Transparent{
|
||||
return ($block instanceof NetherBrickFence) or ($block->isSolid() and !$block->isTransparent());
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[$this->id, $this->meta, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
//TODO: fix bounding boxes
|
||||
}
|
||||
|
@ -50,11 +50,11 @@ class NetherReactor extends Solid{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::IRON_INGOT, 0, 6],
|
||||
[Item::DIAMOND, 0, 3]
|
||||
Item::get(Item::IRON_INGOT, 0, 6),
|
||||
Item::get(Item::DIAMOND, 0, 3)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,8 @@ use pocketmine\Player;
|
||||
class NetherWartPlant extends Flowable{
|
||||
protected $id = Block::NETHER_WART_PLANT;
|
||||
|
||||
protected $itemId = Item::NETHER_WART;
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
@ -74,7 +76,9 @@ class NetherWartPlant extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [[Item::NETHER_WART, 0, ($this->meta === 3 ? mt_rand(2, 4) : 1)]];
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, ($this->getDamage() === 3 ? mt_rand(2, 4) : 1))
|
||||
];
|
||||
}
|
||||
}
|
@ -46,13 +46,11 @@ class Netherrack extends Solid{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::NETHERRACK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -43,16 +43,14 @@ class Obsidian extends Solid{
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 35;
|
||||
return 35; //50 in PC
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_DIAMOND){
|
||||
return [
|
||||
[Item::OBSIDIAN, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -37,14 +37,9 @@ class Potato extends Crops{
|
||||
return "Potato Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$drops = [];
|
||||
if($this->meta >= 0x07){
|
||||
$drops[] = [Item::POTATO, 0, mt_rand(1, 4)];
|
||||
}else{
|
||||
$drops[] = [Item::POTATO, 0, 1];
|
||||
}
|
||||
|
||||
return $drops;
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get(Item::POTATO, 0, $this->getDamage() >= 0x07 ? mt_rand(1, 4) : 1)
|
||||
];
|
||||
}
|
||||
}
|
@ -55,13 +55,13 @@ class Prismarine extends Solid{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[$this->id, $this->meta & 0x03, 1],
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x03, 1)
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -82,9 +82,9 @@ class PumpkinStem extends Crops{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[Item::PUMPKIN_SEEDS, 0, mt_rand(0, 2)],
|
||||
Item::get(Item::PUMPKIN_SEEDS, 0, mt_rand(0, 2))
|
||||
];
|
||||
}
|
||||
}
|
@ -57,13 +57,13 @@ class Quartz extends Solid{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::QUARTZ_BLOCK, $this->meta & 0x03, 1],
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x03, 1)
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -46,13 +46,11 @@ class Redstone extends Solid{
|
||||
return "Redstone Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::REDSTONE_BLOCK, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -62,13 +62,13 @@ class RedstoneOre extends Solid{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_IRON){
|
||||
return [
|
||||
[Item::REDSTONE_DUST, 0, mt_rand(4, 5)],
|
||||
Item::get(Item::REDSTONE_DUST, 0, mt_rand(4, 5))
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -55,14 +55,14 @@ class Sandstone extends Solid{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::SANDSTONE, $this->meta & 0x03, 1],
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x03, 1)
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
@ -107,9 +107,9 @@ class Sapling extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[$this->id, $this->meta & 0x07, 1],
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x07, 1)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -45,9 +45,9 @@ class SeaLantern extends Transparent{
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[Item::PRISMARINE_CRYSTALS, 0, 3],
|
||||
Item::get(Item::PRISMARINE_CRYSTALS, 0, 3)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,8 @@ class SignPost extends Transparent{
|
||||
|
||||
protected $id = self::SIGN_POST;
|
||||
|
||||
protected $itemId = Item::SIGN;
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
@ -109,12 +111,6 @@ class SignPost extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[Item::SIGN, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
public function getToolType() : int{
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
@ -89,11 +89,11 @@ class Skull extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
$tile = $this->level->getTile($this);
|
||||
if($tile instanceof SkullTile){
|
||||
return [
|
||||
[Item::SKULL, $tile->getType(), 1]
|
||||
Item::get(Item::SKULL, $tile->getType(), 1)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -83,10 +83,10 @@ class SnowLayer extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isShovel() !== false){
|
||||
return [
|
||||
[Item::SNOWBALL, 0, 1],
|
||||
Item::get(Item::SNOWBALL, 0, 1) //TODO: check layer count
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -145,13 +145,13 @@ abstract class Stair extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[$this->getId(), 0, 1],
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@ -62,14 +62,18 @@ class Stone extends Solid{
|
||||
return $names[$this->meta & 0x07] ?? "Unknown";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[$this->getDamage() === 0 ? Item::COBBLESTONE : Item::STONE, $this->getDamage(), 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
if($this->getDamage() === self::NORMAL){
|
||||
return [
|
||||
Item::get(Item::COBBLESTONE, $this->getDamage(), 1)
|
||||
];
|
||||
}
|
||||
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
@ -56,14 +56,14 @@ class StoneBricks extends Solid{
|
||||
return $names[$this->meta & 0x03];
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::STONE_BRICKS, $this->meta & 0x03, 1],
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x03, 1)
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
@ -62,14 +62,12 @@ class StoneSlab extends WoodenSlab{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[$this->id, $this->meta & 0x07, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
|
@ -26,7 +26,6 @@ namespace pocketmine\block;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
//TODO: check orientation
|
||||
class Stonecutter extends Solid{
|
||||
|
||||
protected $id = self::STONECUTTER;
|
||||
@ -43,13 +42,11 @@ class Stonecutter extends Solid{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::STONECUTTER, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -34,6 +34,8 @@ class Sugarcane extends Flowable{
|
||||
|
||||
protected $id = self::SUGARCANE_BLOCK;
|
||||
|
||||
protected $itemId = Item::SUGARCANE;
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
@ -42,13 +44,6 @@ class Sugarcane extends Flowable{
|
||||
return "Sugarcane";
|
||||
}
|
||||
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[Item::SUGARCANE, 0, 1],
|
||||
];
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null) : bool{
|
||||
if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
|
||||
if($this->getSide(Vector3::SIDE_DOWN)->getId() !== self::SUGARCANE_BLOCK){
|
||||
|
@ -73,10 +73,10 @@ class TallGrass extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if(mt_rand(0, 15) === 0){
|
||||
return [
|
||||
[Item::WHEAT_SEEDS, 0, 1]
|
||||
Item::get(Item::WHEAT_SEEDS, 0, 1)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -93,9 +93,9 @@ class Torch extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}
|
||||
}
|
@ -140,9 +140,9 @@ class Trapdoor extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class UnknownBlock extends Transparent{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -174,14 +174,14 @@ class Vine extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isShears()){
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getToolType() : int{
|
||||
|
@ -80,9 +80,9 @@ class WaterLily extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[$this->id, 0, 1]
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}
|
||||
}
|
@ -37,15 +37,16 @@ class Wheat extends Crops{
|
||||
return "Wheat Block";
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
$drops = [];
|
||||
public function getDrops(Item $item) : array{
|
||||
if($this->meta >= 0x07){
|
||||
$drops[] = [Item::WHEAT, 0, 1];
|
||||
$drops[] = [Item::WHEAT_SEEDS, 0, mt_rand(0, 3)];
|
||||
return [
|
||||
Item::get(Item::WHEAT, 0, 1),
|
||||
Item::get(Item::WHEAT_SEEDS, 0, mt_rand(0, 3))
|
||||
];
|
||||
}else{
|
||||
$drops[] = [Item::WHEAT_SEEDS, 0, 1];
|
||||
return [
|
||||
Item::get(Item::WHEAT_SEEDS, 0, 1)
|
||||
];
|
||||
}
|
||||
|
||||
return $drops;
|
||||
}
|
||||
}
|
@ -69,9 +69,9 @@ class Wood extends Solid{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[$this->id, $this->meta & 0x03, 1],
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x03, 1)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,9 @@ class WoodenDoor extends Door{
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[$this->getItemId(), 0, 1],
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}
|
||||
}
|
@ -129,9 +129,9 @@ class WoodenSlab extends Transparent{
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[$this->id, $this->meta & 0x07, 1],
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x07, 1)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,9 @@ class WoodenStairs extends Stair{
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}
|
||||
}
|
@ -39,6 +39,7 @@ class BlockBreakEvent extends BlockEvent implements Cancellable{
|
||||
|
||||
/** @var bool */
|
||||
protected $instaBreak = false;
|
||||
/** @var Item[] */
|
||||
protected $blockDrops = [];
|
||||
|
||||
public function __construct(Player $player, Block $block, Item $item, $instaBreak = false){
|
||||
@ -46,10 +47,7 @@ class BlockBreakEvent extends BlockEvent implements Cancellable{
|
||||
$this->item = $item;
|
||||
$this->player = $player;
|
||||
$this->instaBreak = (bool) $instaBreak;
|
||||
$drops = $player->isSurvival() ? $block->getDrops($item) : [];
|
||||
foreach($drops as $i){
|
||||
$this->blockDrops[] = Item::get($i[0], $i[1], $i[2]);
|
||||
}
|
||||
$this->blockDrops = $player->isSurvival() ? $block->getDrops($item) : [];
|
||||
}
|
||||
|
||||
public function getPlayer(){
|
||||
|
@ -173,7 +173,7 @@ class Explosion{
|
||||
$block->ignite(mt_rand(10, 30));
|
||||
}elseif(mt_rand(0, 100) < $yield){
|
||||
foreach($block->getDrops($air) as $drop){
|
||||
$this->level->dropItem($block->add(0.5, 0.5, 0.5), Item::get(...$drop));
|
||||
$this->level->dropItem($block->add(0.5, 0.5, 0.5), $drop);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1651,9 +1651,6 @@ class Level implements ChunkManager, Metadatable{
|
||||
return false;
|
||||
}else{
|
||||
$drops = $target->getDrops($item); //Fixes tile entities being deleted before getting drops
|
||||
foreach($drops as $k => $i){
|
||||
$drops[$k] = Item::get($i[0], $i[1], $i[2]);
|
||||
}
|
||||
}
|
||||
|
||||
$above = $this->getBlock(new Vector3($target->x, $target->y + 1, $target->z));
|
||||
|
Loading…
x
Reference in New Issue
Block a user