diff --git a/src/material/block/nonfull/SnowLayerBlock.php b/src/material/block/nonfull/SnowLayerBlock.php index 9d03ff58..ccabc6ed 100644 --- a/src/material/block/nonfull/SnowLayerBlock.php +++ b/src/material/block/nonfull/SnowLayerBlock.php @@ -28,6 +28,12 @@ class SnowLayerBlock extends FlowableBlock{ $level->fastSetBlockUpdate($x, $y, $z, 0, 0, true); } } + + public static function onRandomTick(Level $level, $x, $y, $z){ + if($level->level->getBlockLight($x, $y, $z) > 11){ + $level->fastSetBlockUpdate($x, $y, $z, 0, true); + } + } public function getDrops(Item $item, Player $player){ if($item->isShovel() !== false){ diff --git a/src/material/block/solid/IceBlock.php b/src/material/block/solid/IceBlock.php index 3b74cab2..89ebdd7a 100644 --- a/src/material/block/solid/IceBlock.php +++ b/src/material/block/solid/IceBlock.php @@ -29,33 +29,13 @@ class IceBlock extends TransparentBlock{ } return true; } - - private function scanForNearbyLightSources($offsetX, $offsetY, $offsetZ){ - for($x = -$offsetX; $x <= $offsetX; ++$x){ //i hope it is possible to optimize it - for($z = -$offsetZ; $z <= $offsetZ; ++$z){ - for($y = -$offsetY; $y <= $offsetY; ++$y){ - $pX = $this->x+$x; - $pY = $this->y+$y; - $pZ = $this->z+$z; - $block = $this->level->getBlock(new Vector3($pX, $pY, $pZ)); //D= slow what was u thinking of gameherobrine from 2022 - if($block instanceof LightingBlock){ //idk is it possible to make it better - return $block; - } - } - } + + public static function onRandomTick(Level $level, $x, $y, $z){ + if($level->level->getBlockLight($x, $y, $z) > 11 - StaticBlock::$lightBlock[ICE]){ + $level->fastSetBlockUpdate($x, $y, $z, STILL_WATER, true); } } - //public static function onUpdate(Level $level, $x, $y, $z, $type){ /*Taken from https://github.com/PocketMine/PocketMine-MP/issues/3249*/ - /*if($type === BLOCK_UPDATE_RANDOM){ - $light = $this->scanForNearbyLightSources(3,3,3); - if(LightUtils::getLightValueFromNearbySource($light,$this) > 12){ - $this->level->setBlock($this, new WaterBlock(), true); - ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL); //additional request for update - } - return BLOCK_UPDATE_RANDOM; - } - return false;*/ //TODO ice melting(after light?) - //} + public function getBreakTime(Item $item, Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20; diff --git a/src/world/Level.php b/src/world/Level.php index 8714b4aa..b14f7dc6 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -43,8 +43,9 @@ class Level{ WHEAT_BLOCK => true, DIRT => true, GRASS => true, - ICE => true, - LEAVES => true + LEAVES => true, + SNOW_LAYER => true, + ICE => true ]; public function __construct(PMFLevel $level, Config $entities, Config $tiles, Config $blockUpdates, $name){