fix(block): melt snow layers under high block light (#2419)

* fix(block): melt snow layers under high block light

Snow layers never melted because the block had no random_tick handler.
Mirror vanilla SnowLayerBlock.randomTick: on a random tick, remove the
layer when the block light level at its position exceeds 11 (e.g. from
a nearby torch).

Fixes #2179

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* style: apply rustfmt
This commit is contained in:
Mcxiaocaibug
2026-07-20 16:17:40 +08:00
committed by GitHub
parent e0117ab559
commit 5bc4e1bd67

View File

@@ -10,7 +10,7 @@ use pumpkin_world::{
use crate::block::{
BlockBehaviour, BlockFuture, GetStateForNeighborUpdateArgs, OnPlaceArgs, OnScheduledTickArgs,
UseWithItemArgs, registry::BlockActionResult,
RandomTickArgs, UseWithItemArgs, registry::BlockActionResult,
};
#[pumpkin_block("minecraft:snow")]
@@ -86,6 +86,18 @@ impl BlockBehaviour for LayeredSnowBlock {
})
}
fn random_tick<'a>(&'a self, args: RandomTickArgs<'a>) -> BlockFuture<'a, ()> {
Box::pin(async move {
// Snow layers melt when lit by block light above level 11,
// e.g. from a nearby torch.
if args.world.get_block_light_level(args.position).unwrap_or(0) > 11 {
args.world
.break_block(args.position, None, BlockFlags::empty())
.await;
}
})
}
fn get_state_for_neighbor_update<'a>(
&'a self,
args: GetStateForNeighborUpdateArgs<'a>,