Separate block break-info to a separate dynamic unit

This commit is contained in:
Dylan K. Taylor 2019-05-10 16:24:59 +01:00
parent 3be5de4570
commit 9e72bc91a2
155 changed files with 556 additions and 1295 deletions

View File

@ -1922,7 +1922,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
if(!$this->isCreative()){
//TODO: improve this to take stuff like swimming, ladders, enchanted tools into account, fix wrong tool break time calculations for bad tools (pmmp/PocketMine-MP#211)
$breakTime = ceil($target->getBreakTime($this->inventory->getItemInHand()) * 20);
$breakTime = ceil($target->getBreakInfo()->getBreakTime($this->inventory->getItemInHand()) * 20);
if($breakTime > 0){
$this->world->broadcastLevelEvent($pos, LevelEventPacket::EVENT_BLOCK_START_BREAK, (int) (65535 / $breakTime));
}

View File

@ -23,17 +23,15 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
/**
* Air block
*/
class Air extends Transparent{
public function isBreakable(Item $item) : bool{
return false;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(-1.0, BlockToolType::TYPE_NONE, 0, 0.0));
}
public function canBeFlowedInto() : bool{
@ -59,12 +57,4 @@ class Air extends Transparent{
public function getCollisionBoxes() : array{
return [];
}
public function getHardness() : float{
return -1;
}
public function getBlastResistance() : float{
return 0;
}
}

View File

@ -45,6 +45,10 @@ class Anvil extends Transparent implements Fallable{
/** @var int */
protected $facing = Facing::NORTH;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(5.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 6000.0));
}
protected function writeStateToMeta() : int{
return Bearing::fromFacing($this->facing);
}
@ -57,22 +61,6 @@ class Anvil extends Transparent implements Fallable{
return 0b11;
}
public function getHardness() : float{
return 5;
}
public function getBlastResistance() : float{
return 6000;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function recalculateBoundingBox() : ?AxisAlignedBB{
return AxisAlignedBB::one()->squash(Facing::axis(Facing::rotateY($this->facing, false)), 1 / 8);
}

View File

@ -56,8 +56,8 @@ class Banner extends Transparent{
/** @var Deque|BannerPattern[] */
protected $patterns;
public function __construct(BlockIdentifierFlattened $idInfo, string $name){
parent::__construct($idInfo, $name);
public function __construct(BlockIdentifierFlattened $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(1.0, BlockToolType::TYPE_AXE));
$this->baseColor = DyeColor::BLACK();
$this->patterns = new Deque();
}
@ -107,10 +107,6 @@ class Banner extends Transparent{
$tile->setPatterns($this->patterns);
}
public function getHardness() : float{
return 1;
}
public function isSolid() : bool{
return false;
}
@ -168,10 +164,6 @@ class Banner extends Transparent{
}
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
public function getDropsForCompatibleTool(Item $item) : array{
$drop = ItemFactory::get(Item::BANNER, $this->baseColor->getInvertedMagicNumber());
if($drop instanceof ItemBanner and !$this->patterns->isEmpty()){

View File

@ -23,19 +23,9 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
class Barrier extends Transparent{
public function getHardness() : float{
return -1;
}
public function getBlastResistance() : float{
return 18000003; //don't even ask
}
public function isBreakable(Item $item) : bool{
return false;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::indestructible());
}
}

View File

@ -80,6 +80,10 @@ abstract class BaseRail extends Flowable{
/** @var int[] */
protected $connections = [];
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.7));
}
protected function writeStateToMeta() : int{
if(empty($this->connections)){
return self::STRAIGHT_NORTH_SOUTH;
@ -99,10 +103,6 @@ abstract class BaseRail extends Flowable{
return 0b1111;
}
public function getHardness() : float{
return 0.7;
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if(!$blockReplace->getSide(Facing::DOWN)->isTransparent()){
$this->tryReconnect();

View File

@ -51,8 +51,8 @@ class Bed extends Transparent{
/** @var DyeColor */
protected $color;
public function __construct(BlockIdentifier $idInfo, string $name){
parent::__construct($idInfo, $name);
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.2));
$this->color = DyeColor::RED();
}
@ -90,10 +90,6 @@ class Bed extends Transparent{
}
}
public function getHardness() : float{
return 0.2;
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return AxisAlignedBB::one()->trim(Facing::UP, 7 / 16);
}

View File

@ -23,13 +23,15 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
class Bedrock extends Solid{
/** @var bool */
private $burnsForever = false;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::indestructible());
}
public function readStateFromData(int $id, int $stateMeta) : void{
$this->burnsForever = $stateMeta !== 0;
}
@ -42,18 +44,6 @@ class Bedrock extends Solid{
return 0b1;
}
public function getHardness() : float{
return -1;
}
public function getBlastResistance() : float{
return 18000000;
}
public function isBreakable(Item $item) : bool{
return false;
}
public function burnsForever() : bool{
return $this->burnsForever;
}

View File

@ -46,7 +46,6 @@ use pocketmine\world\World;
use function array_merge;
use function assert;
use function dechex;
use function get_class;
use const PHP_INT_MAX;
class Block extends Position implements BlockLegacyIds, Metadatable{
@ -72,6 +71,9 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
/** @var string */
protected $fallbackName;
/** @var BlockBreakInfo */
protected $breakInfo;
/** @var AxisAlignedBB */
protected $boundingBox = null;
@ -81,13 +83,15 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
/**
* @param BlockIdentifier $idInfo
* @param string $name English name of the block type (TODO: implement translations)
* @param BlockBreakInfo $breakInfo
*/
public function __construct(BlockIdentifier $idInfo, string $name){
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
if(($idInfo->getVariant() & $this->getStateBitmask()) !== 0){
throw new \InvalidArgumentException("Variant 0x" . dechex($idInfo->getVariant()) . " collides with state bitmask 0x" . dechex($this->getStateBitmask()));
}
$this->idInfo = $idInfo;
$this->fallbackName = $name;
$this->breakInfo = $breakInfo;
}
public function getIdInfo() : BlockIdentifier{
@ -248,59 +252,12 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
}
/**
* Returns if the block can be broken with an specific Item
* Returns an object containing information about the destruction requirements of this block.
*
* @param Item $item
*
* @return bool
* @return BlockBreakInfo
*/
public function isBreakable(Item $item) : bool{
return true;
}
/**
* @return int
*/
public function getToolType() : int{
return BlockToolType::TYPE_NONE;
}
/**
* Returns the level of tool required to harvest this block (for normal blocks). When the tool type matches the
* block's required tool type, the tool must have a harvest level greater than or equal to this value to be able to
* successfully harvest the block.
*
* If the block requires a specific minimum tier of tiered tool, the minimum tier required should be returned.
* Otherwise, 1 should be returned if a tool is required, 0 if not.
*
* @see Item::getBlockToolHarvestLevel()
*
* @return int
*/
public function getToolHarvestLevel() : int{
return 0;
}
/**
* Returns whether the specified item is the proper tool to use for breaking this block. This checks tool type and
* harvest level requirement.
*
* In most cases this is also used to determine whether block drops should be created or not, except in some
* special cases such as vines.
*
* @param Item $tool
*
* @return bool
*/
public function isCompatibleWithTool(Item $tool) : bool{
if($this->getHardness() < 0){
return false;
}
$toolType = $this->getToolType();
$harvestLevel = $this->getToolHarvestLevel();
return $toolType === BlockToolType::TYPE_NONE or $harvestLevel === 0 or (
($toolType & $tool->getBlockToolType()) !== 0 and $tool->getBlockToolHarvestLevel() >= $harvestLevel);
public function getBreakInfo() : BlockBreakInfo{
return $this->breakInfo;
}
/**
@ -318,33 +275,6 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
return $this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR));
}
/**
* Returns the seconds that this block takes to be broken using an specific Item
*
* @param Item $item
*
* @return float
* @throws \InvalidArgumentException if the item efficiency is not a positive number
*/
public function getBreakTime(Item $item) : float{
$base = $this->getHardness();
if($this->isCompatibleWithTool($item)){
$base *= 1.5;
}else{
$base *= 5;
}
$efficiency = $item->getMiningEfficiency(($this->getToolType() & $item->getBlockToolType()) !== 0);
if($efficiency <= 0){
throw new \InvalidArgumentException(get_class($item) . " has invalid mining efficiency: expected >= 0, got $efficiency");
}
$base /= $efficiency;
return $base;
}
/**
* Called when this block or a block immediately adjacent to it changes state.
*/
@ -404,22 +334,6 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
return false;
}
/**
* Returns a base value used to compute block break times.
* @return float
*/
public function getHardness() : float{
return 10;
}
/**
* Returns the block's resistance to explosions. Usually 5x hardness.
* @return float
*/
public function getBlastResistance() : float{
return $this->getHardness() * 5;
}
/**
* @return float
*/
@ -517,7 +431,7 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
* @return Item[]
*/
public function getDrops(Item $item) : array{
if($this->isCompatibleWithTool($item)){
if($this->breakInfo->isToolCompatible($item)){
if($this->isAffectedBySilkTouch() and $item->hasEnchantment(Enchantment::SILK_TOUCH())){
return $this->getSilkTouchDrops($item);
}
@ -558,7 +472,7 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
* @return int
*/
public function getXpDropForTool(Item $item) : int{
if($item->hasEnchantment(Enchantment::SILK_TOUCH()) or !$this->isCompatibleWithTool($item)){
if($item->hasEnchantment(Enchantment::SILK_TOUCH()) or !$this->breakInfo->isToolCompatible($item)){
return 0;
}

View File

@ -0,0 +1,165 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use function get_class;
class BlockBreakInfo{
/** @var float */
private $hardness;
/** @var float */
private $blastResistance;
/** @var int */
private $toolType;
/** @var int */
private $toolHarvestLevel;
/**
* @param float $hardness
* @param int $toolType
* @param int $toolHarvestLevel
* @param float|null $blastResistance default 5x hardness
*/
public function __construct(float $hardness, int $toolType = BlockToolType::TYPE_NONE, int $toolHarvestLevel = 0, ?float $blastResistance = null){
$this->hardness = $hardness;
$this->toolType = $toolType;
$this->toolHarvestLevel = $toolHarvestLevel;
$this->blastResistance = $blastResistance ?? $hardness * 5;
}
public static function instant(int $toolType = BlockToolType::TYPE_NONE, int $toolHarvestLevel = 0) : self{
return new self(0.0, $toolType, $toolHarvestLevel, 0.0);
}
public static function indestructible(float $blastResistance = 18000000.0) : self{
return new self(-1.0, BlockToolType::TYPE_NONE, 0, $blastResistance);
}
/**
* Returns a base value used to compute block break times.
*
* @return float
*/
public function getHardness() : float{
return $this->hardness;
}
/**
* Returns whether the block can be broken at all.
*
* @return bool
*/
public function isBreakable() : bool{
return $this->hardness >= 0;
}
/**
* Returns whether this block can be instantly broken.
*
* @return bool
*/
public function breaksInstantly() : bool{
return $this->hardness == 0.0;
}
/**
* Returns the block's resistance to explosions. Usually 5x hardness.
*
* @return float
*/
public function getBlastResistance() : float{
return $this->blastResistance;
}
/**
* @return int
*/
public function getToolType() : int{
return $this->toolType;
}
/**
* Returns the level of tool required to harvest the block (for normal blocks). When the tool type matches the
* block's required tool type, the tool must have a harvest level greater than or equal to this value to be able to
* successfully harvest the block.
*
* If the block requires a specific minimum tier of tiered tool, the minimum tier required should be returned.
* Otherwise, 1 should be returned if a tool is required, 0 if not.
*
* @see Item::getBlockToolHarvestLevel()
*
* @return int
*/
public function getToolHarvestLevel() : int{
return $this->toolHarvestLevel;
}
/**
* Returns whether the specified item is the proper tool to use for breaking this block. This checks tool type and
* harvest level requirement.
*
* In most cases this is also used to determine whether block drops should be created or not, except in some
* special cases such as vines.
*
* @param Item $tool
*
* @return bool
*/
public function isToolCompatible(Item $tool) : bool{
if($this->hardness < 0){
return false;
}
return $this->toolType === BlockToolType::TYPE_NONE or $this->toolHarvestLevel === 0 or (
($this->toolType & $tool->getBlockToolType()) !== 0 and $tool->getBlockToolHarvestLevel() >= $this->toolHarvestLevel);
}
/**
* Returns the seconds that this block takes to be broken using an specific Item
*
* @param Item $item
*
* @return float
* @throws \InvalidArgumentException if the item efficiency is not a positive number
*/
public function getBreakTime(Item $item) : float{
$base = $this->hardness;
if($this->isToolCompatible($item)){
$base *= 1.5;
}else{
$base *= 5;
}
$efficiency = $item->getMiningEfficiency(($this->toolType & $item->getBlockToolType()) !== 0);
if($efficiency <= 0){
throw new \InvalidArgumentException(get_class($item) . " has invalid mining efficiency: expected >= 0, got $efficiency");
}
$base /= $efficiency;
return $base;
}
}

View File

@ -31,8 +31,8 @@ use pocketmine\block\utils\TreeType;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\ItemIds;
use pocketmine\world\Position;
use pocketmine\tile\Comparator;
use pocketmine\world\Position;
use function array_fill;
use function array_filter;
use function get_class;
@ -612,7 +612,7 @@ class BlockFactory{
self::$fullList[$index] = $block;
self::$lightFilter[$index] = min(15, $block->getLightFilter() + 1); //opacity plus 1 standard light filter
self::$diffusesSkyLight[$index] = $block->diffusesSkyLight();
self::$blastResistance[$index] = $block->getBlastResistance();
self::$blastResistance[$index] = $block->getBreakInfo()->getBlastResistance();
}
/**

View File

@ -27,12 +27,8 @@ use pocketmine\item\Item;
class BlueIce extends Solid{
public function getHardness() : float{
return 2.8;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.8, BlockToolType::TYPE_PICKAXE));
}
public function getLightLevel() : int{

View File

@ -29,15 +29,7 @@ use pocketmine\item\TieredTool;
class BoneBlock extends Solid{
use PillarRotationTrait;
public function getHardness() : float{
return 2;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN));
}
}

View File

@ -28,12 +28,8 @@ use pocketmine\item\ItemFactory;
class Bookshelf extends Solid{
public function getHardness() : float{
return 1.5;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(1.5, BlockToolType::TYPE_AXE));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -34,6 +34,10 @@ class BrewingStand extends Transparent{
/** @var bool */
protected $southwestSlot = false;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.5, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN));
}
protected function writeStateToMeta() : int{
return ($this->eastSlot ? 0x01 : 0) | ($this->southwestSlot ? 0x02 : 0) | ($this->northwestSlot ? 0x04 : 0);
}
@ -48,17 +52,5 @@ class BrewingStand extends Transparent{
return 0b111;
}
public function getHardness() : float{
return 0.5;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
//TODO
}

View File

@ -27,19 +27,7 @@ use pocketmine\item\TieredTool;
class BrickStairs extends Stair{
public function getHardness() : float{
return 2;
}
public function getBlastResistance() : float{
return 30;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 30.0));
}
}

View File

@ -27,19 +27,7 @@ use pocketmine\item\TieredTool;
class Bricks extends Solid{
public function getHardness() : float{
return 2;
}
public function getBlastResistance() : float{
return 30;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 30.0));
}
}

View File

@ -39,6 +39,10 @@ class Cactus extends Transparent{
/** @var int */
protected $age = 0;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.4));
}
protected function writeStateToMeta() : int{
return $this->age;
}
@ -51,10 +55,6 @@ class Cactus extends Transparent{
return 0b1111;
}
public function getHardness() : float{
return 0.4;
}
public function hasEntityCollision() : bool{
return true;
}

