SurvivalBlockBreakHandler: remove useless code

This commit is contained in:
Dylan K. Taylor 2021-10-30 21:35:58 +01:00
parent 1d22761d27
commit 4f816d03a7
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 3 additions and 11 deletions

View File

@ -1518,8 +1518,8 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
return true;
}
if(!$this->isCreative()){
$this->blockBreakHandler = SurvivalBlockBreakHandler::createIfNecessary($this, $pos, $target, $face, 16);
if(!$this->isCreative() && !$block->getBreakInfo()->breaksInstantly()){
$this->blockBreakHandler = new SurvivalBlockBreakHandler($this, $pos, $target, $face, 16);
}
return true;

View File

@ -59,7 +59,7 @@ final class SurvivalBlockBreakHandler{
/** @var float */
private $breakProgress = 0;
private function __construct(Player $player, Vector3 $blockPos, Block $block, int $targetedFace, int $maxPlayerDistance, int $fxTickInterval = self::DEFAULT_FX_INTERVAL_TICKS){
public function __construct(Player $player, Vector3 $blockPos, Block $block, int $targetedFace, int $maxPlayerDistance, int $fxTickInterval = self::DEFAULT_FX_INTERVAL_TICKS){
$this->player = $player;
$this->blockPos = $blockPos;
$this->block = $block;
@ -76,14 +76,6 @@ final class SurvivalBlockBreakHandler{
}
}
public static function createIfNecessary(Player $player, Vector3 $blockPos, Block $block, int $targetedFace, int $maxPlayerDistance, int $fxTickInterval = self::DEFAULT_FX_INTERVAL_TICKS) : ?self{
$breakInfo = $block->getBreakInfo();
if(!$breakInfo->breaksInstantly()){
return new self($player, $blockPos, $block, $targetedFace, $maxPlayerDistance, $fxTickInterval);
}
return null;
}
/**
* Returns the calculated break speed as percentage progress per game tick.
*/