Refactor Block->getResistance() -> Block->getBlastResistance() and added some documentation

This commit is contained in:
Dylan K. Taylor 2017-08-20 13:25:43 +01:00
parent 216fc6fe31
commit eeedcf7332
11 changed files with 20 additions and 10 deletions

View File

@ -74,7 +74,7 @@ class Air extends Transparent{
return -1;
}
public function getResistance() : float{
public function getBlastResistance() : float{
return 0;
}

View File

@ -49,7 +49,7 @@ class Anvil extends Fallable{
return 5;
}
public function getResistance() : float{
public function getBlastResistance() : float{
return 6000;
}

View File

@ -41,7 +41,7 @@ class Bedrock extends Solid{
return -1;
}
public function getResistance() : float{
public function getBlastResistance() : float{
return 18000000;
}

View File

@ -531,6 +531,7 @@ class Block extends Position implements BlockIds, Metadatable{
}
/**
* Returns a base value used to compute block break times.
* @return float
*/
public function getHardness() : float{
@ -538,9 +539,18 @@ class Block extends Position implements BlockIds, Metadatable{
}
/**
* @deprecated
* @return float
*/
public function getResistance() : float{
return $this->getBlastResistance();
}
/**
* Returns the block's resistance to explosions. Usually 5x hardness.
* @return float
*/
public function getBlastResistance() : float{
return $this->getHardness() * 5;
}

View File

@ -37,7 +37,7 @@ class BrickStairs extends Stair{
return 2;
}
public function getResistance() : float{
public function getBlastResistance() : float{
return 30;
}

View File

@ -38,7 +38,7 @@ class Bricks extends Solid{
return 2;
}
public function getResistance() : float{
public function getBlastResistance() : float{
return 30;
}

View File

@ -69,7 +69,7 @@ class EnchantingTable extends Transparent{
return 5;
}
public function getResistance() : float{
public function getBlastResistance() : float{
return 6000;
}

View File

@ -46,7 +46,7 @@ class EndPortalFrame extends Solid{
return -1;
}
public function getResistance() : float{
public function getBlastResistance() : float{
return 18000000;
}

View File

@ -33,7 +33,7 @@ abstract class Flowable extends Transparent{
return 0;
}
public function getResistance() : float{
public function getBlastResistance() : float{
return 0;
}

View File

@ -32,7 +32,7 @@ class WoodenStairs extends Stair{
return 2;
}
public function getResistance() : float{
public function getBlastResistance() : float{
return 15;
}

View File

@ -95,7 +95,7 @@ class Explosion{
$block = $this->level->getBlock($vBlock);
if($block->getId() !== 0){
$blastForce -= ($block->getResistance() / 5 + 0.3) * $this->stepLen;
$blastForce -= ($block->getBlastResistance() / 5 + 0.3) * $this->stepLen;
if($blastForce > 0){
if(!isset($this->affectedBlocks[$index = Level::blockHash($block->x, $block->y, $block->z)])){
$this->affectedBlocks[$index] = $block;