View File

@ -38,6 +38,10 @@ class Cake extends Transparent implements FoodSource{
/** @var int */
protected $bites = 0;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.5));
}
protected function writeStateToMeta() : int{
return $this->bites;
}
@ -50,10 +54,6 @@ class Cake extends Transparent implements FoodSource{
return 0b111;
}
public function getHardness() : float{
return 0.5;
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return AxisAlignedBB::one()
->contract(1 / 16, 0, 1 / 16)

View File

@ -31,8 +31,8 @@ use pocketmine\Player;
class Carpet extends Flowable{
public function getHardness() : float{
return 0.1;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.1));
}
public function isSolid() : bool{

View File

@ -36,6 +36,10 @@ class Chest extends Transparent{
/** @var int */
protected $facing = Facing::NORTH;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.5, BlockToolType::TYPE_AXE));
}
protected function writeStateToMeta() : int{
return $this->facing;
}
@ -48,14 +52,6 @@ class Chest extends Transparent{
return 0b111;
}
public function getHardness() : float{
return 2.5;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
//these are slightly bigger than in PC
return AxisAlignedBB::one()->contract(0.025, 0, 0.025)->trim(Facing::UP, 0.05);

View File

@ -28,12 +28,8 @@ use pocketmine\item\ItemFactory;
class Clay extends Solid{
public function getHardness() : float{
return 0.6;
}
public function getToolType() : int{
return BlockToolType::TYPE_SHOVEL;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.6, BlockToolType::TYPE_SHOVEL));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -27,16 +27,8 @@ use pocketmine\item\TieredTool;
class Coal extends Solid{
public function getHardness() : float{
return 5;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(5.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 30.0));
}
public function getFuelTime() : int{

View File

@ -30,16 +30,8 @@ use function mt_rand;
class CoalOre extends Solid{
public function getHardness() : float{
return 3;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(3.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class Cobblestone extends Solid{
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getHardness() : float{
return 2;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 30.0));
}
}

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class CobblestoneStairs extends Stair{
public function getHardness() : float{
return 2;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 30.0));
}
}

View File

@ -29,22 +29,14 @@ use pocketmine\item\ItemFactory;
class Cobweb extends Flowable{
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(4.0, BlockToolType::TYPE_SWORD | BlockToolType::TYPE_SHEARS, 1));
}
public function hasEntityCollision() : bool{
return true;
}
public function getHardness() : float{
return 4;
}
public function getToolType() : int{
return BlockToolType::TYPE_SWORD | BlockToolType::TYPE_SHEARS;
}
public function getToolHarvestLevel() : int{
return 1;
}
public function onEntityInside(Entity $entity) : void{
$entity->resetFallDistance();
}

