Skip to content

Commit 5bc4e1b

Browse files
authored
fix(block): melt snow layers under high block light (Pumpkin-MC#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 Pumpkin-MC#2179 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * style: apply rustfmt
1 parent e0117ab commit 5bc4e1b

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

pumpkin/src/block/blocks/snow.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use pumpkin_world::{
1010

1111
use crate::block::{
1212
BlockBehaviour, BlockFuture, GetStateForNeighborUpdateArgs, OnPlaceArgs, OnScheduledTickArgs,
13-
UseWithItemArgs, registry::BlockActionResult,
13+
RandomTickArgs, UseWithItemArgs, registry::BlockActionResult,
1414
};
1515

1616
#[pumpkin_block("minecraft:snow")]
@@ -86,6 +86,18 @@ impl BlockBehaviour for LayeredSnowBlock {
8686
})
8787
}
8888

89+
fn random_tick<'a>(&'a self, args: RandomTickArgs<'a>) -> BlockFuture<'a, ()> {
90+
Box::pin(async move {
91+
// Snow layers melt when lit by block light above level 11,
92+
// e.g. from a nearby torch.
93+
if args.world.get_block_light_level(args.position).unwrap_or(0) > 11 {
94+
args.world
95+
.break_block(args.position, None, BlockFlags::empty())
96+
.await;
97+
}
98+
})
99+
}
100+
89101
fn get_state_for_neighbor_update<'a>(
90102
&'a self,
91103
args: GetStateForNeighborUpdateArgs<'a>,

0 commit comments

Comments
 (0)