mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
first shot making Block not extend Position
this makes some stuff a lot less pretty, but this seems to be the bare minimum necessary to do this task. It can be enhanced later.
This commit is contained in:
@ -50,17 +50,17 @@ class FrostedIce extends Ice{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->checkAdjacentBlocks(2)){
|
||||
$this->world->useBreakOn($this);
|
||||
$this->pos->getWorld()->useBreakOn($this->pos);
|
||||
}else{
|
||||
$this->world->scheduleDelayedBlockUpdate($this, mt_rand(20, 40));
|
||||
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, mt_rand(20, 40));
|
||||
}
|
||||
}
|
||||
|
||||
public function onRandomTick() : void{
|
||||
if((!$this->checkAdjacentBlocks(4) or mt_rand(0, 2) === 0) and
|
||||
max( //TODO: move this to World
|
||||
$this->world->getHighestAdjacentBlockLight($this->x, $this->y, $this->z),
|
||||
$this->world->getHighestAdjacentBlockSkyLight($this->x, $this->y, $this->z) - $this->world->getSkyLightReduction()
|
||||
$this->pos->getWorld()->getHighestAdjacentBlockLight($this->pos->x, $this->pos->y, $this->pos->z),
|
||||
$this->pos->getWorld()->getHighestAdjacentBlockSkyLight($this->pos->x, $this->pos->y, $this->pos->z) - $this->pos->getWorld()->getSkyLightReduction()
|
||||
) >= 12 - $this->age){
|
||||
if($this->tryMelt()){
|
||||
foreach($this->getAllSides() as $block){
|
||||
@ -70,7 +70,7 @@ class FrostedIce extends Ice{
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$this->world->scheduleDelayedBlockUpdate($this, mt_rand(20, 40));
|
||||
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, mt_rand(20, 40));
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ class FrostedIce extends Ice{
|
||||
continue;
|
||||
}
|
||||
if(
|
||||
$this->world->getBlockAt($this->x + $x, $this->y, $this->z + $z) instanceof FrostedIce and
|
||||
$this->pos->getWorld()->getBlockAt($this->pos->x + $x, $this->pos->y, $this->pos->z + $z) instanceof FrostedIce and
|
||||
++$found >= $requirement
|
||||
){
|
||||
return true;
|
||||
@ -103,13 +103,13 @@ class FrostedIce extends Ice{
|
||||
*/
|
||||
private function tryMelt() : bool{
|
||||
if($this->age >= 3){
|
||||
$this->world->useBreakOn($this);
|
||||
$this->pos->getWorld()->useBreakOn($this->pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->age++;
|
||||
$this->world->setBlock($this, $this);
|
||||
$this->world->scheduleDelayedBlockUpdate($this, mt_rand(20, 40));
|
||||
$this->pos->getWorld()->setBlock($this->pos, $this);
|
||||
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, mt_rand(20, 40));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user