mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-30 20:14:23 +00:00
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:
@@ -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>,
|
||||
|
||||
Reference in New Issue
Block a user