View File

@ -42,6 +42,10 @@ class CocoaBlock extends Transparent{
/** @var int */
protected $age = 0;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.2, BlockToolType::TYPE_AXE, 0, 15.0));
}
protected function writeStateToMeta() : int{
return Bearing::fromFacing(Facing::opposite($this->facing)) | ($this->age << 2);
}
@ -55,14 +59,6 @@ class CocoaBlock extends Transparent{
return 0b1111;
}
public function getHardness() : float{
return 0.2;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
public function isAffectedBySilkTouch() : bool{
return false;
}

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class Concrete extends Solid{
public function getHardness() : float{
return 1.8;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(1.8, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN));
}
}

View File

@ -32,12 +32,8 @@ class ConcretePowder extends Solid implements Fallable{
onNearbyBlockChange as protected startFalling;
}
public function getHardness() : float{
return 0.5;
}
public function getToolType() : int{
return BlockToolType::TYPE_SHOVEL;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.5, BlockToolType::TYPE_SHOVEL));
}
public function onNearbyBlockChange() : void{

View File

@ -30,12 +30,8 @@ use pocketmine\Player;
class CraftingTable extends Solid{
public function getHardness() : float{
return 2.5;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.5, BlockToolType::TYPE_AXE));
}
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{

View File

@ -40,8 +40,8 @@ class DaylightSensor extends Transparent{
/** @var bool */
protected $inverted = false;
public function __construct(BlockIdentifierFlattened $idInfo, string $name){
parent::__construct($idInfo, $name);
public function __construct(BlockIdentifierFlattened $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.2, BlockToolType::TYPE_AXE));
}
public function getId() : int{
@ -75,18 +75,10 @@ class DaylightSensor extends Transparent{
return $this;
}
public function getHardness() : float{
return 0.2;
}
public function getFuelTime() : int{
return 300;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return AxisAlignedBB::one()->trim(Facing::UP, 0.5);
}

View File

@ -32,6 +32,10 @@ use function mt_rand;
class DeadBush extends Flowable{
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant(BlockToolType::TYPE_SHEARS, 1));
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if(!$this->getSide(Facing::DOWN)->isTransparent()){
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
@ -46,16 +50,8 @@ class DeadBush extends Flowable{
}
}
public function getToolType() : int{
return BlockToolType::TYPE_SHEARS;
}
public function getToolHarvestLevel() : int{
return 1;
}
public function getDrops(Item $item) : array{
if(!$this->isCompatibleWithTool($item)){
if(!$this->breakInfo->isToolCompatible($item)){
return [
ItemFactory::get(Item::STICK, 0, mt_rand(0, 2))
];

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class Diamond extends Solid{
public function getHardness() : float{
return 5;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_IRON;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(5.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_IRON, 30.0));
}
}

View File

@ -30,16 +30,8 @@ use function mt_rand;
class DiamondOre extends Solid{
public function getHardness() : float{
return 3;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_IRON;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(3.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_IRON));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -33,12 +33,8 @@ class Dirt extends Solid{
public const NORMAL = 0;
public const COARSE = 1;
public function getHardness() : float{
return 0.5;
}
public function getToolType() : int{
return BlockToolType::TYPE_SHOVEL;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.5, BlockToolType::TYPE_SHOVEL));
}
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{

View File

@ -29,20 +29,16 @@ use function mt_rand;
class DoubleTallGrass extends DoublePlant{
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant(BlockToolType::TYPE_SHEARS, 1));
}
public function canBeReplaced() : bool{
return true;
}
public function getToolType() : int{
return BlockToolType::TYPE_SHEARS;
}
public function getToolHarvestLevel() : int{
return 1;
}
public function getDrops(Item $item) : array{
if($this->top and !$this->isCompatibleWithTool($item) and mt_rand(0, 7) === 0){
if($this->top and !$this->breakInfo->isToolCompatible($item) and mt_rand(0, 7) === 0){
return [
ItemFactory::get(Item::SEEDS)
];

View File

@ -39,16 +39,8 @@ use function mt_rand;
class DragonEgg extends Transparent implements Fallable{
use FallableTrait;
public function getHardness() : float{
return 3;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(3.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN));
}
public function getLightLevel() : int{

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class Emerald extends Solid{
public function getHardness() : float{
return 5;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_IRON;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(5.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_IRON, 30.0));
}
}

View File

@ -30,16 +30,8 @@ use function mt_rand;
class EmeraldOre extends Solid{
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_IRON;
}
public function getHardness() : float{
return 3;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(3.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_IRON));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -33,20 +33,8 @@ use pocketmine\Player;
class EnchantingTable extends Transparent{
public function getHardness() : float{
return 5;
}
public function getBlastResistance() : float{
return 6000;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(5.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 6000.0));
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{

View File

@ -38,6 +38,10 @@ class EndPortalFrame extends Solid{
/** @var bool */
protected $eye = false;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::indestructible());
}
protected function writeStateToMeta() : int{
return Bearing::fromFacing($this->facing) | ($this->eye ? 0x04 : 0);
}
@ -55,18 +59,6 @@ class EndPortalFrame extends Solid{
return 1;
}
public function getHardness() : float{
return -1;
}
public function getBlastResistance() : float{
return 18000000;
}
public function isBreakable(Item $item) : bool{
return false;
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return AxisAlignedBB::one()->trim(Facing::UP, 3 / 16);
}

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class EndStone extends Solid{
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getHardness() : float{
return 3;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(3.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 45.0));
}
}

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class EndStoneBricks extends Solid{
public function getHardness() : float{
return 0.8;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.8, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 4.0));
}
}

View File

@ -38,6 +38,10 @@ class EnderChest extends Transparent{
/** @var int */
protected $facing = Facing::NORTH;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(22.5, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 3000.0));
}
protected function writeStateToMeta() : int{
return $this->facing;
}
@ -50,26 +54,10 @@ class EnderChest extends Transparent{
return 0b111;
}
public function getHardness() : float{
return 22.5;
}
public function getBlastResistance() : float{
return 3000;
}
public function getLightLevel() : int{
return 7;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
//these are slightly bigger than in PC
return AxisAlignedBB::one()->contract(0.025, 0, 0.025)->trim(Facing::UP, 0.05);

View File

@ -34,6 +34,10 @@ class Farmland extends Transparent{
/** @var int */
protected $wetness = 0; //"moisture" blockstate property in PC
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.6, BlockToolType::TYPE_SHOVEL));
}
protected function writeStateToMeta() : int{
return $this->wetness;
}
@ -46,14 +50,6 @@ class Farmland extends Transparent{
return 0b111;
}
public function getHardness() : float{
return 0.6;
}
public function getToolType() : int{
return BlockToolType::TYPE_SHOVEL;
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return AxisAlignedBB::one(); //TODO: this should be trimmed at the top by 1/16, but MCPE currently treats them as a full block (https://bugs.mojang.com/browse/MCPE-12109)
}

View File

@ -40,6 +40,10 @@ class FenceGate extends Transparent{
/** @var bool */
protected $inWall = false;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.0, BlockToolType::TYPE_AXE));
}
protected function writeStateToMeta() : int{
return Bearing::fromFacing($this->facing) | ($this->open ? 0x04 : 0) | ($this->inWall ? 0x08 : 0);
}
@ -54,15 +58,6 @@ class FenceGate extends Transparent{
return 0b1111;
}
public function getHardness() : float{
return 2;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
if($this->open){
return null;

View File

@ -60,10 +60,6 @@ class Fire extends Flowable{
return 15;
}
public function isBreakable(Item $item) : bool{
return false;
}
public function canBeReplaced() : bool{
return true;
}

View File

@ -27,12 +27,12 @@ use pocketmine\math\AxisAlignedBB;
abstract class Flowable extends Transparent{
public function canBeFlowedInto() : bool{
return true;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
}
public function getHardness() : float{
return 0;
public function canBeFlowedInto() : bool{
return true;
}
public function isSolid() : bool{

View File

@ -32,6 +32,10 @@ class FrostedIce extends Ice{
/** @var int */
protected $age = 0;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.5, BlockToolType::TYPE_PICKAXE));
}
public function readStateFromData(int $id, int $stateMeta) : void{
$this->age = BlockDataValidator::readBoundedInt("age", $stateMeta, 0, 3);
}
@ -44,10 +48,6 @@ class FrostedIce extends Ice{
return 0b11;
}
public function getHardness() : float{
return 2.5;
}
public function onNearbyBlockChange() : void{
if(!$this->checkAdjacentBlocks(2)){
$this->world->useBreakOn($this);

View File

@ -40,6 +40,10 @@ class Furnace extends Solid{
/** @var bool */
protected $lit = false; //this is set based on the blockID
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(3.5, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN));
}
public function getId() : int{
return $this->lit ? $this->idInfo->getSecondId() : parent::getId();
}
@ -57,18 +61,6 @@ class Furnace extends Solid{
return 0b111;
}
public function getHardness() : float{
return 3.5;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getLightLevel() : int{
return $this->lit ? 13 : 0;
}

View File

@ -27,8 +27,8 @@ use pocketmine\item\Item;
class Glass extends Transparent{
public function getHardness() : float{
return 0.3;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.3));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -27,8 +27,8 @@ use pocketmine\item\Item;
class GlassPane extends Thin{
public function getHardness() : float{
return 0.3;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.3));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -36,6 +36,10 @@ class GlazedTerracotta extends Solid{
/** @var int */
protected $facing = Facing::NORTH;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(1.4, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN));
}
protected function writeStateToMeta() : int{
return $this->facing;
}
@ -48,18 +52,6 @@ class GlazedTerracotta extends Solid{
return 0b111;
}
public function getHardness() : float{
return 1.4;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if($player !== null){
$this->facing = Facing::opposite($player->getHorizontalFacing());

View File

@ -28,23 +28,11 @@ use pocketmine\item\TieredTool;
class GlowingObsidian extends Solid{
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(10.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_DIAMOND, 50.0));
}
public function getLightLevel() : int{
return 12;
}
public function getHardness() : float{
return 10;
}
public function getBlastResistance() : float{
return 50;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_DIAMOND;
}
}

View File

@ -29,12 +29,8 @@ use function mt_rand;
class Glowstone extends Transparent{
public function getHardness() : float{
return 0.3;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.3, BlockToolType::TYPE_PICKAXE));
}
public function getLightLevel() : int{

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class Gold extends Solid{
public function getHardness() : float{
return 3;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_IRON;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(3.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_IRON, 30.0));
}
}

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class GoldOre extends Solid{
public function getHardness() : float{
return 3;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_IRON;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(3.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_IRON));
}
}

View File

@ -38,12 +38,8 @@ use function mt_rand;
class Grass extends Solid{
public function getHardness() : float{
return 0.6;
}
public function getToolType() : int{
return BlockToolType::TYPE_SHOVEL;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.6, BlockToolType::TYPE_SHOVEL));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -30,18 +30,14 @@ use pocketmine\math\Facing;
class GrassPath extends Transparent{
public function getToolType() : int{
return BlockToolType::TYPE_SHOVEL;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.6, BlockToolType::TYPE_SHOVEL));
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return AxisAlignedBB::one(); //TODO: this should be trimmed at the top by 1/16, but MCPE currently treats them as a full block (https://bugs.mojang.com/browse/MCPE-12109)
}
public function getHardness() : float{
return 0.6;
}
public function onNearbyBlockChange() : void{
if($this->getSide(Facing::UP)->isSolid()){
$this->world->setBlock($this, BlockFactory::get(BlockLegacyIds::DIRT));

View File

@ -32,12 +32,8 @@ use function mt_rand;
class Gravel extends Solid implements Fallable{
use FallableTrait;
public function getHardness() : float{
return 0.6;
}
public function getToolType() : int{
return BlockToolType::TYPE_SHOVEL;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.6, BlockToolType::TYPE_SHOVEL));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class HardenedClay extends Solid{
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getHardness() : float{
return 1.25;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(1.25, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 21.0));
}
}

View File

@ -25,7 +25,7 @@ namespace pocketmine\block;
class HardenedGlass extends Transparent{
public function getHardness() : float{
return 10;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(10.0));
}
}

View File

@ -25,7 +25,7 @@ namespace pocketmine\block;
class HardenedGlassPane extends Thin{
public function getHardness() : float{
return 10;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(10.0));
}
}

View File

@ -28,8 +28,8 @@ use pocketmine\block\utils\PillarRotationTrait;
class HayBale extends Solid{
use PillarRotationTrait;
public function getHardness() : float{
return 0.5;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.5));
}
public function getFlameEncouragement() : int{

View File

@ -29,8 +29,8 @@ use pocketmine\Player;
class Ice extends Transparent{
public function getHardness() : float{
return 0.5;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.5, BlockToolType::TYPE_PICKAXE));
}
public function getLightFilter() : int{
@ -41,10 +41,6 @@ class Ice extends Transparent{
return 0.98;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function onBreak(Item $item, ?Player $player = null) : bool{
if(($player === null or $player->isSurvival()) and !$item->hasEnchantment(Enchantment::SILK_TOUCH())){
return $this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::WATER));

View File

@ -27,8 +27,8 @@ use pocketmine\item\Item;
abstract class InfestedStone extends Solid{
public function getHardness() : float{
return 0.75;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.75));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -25,7 +25,7 @@ namespace pocketmine\block;
class InfoUpdate extends Solid{
public function getHardness() : float{
return 1;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(1.0));
}
}

View File

@ -23,19 +23,9 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
class InvisibleBedrock extends Transparent{
public function getHardness() : float{
return -1;
}
public function getBlastResistance() : float{
return 18000000;
}
public function isBreakable(Item $item) : bool{
return false;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::indestructible());
}
}

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class Iron extends Solid{
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_STONE;
}
public function getHardness() : float{
return 5;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(5.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_STONE, 30.0));
}
}

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class IronBars extends Thin{
public function getHardness() : float{
return 5;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(5.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 30.0));
}
}

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class IronDoor extends Door{
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getHardness() : float{
return 5;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(5.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 25.0));
}
}

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class IronOre extends Solid{
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_STONE;
}
public function getHardness() : float{
return 3;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(3.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_STONE));
}
}

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class IronTrapdoor extends Trapdoor{
public function getHardness() : float{
return 5;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(5.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN));
}
}

