From 3b2eba14577b0cdc11918bd6b971e6446ba338e4 Mon Sep 17 00:00:00 2001 From: Isse Date: Thu, 13 Oct 2022 21:15:22 +0200 Subject: [PATCH] autumn leaves --- world/src/block/mod.rs | 13 +++++++++++++ world/src/layer/scatter.rs | 37 +++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index f7390bbde1..df7c234151 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -265,6 +265,19 @@ pub fn block_from_structure( && field.chance(pos + structure_pos, 0.025) { Block::new(BlockKind::GlowingWeakRock, Rgb::new(255, 0, 0)) + } else if calendar.map_or(false, |c| c.is_event(CalendarEvent::Halloween)) + && sblock != StructureBlock::PineLeaves + { + let (c0, c1) = match structure_seed % 6 { + 0 => (Rgb::new(165.0, 150.0, 11.0), Rgb::new(170.0, 165.0, 16.0)), + 1 | 2 => (Rgb::new(218.0, 53.0, 3.0), Rgb::new(226.0, 62.0, 5.0)), + _ => (Rgb::new(230.0, 120.0, 20.0), Rgb::new(242.0, 130.0, 25.0)), + }; + + Block::new( + BlockKind::Leaves, + Rgb::::lerp(c0, c1, lerp).map(|e| e as u8), + ) } else { Block::new( BlockKind::Leaves, diff --git a/world/src/layer/scatter.rs b/world/src/layer/scatter.rs index ecb733e1f4..e59de70cc3 100644 --- a/world/src/layer/scatter.rs +++ b/world/src/layer/scatter.rs @@ -286,26 +286,23 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng, calendar: Optio kind: Pumpkin, water_mode: Ground, permit: |b| matches!(b, BlockKind::Grass), - f: if calendar.map_or(false, |calendar| calendar.is_event(CalendarEvent::Halloween)) { - |_, _| { - ( - 0.1, - Some((0.0003, 128.0, 0.1)), - ) - } - } else { - |_, col| { - ( - close(col.temp, CONFIG.temperate_temp, 0.5).min(close( - col.humidity, - CONFIG.forest_hum, - 0.5, - )) * MUSH_FACT - * 500.0, - Some((0.0, 512.0, 0.05)), - ) - } - }, + f: if calendar.map_or(false, |calendar| { + calendar.is_event(CalendarEvent::Halloween) + }) { + |_, _| (0.1, Some((0.0003, 128.0, 0.1))) + } else { + |_, col| { + ( + close(col.temp, CONFIG.temperate_temp, 0.5).min(close( + col.humidity, + CONFIG.forest_hum, + 0.5, + )) * MUSH_FACT + * 500.0, + Some((0.0, 512.0, 0.05)), + ) + } + }, }, // Collectable Objects // Only spawn twigs in temperate forests