explosion tweaks

This commit is contained in:
GameHerobrine 2023-02-22 17:22:44 +03:00
parent 90d1865cb1
commit a5a0c0e000
3 changed files with 23 additions and 12 deletions

View file

@ -13,5 +13,9 @@ class LiquidBlock extends TransparentBlock{
$this->isReplaceable = true; $this->isReplaceable = true;
$this->isSolid = false; $this->isSolid = false;
$this->isFullBlock = true; $this->isFullBlock = true;
$this->hardness = 500;
}
public function getDrops(Item $item, Player $player){
return array();
} }
} }

View file

@ -3,7 +3,7 @@
class LavaBlock extends LiquidBlock implements LightingBlock{ class LavaBlock extends LiquidBlock implements LightingBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(LAVA, $meta, "Lava"); parent::__construct(LAVA, $meta, "Lava");
$this->hardness = 0; $this->hardness = 500;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View file

@ -52,6 +52,7 @@ class Explosion{
]) === false){ ]) === false){
return false; return false;
} }
$visited = [];
$mRays = $this->rays - 1; $mRays = $this->rays - 1;
for($i = 0; $i < $this->rays; ++$i){ for($i = 0; $i < $this->rays; ++$i){
for($j = 0; $j < $this->rays; ++$j){ for($j = 0; $j < $this->rays; ++$j){
@ -63,14 +64,20 @@ class Explosion{
for($blastForce = $this->size * (mt_rand(700, 1300) / 1000); $blastForce > 0; $blastForce -= $this->stepLen * 0.75){ for($blastForce = $this->size * (mt_rand(700, 1300) / 1000); $blastForce > 0; $blastForce -= $this->stepLen * 0.75){
$vBlock = $pointer->floor(); $vBlock = $pointer->floor();
$blockID = $this->level->level->getBlockID($vBlock->x, $vBlock->y, $vBlock->z); $BIDM = $this->level->level->getBlock($vBlock->x, $vBlock->y, $vBlock->z);
$blockMeta = $this->level->level->getBlockDamage($vBlock->x, $vBlock->y, $vBlock->z); $blockID = $BIDM[0];
$blockMeta = $BIDM[1];
if($blockID > 0){ if($blockID > 0){
$block = BlockAPI::get($blockID, $blockMeta); $block = BlockAPI::get($blockID, $blockMeta);
$block->x = $vBlock->x; $block->x = $vBlock->x;
$block->y = $vBlock->y; $block->y = $vBlock->y;
$block->z = $vBlock->z; $block->z = $vBlock->z;
$block->level = $this->level; $block->level = $this->level;
$index = ($block->x << 15) + ($block->z << 7) + $block->y;
if($block instanceof LiquidBlock && !isset($visited[$index])){
ServerAPI::request()->api->block->scheduleBlockUpdate($block, 5, BLOCK_UPDATE_NORMAL);
$visited[$index] = true;
}
$blastForce -= ($block->getHardness() / 5 + 0.3) * $this->stepLen; $blastForce -= ($block->getHardness() / 5 + 0.3) * $this->stepLen;
if($blastForce > 0){ if($blastForce > 0){
$index = ($block->x << 15) + ($block->z << 7) + $block->y; $index = ($block->x << 15) + ($block->z << 7) + $block->y;