PocketMine-MP 5.39.3 git-66148f13a91e4af6778ba9f200ca25ad8a04a584
Loading...
Searching...
No Matches
pocketmine\block\BlockBreakInfo Class Reference
+ Collaboration diagram for pocketmine\block\BlockBreakInfo:

Public Member Functions

 __construct (private float $hardness, private int $toolType=BlockToolType::NONE, private int $toolHarvestLevel=0, ?float $blastResistance=null, ?bool $explosionHarvestable=null,)
 
 breaksInstantly ()
 
 getBlastResistance ()
 
 getBreakTime (Item $item)
 
 getHardness ()
 
 getToolHarvestLevel ()
 
 getToolType ()
 
 isBreakable ()
 
 isExplosionHarvestable ()
 
 isToolCompatible (Item $tool)
 

Static Public Member Functions

static axe (float $hardness, ?ToolTier $toolTier=null, ?float $blastResistance=null)
 
static indestructible (float $blastResistance=18000003.75)
 
static instant (int $toolType=BlockToolType::NONE, int $toolHarvestLevel=0)
 
static pickaxe (float $hardness, ?ToolTier $toolTier=null, ?float $blastResistance=null)
 
static shovel (float $hardness, ?ToolTier $toolTier=null, ?float $blastResistance=null)
 
static tier (float $hardness, int $toolType, ToolTier $toolTier, ?float $blastResistance=null)
 

Public Attributes

const COMPATIBLE_TOOL_MULTIPLIER = 1.5
 
const INCOMPATIBLE_TOOL_MULTIPLIER = 5.0
 

Detailed Description

Definition at line 30 of file BlockBreakInfo.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\block\BlockBreakInfo::__construct ( private float $hardness,
private int $toolType = BlockToolType::NONE,
private int $toolHarvestLevel = 0,
?float $blastResistance = null,
?bool $explosionHarvestable = null )
Parameters
float | null$blastResistancedefault 5x hardness
bool | null$explosionHarvestableWhether explosions are considered a compatible "tool" to harvest. Defaults to true if a pickaxe is compatible

Definition at line 49 of file BlockBreakInfo.php.

Member Function Documentation

◆ axe()

static pocketmine\block\BlockBreakInfo::axe ( float $hardness,
?ToolTier $toolTier = null,
?float $blastResistance = null )
static

Definition at line 72 of file BlockBreakInfo.php.

◆ breaksInstantly()

pocketmine\block\BlockBreakInfo::breaksInstantly ( )

Returns whether this block can be instantly broken.

Definition at line 101 of file BlockBreakInfo.php.

◆ getBlastResistance()

pocketmine\block\BlockBreakInfo::getBlastResistance ( )

Returns the block's resistance to explosions. Usually 5x hardness.

Definition at line 108 of file BlockBreakInfo.php.

◆ getBreakTime()

pocketmine\block\BlockBreakInfo::getBreakTime ( Item $item)

Returns the seconds that this block takes to be broken using an specific Item

Exceptions

InvalidArgumentException if the item efficiency is not a positive number

Definition at line 151 of file BlockBreakInfo.php.

◆ getHardness()

pocketmine\block\BlockBreakInfo::getHardness ( )

Returns a base value used to compute block break times.

Definition at line 87 of file BlockBreakInfo.php.

◆ getToolHarvestLevel()

pocketmine\block\BlockBreakInfo::getToolHarvestLevel ( )

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 also
Item::getBlockToolHarvestLevel()

Definition at line 126 of file BlockBreakInfo.php.

◆ getToolType()

pocketmine\block\BlockBreakInfo::getToolType ( )

Definition at line 112 of file BlockBreakInfo.php.

◆ indestructible()

static pocketmine\block\BlockBreakInfo::indestructible ( float $blastResistance = 18000003.75)
static

Definition at line 80 of file BlockBreakInfo.php.

◆ instant()

static pocketmine\block\BlockBreakInfo::instant ( int $toolType = BlockToolType::NONE,
int $toolHarvestLevel = 0 )
static

Definition at line 76 of file BlockBreakInfo.php.

◆ isBreakable()

pocketmine\block\BlockBreakInfo::isBreakable ( )

Returns whether the block can be broken at all.

Definition at line 94 of file BlockBreakInfo.php.

◆ isExplosionHarvestable()

pocketmine\block\BlockBreakInfo::isExplosionHarvestable ( )

Returns whether an explosion can harvest resources from the block, as if a compatible tool was used. If this returns true, required harvest level and tool type will be ignored when calculating drops for explosions. Otherwise, the block will behave as if it was broken with an empty hand.

Note: If the required harvest level is 0, this has no effect.

Definition at line 176 of file BlockBreakInfo.php.

◆ isToolCompatible()

pocketmine\block\BlockBreakInfo::isToolCompatible ( Item $tool)

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.

Definition at line 137 of file BlockBreakInfo.php.

◆ pickaxe()

static pocketmine\block\BlockBreakInfo::pickaxe ( float $hardness,
?ToolTier $toolTier = null,
?float $blastResistance = null )
static

Definition at line 64 of file BlockBreakInfo.php.

◆ shovel()

static pocketmine\block\BlockBreakInfo::shovel ( float $hardness,
?ToolTier $toolTier = null,
?float $blastResistance = null )
static

Definition at line 68 of file BlockBreakInfo.php.

◆ tier()

static pocketmine\block\BlockBreakInfo::tier ( float $hardness,
int $toolType,
ToolTier $toolTier,
?float $blastResistance = null )
static

Definition at line 60 of file BlockBreakInfo.php.

Member Data Documentation

◆ COMPATIBLE_TOOL_MULTIPLIER

const pocketmine\block\BlockBreakInfo::COMPATIBLE_TOOL_MULTIPLIER = 1.5

If the tool is the correct type and high enough harvest level (tool tier), base break time is hardness multiplied by this value.

Definition at line 35 of file BlockBreakInfo.php.

◆ INCOMPATIBLE_TOOL_MULTIPLIER

const pocketmine\block\BlockBreakInfo::INCOMPATIBLE_TOOL_MULTIPLIER = 5.0

If the tool is an incorrect type or too low harvest level (tool tier), base break time is hardness multiplied by this value.

Definition at line 40 of file BlockBreakInfo.php.


The documentation for this class was generated from the following file: