mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Liquid: Update legacy code with Facing::OFFSET
This commit is contained in:
parent
114f444ec3
commit
f868c1d8c6
@ -170,16 +170,11 @@ abstract class Liquid extends Transparent{
|
|||||||
$world = $this->position->getWorld();
|
$world = $this->position->getWorld();
|
||||||
|
|
||||||
foreach(Facing::HORIZONTAL as $j){
|
foreach(Facing::HORIZONTAL as $j){
|
||||||
$x = $this->position->x;
|
[$dx, $dy, $dz] = Facing::OFFSET[$j];
|
||||||
$y = $this->position->y;
|
|
||||||
$z = $this->position->z;
|
|
||||||
|
|
||||||
match($j){
|
$x = $this->position->x + $dx;
|
||||||
Facing::WEST => --$x,
|
$y = $this->position->y + $dy;
|
||||||
Facing::EAST => ++$x,
|
$z = $this->position->z + $dz;
|
||||||
Facing::NORTH => --$z,
|
|
||||||
Facing::SOUTH => ++$z
|
|
||||||
};
|
|
||||||
|
|
||||||
$sideBlock = $world->getBlockAt($x, $y, $z);
|
$sideBlock = $world->getBlockAt($x, $y, $z);
|
||||||
$blockDecay = $this->getEffectiveFlowDecay($sideBlock);
|
$blockDecay = $this->getEffectiveFlowDecay($sideBlock);
|
||||||
|
@ -58,17 +58,10 @@ final class MinimumCostFlowCalculator{
|
|||||||
if($j === $originOpposite || $j === $lastOpposite){
|
if($j === $originOpposite || $j === $lastOpposite){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
[$dx, $dy, $dz] = Facing::OFFSET[$j];
|
||||||
$x = $blockX;
|
$x = $blockX + $dx;
|
||||||
$y = $blockY;
|
$y = $blockY + $dy;
|
||||||
$z = $blockZ;
|
$z = $blockZ + $dz;
|
||||||
|
|
||||||
match($j){
|
|
||||||
Facing::WEST => --$x,
|
|
||||||
Facing::EAST => ++$x,
|
|
||||||
Facing::NORTH => --$z,
|
|
||||||
Facing::SOUTH => ++$z
|
|
||||||
};
|
|
||||||
|
|
||||||
if(!isset($this->flowCostVisited[$hash = World::blockHash($x, $y, $z)])){
|
if(!isset($this->flowCostVisited[$hash = World::blockHash($x, $y, $z)])){
|
||||||
if(!$this->world->isInWorld($x, $y, $z) || !$this->canFlowInto($this->world->getBlockAt($x, $y, $z))){
|
if(!$this->world->isInWorld($x, $y, $z) || !$this->canFlowInto($this->world->getBlockAt($x, $y, $z))){
|
||||||
@ -109,16 +102,10 @@ final class MinimumCostFlowCalculator{
|
|||||||
$flowCost = array_fill_keys(Facing::HORIZONTAL, 1000);
|
$flowCost = array_fill_keys(Facing::HORIZONTAL, 1000);
|
||||||
$maxCost = intdiv(4, $this->flowDecayPerBlock);
|
$maxCost = intdiv(4, $this->flowDecayPerBlock);
|
||||||
foreach(Facing::HORIZONTAL as $j){
|
foreach(Facing::HORIZONTAL as $j){
|
||||||
$x = $originX;
|
[$dx, $dy, $dz] = Facing::OFFSET[$j];
|
||||||
$y = $originY;
|
$x = $originX + $dx;
|
||||||
$z = $originZ;
|
$y = $originY + $dy;
|
||||||
|
$z = $originZ + $dz;
|
||||||
match($j){
|
|
||||||
Facing::WEST => --$x,
|
|
||||||
Facing::EAST => ++$x,
|
|
||||||
Facing::NORTH => --$z,
|
|
||||||
Facing::SOUTH => ++$z
|
|
||||||
};
|
|
||||||
|
|
||||||
if(!$this->world->isInWorld($x, $y, $z) || !$this->canFlowInto($this->world->getBlockAt($x, $y, $z))){
|
if(!$this->world->isInWorld($x, $y, $z) || !$this->canFlowInto($this->world->getBlockAt($x, $y, $z))){
|
||||||
$this->flowCostVisited[World::blockHash($x, $y, $z)] = self::BLOCKED;
|
$this->flowCostVisited[World::blockHash($x, $y, $z)] = self::BLOCKED;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user