mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Liquid: add getMinAdjacentSourcesToFormSource(), remove circular dependency between Liquid and Water
this unpleasantly-named method allows controlling the source-forming behaviour of liquids by changing the required number of adjacent sources that must be present in order for a new source to form. This allows stuff like non-infinite water.
This commit is contained in:
parent
971cbe3929
commit
1ce388ca0b
@ -249,6 +249,14 @@ abstract class Liquid extends Transparent{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of source blocks of this liquid that must be horizontally adjacent to this block in order for
|
||||
* this block to become a source block itself, or null if the liquid does not exhibit source-forming behaviour.
|
||||
*/
|
||||
public function getMinAdjacentSourcesToFormSource() : ?int{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->checkForHarden()){
|
||||
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, $this->tickRate());
|
||||
@ -279,9 +287,10 @@ abstract class Liquid extends Transparent{
|
||||
$falling = true;
|
||||
}
|
||||
|
||||
if($this->adjacentSources >= 2 and $this instanceof Water){
|
||||
$minAdjacentSources = $this->getMinAdjacentSourcesToFormSource();
|
||||
if($minAdjacentSources !== null && $this->adjacentSources >= $minAdjacentSources){
|
||||
$bottomBlock = $world->getBlockAt($this->position->x, $this->position->y - 1, $this->position->z);
|
||||
if($bottomBlock->isSolid() or ($bottomBlock instanceof Water and $bottomBlock->isSource())){
|
||||
if($bottomBlock->isSolid() or ($bottomBlock instanceof Liquid and $bottomBlock->isSameType($this) and $bottomBlock->isSource())){
|
||||
$newDecay = 0;
|
||||
$falling = false;
|
||||
}
|
||||
|
@ -46,6 +46,10 @@ class Water extends Liquid{
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getMinAdjacentSourcesToFormSource() : ?int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function onEntityInside(Entity $entity) : bool{
|
||||
$entity->resetFallDistance();
|
||||
if($entity->isOnFire()){
|
||||
|
Loading…
x
Reference in New Issue
Block a user