mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 13:25:16 +00:00
Declare tool harvest level as a property
This commit is contained in:
parent
45983acc0d
commit
dbc180315e
@ -195,14 +195,26 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getToolType() : int{
|
||||||
|
return BlockToolType::TYPE_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolHarvestLevel() : int{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public function canBeBrokenWith(Item $item) : bool{
|
public function canBeBrokenWith(Item $item) : bool{
|
||||||
if($this->getHardness() < 0){
|
if($this->getHardness() < 0){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$toolType = $this->getToolType();
|
$toolType = $this->getToolType();
|
||||||
return $toolType === BlockToolType::TYPE_NONE or ($toolType & $item->getBlockToolType()) !== 0;
|
$harvestLevel = $this->getToolHarvestLevel();
|
||||||
//TODO: check tool harvest level (tier)
|
return $toolType === BlockToolType::TYPE_NONE or $harvestLevel === 0 or (
|
||||||
|
($toolType & $item->getBlockToolType()) !== 0 and $item->getBlockToolHarvestLevel() >= $harvestLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -319,13 +331,6 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
return $this->getHardness() * 5;
|
return $this->getHardness() * 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getToolType() : int{
|
|
||||||
return BlockToolType::TYPE_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -35,6 +35,10 @@ class Axe extends TieredTool{
|
|||||||
return BlockToolType::TYPE_AXE;
|
return BlockToolType::TYPE_AXE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBlockToolHarvestLevel() : int{
|
||||||
|
return $this->tier;
|
||||||
|
}
|
||||||
|
|
||||||
public function getAttackPoints() : int{
|
public function getAttackPoints() : int{
|
||||||
return self::getBaseDamageFromTier($this->tier) - 1;
|
return self::getBaseDamageFromTier($this->tier) - 1;
|
||||||
}
|
}
|
||||||
|
@ -752,6 +752,10 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
return BlockToolType::TYPE_NONE;
|
return BlockToolType::TYPE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBlockToolHarvestLevel() : int{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum amount of damage this item can take before it breaks.
|
* Returns the maximum amount of damage this item can take before it breaks.
|
||||||
*
|
*
|
||||||
|
@ -35,6 +35,10 @@ class Pickaxe extends TieredTool{
|
|||||||
return BlockToolType::TYPE_PICKAXE;
|
return BlockToolType::TYPE_PICKAXE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBlockToolHarvestLevel() : int{
|
||||||
|
return $this->tier;
|
||||||
|
}
|
||||||
|
|
||||||
public function getAttackPoints() : int{
|
public function getAttackPoints() : int{
|
||||||
return self::getBaseDamageFromTier($this->tier) - 2;
|
return self::getBaseDamageFromTier($this->tier) - 2;
|
||||||
}
|
}
|
||||||
|
@ -42,4 +42,8 @@ class Shears extends Tool{
|
|||||||
public function getBlockToolType() : int{
|
public function getBlockToolType() : int{
|
||||||
return BlockToolType::TYPE_SHEARS;
|
return BlockToolType::TYPE_SHEARS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBlockToolHarvestLevel() : int{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
@ -35,6 +35,10 @@ class Shovel extends TieredTool{
|
|||||||
return BlockToolType::TYPE_SHOVEL;
|
return BlockToolType::TYPE_SHOVEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBlockToolHarvestLevel() : int{
|
||||||
|
return $this->tier;
|
||||||
|
}
|
||||||
|
|
||||||
public function getAttackPoints() : int{
|
public function getAttackPoints() : int{
|
||||||
return self::getBaseDamageFromTier($this->tier) - 3;
|
return self::getBaseDamageFromTier($this->tier) - 3;
|
||||||
}
|
}
|
||||||
|
@ -39,4 +39,7 @@ class Sword extends TieredTool{
|
|||||||
return self::getBaseDamageFromTier($this->tier);
|
return self::getBaseDamageFromTier($this->tier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBlockToolHarvestLevel() : int{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user