View File

@ -45,6 +45,10 @@ class ItemFrame extends Flowable{
/** @var float */
protected $itemDropChance = 1.0;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.25));
}
protected function writeStateToMeta() : int{
return (5 - $this->facing) | ($this->hasMap ? 0x04 : 0);
}
@ -200,8 +204,4 @@ class ItemFrame extends Flowable{
public function isAffectedBySilkTouch() : bool{
return false;
}
public function getHardness() : float{
return 0.25;
}
}

View File

@ -36,6 +36,10 @@ class Ladder extends Transparent{
/** @var int */
protected $facing = Facing::NORTH;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.4, BlockToolType::TYPE_AXE));
}
protected function writeStateToMeta() : int{
return $this->facing;
}
@ -56,10 +60,6 @@ class Ladder extends Transparent{
return false;
}
public function getHardness() : float{
return 0.4;
}
public function canClimb() : bool{
return true;
}
@ -90,8 +90,4 @@ class Ladder extends Transparent{
$this->world->useBreakOn($this);
}
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
}

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class Lapis extends Solid{
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_STONE;
}
public function getHardness() : float{
return 3;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(3.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_STONE));
}
}

View File

@ -30,16 +30,8 @@ use function mt_rand;
class LapisOre extends Solid{
public function getHardness() : float{
return 3;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_STONE;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(3.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_STONE));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -42,8 +42,8 @@ class Leaves extends Transparent{
/** @var bool */
protected $checkDecay = false;
public function __construct(BlockIdentifier $idInfo, string $name, TreeType $treeType){
parent::__construct($idInfo, $name);
public function __construct(BlockIdentifier $idInfo, string $name, TreeType $treeType, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.2, BlockToolType::TYPE_SHEARS));
$this->treeType = $treeType;
}
@ -60,14 +60,6 @@ class Leaves extends Transparent{
return 0b1100;
}
public function getHardness() : float{
return 0.2;
}
public function getToolType() : int{
return BlockToolType::TYPE_SHEARS;
}
public function diffusesSkyLight() : bool{
return true;
}

View File

@ -43,6 +43,10 @@ class Lever extends Flowable{
/** @var bool */
protected $powered = false;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.5));
}
protected function writeStateToMeta() : int{
if($this->position === self::BOTTOM){
$rotationMeta = Facing::axis($this->facing) === Facing::AXIS_Z ? 7 : 0;
@ -74,10 +78,6 @@ class Lever extends Flowable{
return 0b1111;
}
public function getHardness() : float{
return 0.5;
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if(!$blockClicked->isSolid()){
return false;

View File

@ -60,8 +60,8 @@ abstract class Liquid extends Transparent{
/** @var bool */
protected $still = false;
public function __construct(BlockIdentifierFlattened $idInfo, string $name){
parent::__construct($idInfo, $name);
public function __construct(BlockIdentifierFlattened $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::indestructible(500.0));
}
public function getId() : int{
@ -86,10 +86,6 @@ abstract class Liquid extends Transparent{
return true;
}
public function isBreakable(Item $item) : bool{
return false;
}
public function canBeReplaced() : bool{
return true;
}
@ -102,10 +98,6 @@ abstract class Liquid extends Transparent{
return false;
}
public function getHardness() : float{
return 100;
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return null;
}

View File

@ -30,16 +30,8 @@ use pocketmine\item\TieredTool;
class Magma extends Solid{
public function getHardness() : float{
return 0.5;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.5, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN));
}
public function getLightLevel() : int{

View File

@ -29,12 +29,8 @@ use function mt_rand;
class Melon extends Transparent{
public function getHardness() : float{
return 1;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(1.0, BlockToolType::TYPE_AXE));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -29,16 +29,8 @@ use function mt_rand;
class MonsterSpawner extends Transparent{
public function getHardness() : float{
return 5;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(5.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -31,12 +31,8 @@ use function mt_rand;
class Mycelium extends Solid{
public function getToolType() : int{
return BlockToolType::TYPE_SHOVEL;
}
public function getHardness() : float{
return 0.6;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.6, BlockToolType::TYPE_SHOVEL));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class NetherBrick extends Solid{
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getHardness() : float{
return 2;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 30.0));
}
}

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class NetherBrickFence extends Fence{
public function getHardness() : float{
return 2;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 30.0));
}
}

View File

@ -27,15 +27,7 @@ use pocketmine\item\TieredTool;
class NetherBrickStairs extends Stair{
public function getHardness() : float{
return 2;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 30.0));
}
}

View File

@ -32,6 +32,10 @@ class NetherPortal extends Transparent{
/** @var int */
protected $axis = Facing::AXIS_X;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::indestructible(0.0));
}
public function readStateFromData(int $id, int $stateMeta) : void{
$this->axis = $stateMeta === 2 ? Facing::AXIS_Z : Facing::AXIS_X; //mojang u dumb
}
@ -74,18 +78,6 @@ class NetherPortal extends Transparent{
return null;
}
public function isBreakable(Item $item) : bool{
return false;
}
public function getHardness() : float{
return -1;
}
public function getBlastResistance() : float{
return 0;
}
public function getDrops(Item $item) : array{
return [];
}

View File

@ -30,16 +30,8 @@ use function mt_rand;
class NetherQuartzOre extends Solid{
public function getHardness() : float{
return 3;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(3.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN));
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -36,6 +36,10 @@ class NetherReactor extends Solid{
/** @var int */
protected $state = self::STATE_INACTIVE;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(3.0, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN));
}
protected function writeStateToMeta() : int{
return $this->state;
}
@ -48,18 +52,6 @@ class NetherReactor extends Solid{
return 0b11;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
public function getHardness() : float{
return 3;
}
public function getDropsForCompatibleTool(Item $item) : array{
return [
ItemFactory::get(Item::IRON_INGOT, 0, 6),

View File

@ -25,7 +25,7 @@ namespace pocketmine\block;
class NetherWartBlock extends Solid{
public function getHardness() : float{
return 1;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(1.0));
}
}

View File

@ -27,16 +27,8 @@ use pocketmine\item\TieredTool;
class Netherrack extends Solid{
public function getHardness() : float{
return 0.4;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.4, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN));
}
public function burnsForever() : bool{

View File

@ -25,17 +25,13 @@ namespace pocketmine\block;
class NoteBlock extends Solid{
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.8, BlockToolType::TYPE_AXE));
}
public function getFuelTime() : int{
return 300;
}
public function getHardness() : float{
return 0.8;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
//TODO
}

View File

@ -27,19 +27,7 @@ use pocketmine\item\TieredTool;
class Obsidian extends Solid{
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_DIAMOND;
}
public function getHardness() : float{
return 35; //50 in PC
}
public function getBlastResistance() : float{
return 6000;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(35.0 /* 50 in PC */, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_DIAMOND, 6000.0));
}
}

View File

@ -27,18 +27,14 @@ use pocketmine\item\Item;
class PackedIce extends Solid{
public function getHardness() : float{
return 0.5;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.5, BlockToolType::TYPE_PICKAXE));
}
public function getFrictionFactor() : float{
return 0.98;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getDropsForCompatibleTool(Item $item) : array{
return [];
}

View File

@ -25,12 +25,8 @@ namespace pocketmine\block;
class Planks extends Solid{
public function getHardness() : float{
return 2;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.0, BlockToolType::TYPE_AXE, 0, 15.0));
}
public function getFuelTime() : int{

View File

@ -25,11 +25,7 @@ namespace pocketmine\block;
class Podzol extends Solid{
public function getToolType() : int{
return BlockToolType::TYPE_SHOVEL;
}
public function getHardness() : float{
return 2.5;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(2.5, BlockToolType::TYPE_SHOVEL));
}
}

View File

@ -31,15 +31,7 @@ class Prismarine extends Solid{
public const DARK = 1;
public const BRICKS = 2;
public function getHardness() : float{
return 1.5;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(1.5, BlockToolType::TYPE_PICKAXE, TieredTool::TIER_WOODEN, 30.0));
}
}

View File

@ -35,6 +35,10 @@ class Pumpkin extends Solid{
/** @var int */
protected $facing = Facing::NORTH;
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(1.0, BlockToolType::TYPE_AXE));
}
public function readStateFromData(int $id, int $stateMeta) : void{
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($stateMeta & 0x03);
}
@ -47,14 +51,6 @@ class Pumpkin extends Solid{
return 0b11;
}
public function getHardness() : float{
return 1;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if($player !== null){
$this->facing = Facing::opposite($player->getHorizontalFacing());

Some files were not shown because too many files have changed in this diff Show More