mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Fixed liquid CPU leaks and some flow issues
Liquid still needs a total rewrite, but at least it won't constantly waste CPU anymore.
This commit is contained in:
parent
acaa0d2740
commit
210bdc2436
@ -241,9 +241,9 @@ abstract class Liquid extends Transparent{
|
||||
if($k !== $decay){
|
||||
$decay = $k;
|
||||
if($decay < 0){
|
||||
$this->getLevel()->setBlock($this, new Air(), true);
|
||||
$this->getLevel()->setBlock($this, new Air(), true, true);
|
||||
}else{
|
||||
$this->getLevel()->setBlock($this, Block::get($this->id, $decay), true);
|
||||
$this->getLevel()->setBlock($this, Block::get($this->id, $decay), true, true);
|
||||
$this->getLevel()->scheduleDelayedBlockUpdate($this, $this->tickRate());
|
||||
}
|
||||
}elseif($flag){
|
||||
@ -256,19 +256,13 @@ abstract class Liquid extends Transparent{
|
||||
|
||||
$bottomBlock = $this->level->getBlock($this->temporalVector->setComponents($this->x, $this->y - 1, $this->z));
|
||||
|
||||
if($bottomBlock->canBeFlowedInto() or $bottomBlock instanceof Liquid){
|
||||
if($this instanceof Lava and $bottomBlock instanceof Water){
|
||||
$this->getLevel()->setBlock($bottomBlock, Block::get(Item::STONE), true);
|
||||
return;
|
||||
}
|
||||
if($this instanceof Lava and $bottomBlock instanceof Water){
|
||||
$this->getLevel()->setBlock($bottomBlock, Block::get(Block::STONE), true, true);
|
||||
|
||||
}elseif($bottomBlock->canBeFlowedInto() or ($bottomBlock instanceof Liquid and ($bottomBlock->getDamage() & 0x07) !== 0)){
|
||||
$this->getLevel()->setBlock($bottomBlock, Block::get($this->id, $decay | 0x08), true, false);
|
||||
$this->getLevel()->scheduleDelayedBlockUpdate($bottomBlock, $this->tickRate());
|
||||
|
||||
if($decay >= 8){
|
||||
$this->getLevel()->setBlock($bottomBlock, Block::get($this->id, $decay), true);
|
||||
$this->getLevel()->scheduleDelayedBlockUpdate($bottomBlock, $this->tickRate());
|
||||
}else{
|
||||
$this->getLevel()->setBlock($bottomBlock, Block::get($this->id, $decay + 8), true);
|
||||
$this->getLevel()->scheduleDelayedBlockUpdate($bottomBlock, $this->tickRate());
|
||||
}
|
||||
}elseif($decay >= 0 and ($decay === 0 or !$bottomBlock->canBeFlowedInto())){
|
||||
$flags = $this->getOptimalFlowDirections();
|
||||
|
||||
@ -311,7 +305,7 @@ abstract class Liquid extends Transparent{
|
||||
$this->getLevel()->useBreakOn($block);
|
||||
}
|
||||
|
||||
$this->getLevel()->setBlock($block, Block::get($this->getId(), $newFlowDecay), true);
|
||||
$this->getLevel()->setBlock($block, Block::get($this->getId(), $newFlowDecay), true, false);
|
||||
$this->getLevel()->scheduleDelayedBlockUpdate($block, $this->tickRate());
|
||||
}
|
||||
}
|
||||
@ -440,9 +434,9 @@ abstract class Liquid extends Transparent{
|
||||
|
||||
if($colliding){
|
||||
if($this->getDamage() === 0){
|
||||
$this->getLevel()->setBlock($this, Block::get(Item::OBSIDIAN), true);
|
||||
$this->getLevel()->setBlock($this, Block::get(Item::OBSIDIAN), true, true);
|
||||
}elseif($this->getDamage() <= 4){
|
||||
$this->getLevel()->setBlock($this, Block::get(Item::COBBLESTONE), true);
|
||||
$this->getLevel()->setBlock($this, Block::get(Item::COBBLESTONE), true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,13 +29,6 @@ class StillLava extends Lava{
|
||||
|
||||
protected $id = self::STILL_LAVA;
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type !== Level::BLOCK_UPDATE_SCHEDULED){
|
||||
return parent::onUpdate($type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Still Lava";
|
||||
}
|
||||
|
@ -29,14 +29,6 @@ class StillWater extends Water{
|
||||
|
||||
protected $id = self::STILL_WATER;
|
||||
|
||||
public function onUpdate($type){
|
||||
//TODO: add freezing in cold biomes
|
||||
if($type !== Level::BLOCK_UPDATE_SCHEDULED){
|
||||
return parent::onUpdate($type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Still Water";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user