From 5d5099c06f39fbdb9ed043988a098b0f456e5b08 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Fri, 24 May 2024 06:57:52 +0300 Subject: [PATCH] removed some useless stuff from explosion, onPlace should be called every ti --- .../block/liquid/LiquidBlockDynamic.php | 2 +- src/pmf/PMFLevel.php | 9 +++++++- src/world/Explosion.php | 21 +++++++------------ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/material/block/liquid/LiquidBlockDynamic.php b/src/material/block/liquid/LiquidBlockDynamic.php index 7736582f..1dfcff3c 100644 --- a/src/material/block/liquid/LiquidBlockDynamic.php +++ b/src/material/block/liquid/LiquidBlockDynamic.php @@ -203,7 +203,7 @@ class LiquidBlockDynamic extends LiquidBlock{ $flags = static::getSpread($level, $x, $y, $z); $k1 = $depth >= 8 ? 1 : ($depth + $flowAdd); if($k1 >= 8) return; - //TODO flags are broken, no flags makes too much of the liquid + if($flags[0]) static::trySpreadTo($level, $x - 1, $y, $z, $k1); if($flags[1]) static::trySpreadTo($level, $x + 1, $y, $z, $k1); if($flags[2]) static::trySpreadTo($level, $x, $y, $z - 1, $k1); diff --git a/src/pmf/PMFLevel.php b/src/pmf/PMFLevel.php index 5856dea0..3dfb7cfa 100644 --- a/src/pmf/PMFLevel.php +++ b/src/pmf/PMFLevel.php @@ -369,7 +369,14 @@ class PMFLevel extends PMF{ $aX = $x & 0xf; $aZ = $z & 0xf; $aY = $y & 0xf; - $this->chunks[$index][$Y][(int) ($aY + ($aX << 5) + ($aZ << 9))] = chr($block); + $bind = (int) ($aY + ($aX << 5) + ($aZ << 9)); + if($this->chunks[$index][$Y][$bind] == chr($block)){ + return false; //no changes done + }else{ + $this->chunks[$index][$Y][$bind] = chr($block); + if($block > 0) StaticBlock::getBlock($block)::onPlace($this->level, $x, $y, $z); + } + if(!isset($this->chunkChange[$index][$Y])){ $this->chunkChange[$index][$Y] = 1; }else{ diff --git a/src/world/Explosion.php b/src/world/Explosion.php index a49d6277..71e75c8e 100644 --- a/src/world/Explosion.php +++ b/src/world/Explosion.php @@ -27,7 +27,7 @@ class Explosion{ $this->nullPlayer = new PlayerNull(); } - public function sub_expl(&$visited, $i, $mRays, $j, $k){ + public function sub_expl($i, $mRays, $j, $k){ $vector = new Vector3($i / $mRays * 2 - 1, $j / $mRays * 2 - 1, $k / $mRays * 2 - 1); //($i / $mRays) * 2 - 1 $vector = $vector->normalize()->multiply($this->stepLen); $pointer = clone $this->source; @@ -39,11 +39,6 @@ class Explosion{ $blockMeta = $BIDM[1]; if($blockID > 0){ $index = ($vBlock->x << 16) + ($vBlock->z << 8) + $vBlock->y; - - if(StaticBlock::getIsLiquid($blockID) && !isset($visited[$index])){ - $visited[$index] = true; - } - $blastForce -= (StaticBlock::getHardness($blockID) / 5 + 0.3) * $this->stepLen; if($blastForce > 0){ if(!isset($this->affectedBlocks[$index])){ @@ -102,45 +97,45 @@ class Explosion{ ]) === false){ return false; } - $visited = []; + $mRays = $this->rays - 1; $i = 0; for($j = 0; $j <= $mRays; ++$j){ for($k = 0; $k <= $mRays; ++$k){ - $this->sub_expl($visited, $i, $mRays, $j, $k); //i wish there was #define or inline + $this->sub_expl($i, $mRays, $j, $k); //i wish there was #define or inline } } $i = $mRays; for($j = 0; $j <= $mRays; ++$j){ for($k = 0; $k <= $mRays; ++$k){ - $this->sub_expl($visited, $i, $mRays, $j, $k); + $this->sub_expl($i, $mRays, $j, $k); } } $j = 0; for($i = 1; $i < $mRays; ++$i){ for($k = 0; $k <= $mRays; ++$k){ - $this->sub_expl($visited, $i, $mRays, $j, $k); + $this->sub_expl($i, $mRays, $j, $k); } } $j = $mRays; for($i = 1; $i < $mRays; ++$i){ for($k = 0; $k <= $mRays; ++$k){ - $this->sub_expl($visited, $i, $mRays, $j, $k); + $this->sub_expl($i, $mRays, $j, $k); } } $k = 0; for($i = 1; $i < $mRays; ++$i){ for($j = 1; $j < $mRays; ++$j){ - $this->sub_expl($visited, $i, $mRays, $j, $k); + $this->sub_expl($i, $mRays, $j, $k); } } $k = $mRays; for($i = 1; $i < $mRays; ++$i){ for($j = 1; $j < $mRays; ++$j){ - $this->sub_expl($visited, $i, $mRays, $j, $k); + $this->sub_expl($i, $mRays, $j, $k); } } //if($i == 0 or $i == $mRays or $j == 0 or $j == $mRays or $k == 0 or $k == $mRays){