本文整理匯總了PHP中pocketmine\entity\Entity::getBreakTime方法的典型用法代碼示例。如果您正苦於以下問題:PHP Entity::getBreakTime方法的具體用法?PHP Entity::getBreakTime怎麽用?PHP Entity::getBreakTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\entity\Entity
的用法示例。
在下文中一共展示了Entity::getBreakTime方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: useOn
/**
* TODO: Move this to each item
*
* @param Entity|Block $object
*
* @return bool
*/
public function useOn($object)
{
if ($this->isUnbreakable()) {
return false;
}
$break = true;
if (($ench = $this->getEnchantment(Enchantment::TYPE_MINING_DURABILITY)) != null) {
$rnd = mt_rand(1, 100);
if ($rnd <= 100 / ($ench->getLevel() + 1)) {
$break = false;
}
}
if ($object instanceof Block) {
if (!$break) {
return false;
}
if ($object->getToolType() === Tool::TYPE_PICKAXE and $this->isPickaxe() or $object->getToolType() === Tool::TYPE_SHOVEL and $this->isShovel() or $object->getToolType() === Tool::TYPE_AXE and $this->isAxe() or $object->getToolType() === Tool::TYPE_SWORD and $this->isSword() or $object->getToolType() === Tool::TYPE_SHEARS and $this->isShears()) {
$this->meta++;
} elseif (!$this->isShears() and $object->getBreakTime($this) > 0) {
$this->meta += 2;
}
} elseif ($this->isHoe()) {
if (!$break) {
return false;
}
if ($object instanceof Block and ($object->getId() === self::GRASS or $object->getId() === self::DIRT)) {
$this->meta++;
}
} elseif ($object instanceof Entity) {
$return = true;
if (!$this->isSword()) {
if ($break) {
$this->meta += 2;
$return = false;
}
} else {
if ($break) {
$this->meta++;
$return = false;
}
if (!$this->hasEnchantments()) {
return $return;
}
//TODO: move attacking from player class here
//$fire = $this->getEnchantment(Enchantment::TYPE_WEAPON_FIRE_ASPECT);
//$object->setOnFire($fire->getLevel() * 4);
}
}
return true;
}
示例2: useOn
/**
* TODO: Move this to each item
*
* @param Entity|Block $object
*
* @return bool
*/
public function useOn($object)
{
if ($this->isUnbreakable()) {
return true;
}
if ($object instanceof Block) {
if ($object->getToolType() === Tool::TYPE_PICKAXE and $this->isPickaxe() or $object->getToolType() === Tool::TYPE_SHOVEL and $this->isShovel() or $object->getToolType() === Tool::TYPE_AXE and $this->isAxe() or $object->getToolType() === Tool::TYPE_SWORD and $this->isSword() or $object->getToolType() === Tool::TYPE_SHEARS and $this->isShears()) {
$this->meta++;
} elseif (!$this->isShears() and $object->getBreakTime($this) > 0) {
$this->meta += 2;
}
} elseif ($this->isHoe()) {
if ($object instanceof Block and ($object->getId() === self::GRASS or $object->getId() === self::DIRT)) {
$this->meta++;
}
} elseif ($object instanceof Entity and !$this->isSword()) {
$this->meta += 2;
} else {
$this->meta++;
}
return true;
}