From 081c8bed7785abdfbb10e8fdf4a887ecb3806b64 Mon Sep 17 00:00:00 2001 From: Knightress Paladin Date: Mon, 5 Jul 2021 19:13:11 -0700 Subject: [PATCH 1/3] Added check for exploding lava and glowing blocks --- server/src/events/entity_manipulation.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index a2e414a463..8a63701489 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -24,7 +24,7 @@ use common::{ outcome::Outcome, resources::Time, rtsim::RtSimEntity, - terrain::{Block, TerrainGrid}, + terrain::{Block, BlockKind, TerrainGrid}, uid::{Uid, UidAllocator}, util::Dir, vol::ReadVol, @@ -767,6 +767,9 @@ pub fn handle_explosion(server: &Server, pos: Vec3, explosion: Explosion, o let mut block_change = ecs.write_resource::(); for block_pos in touched_blocks { if let Ok(block) = terrain.get(block_pos) { + if matches!(block.kind(), BlockKind::Lava | BlockKind::GlowingRock) { + continue; + } let diff2 = block_pos.map(|b| b as f32).distance_squared(pos); let fade = (1.0 - diff2 / color_range.powi(2)).max(0.0); if let Some(mut color) = block.get_color() { From 5c5b8ed94e61e4159dbcb4bee8617e8e71369fb5 Mon Sep 17 00:00:00 2001 From: Knightress Paladin Date: Mon, 5 Jul 2021 19:13:11 -0700 Subject: [PATCH 2/3] Added check for exploding lava and glowing blocks --- server/src/events/entity_manipulation.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index a2e414a463..8a63701489 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -24,7 +24,7 @@ use common::{ outcome::Outcome, resources::Time, rtsim::RtSimEntity, - terrain::{Block, TerrainGrid}, + terrain::{Block, BlockKind, TerrainGrid}, uid::{Uid, UidAllocator}, util::Dir, vol::ReadVol, @@ -767,6 +767,9 @@ pub fn handle_explosion(server: &Server, pos: Vec3, explosion: Explosion, o let mut block_change = ecs.write_resource::(); for block_pos in touched_blocks { if let Ok(block) = terrain.get(block_pos) { + if matches!(block.kind(), BlockKind::Lava | BlockKind::GlowingRock) { + continue; + } let diff2 = block_pos.map(|b| b as f32).distance_squared(pos); let fade = (1.0 - diff2 / color_range.powi(2)).max(0.0); if let Some(mut color) = block.get_color() { From 2bcfa0df7a964cefd1697b49117f8806aec68e40 Mon Sep 17 00:00:00 2001 From: Knightress Paladin Date: Mon, 5 Jul 2021 19:30:45 -0700 Subject: [PATCH 3/3] Formatted code to omit continue keyword --- server/src/events/entity_manipulation.rs | 33 ++++++++++++------------ 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 8a63701489..2cb6fe3fe0 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -767,23 +767,22 @@ pub fn handle_explosion(server: &Server, pos: Vec3, explosion: Explosion, o let mut block_change = ecs.write_resource::(); for block_pos in touched_blocks { if let Ok(block) = terrain.get(block_pos) { - if matches!(block.kind(), BlockKind::Lava | BlockKind::GlowingRock) { - continue; - } - let diff2 = block_pos.map(|b| b as f32).distance_squared(pos); - let fade = (1.0 - diff2 / color_range.powi(2)).max(0.0); - if let Some(mut color) = block.get_color() { - let r = color[0] as f32 - + (fade * (color[0] as f32 * 0.5 - color[0] as f32)); - let g = color[1] as f32 - + (fade * (color[1] as f32 * 0.3 - color[1] as f32)); - let b = color[2] as f32 - + (fade * (color[2] as f32 * 0.3 - color[2] as f32)); - // Darken blocks, but not too much - color[0] = (r as u8).max(30); - color[1] = (g as u8).max(30); - color[2] = (b as u8).max(30); - block_change.set(block_pos, Block::new(block.kind(), color)); + if !matches!(block.kind(), BlockKind::Lava | BlockKind::GlowingRock) { + let diff2 = block_pos.map(|b| b as f32).distance_squared(pos); + let fade = (1.0 - diff2 / color_range.powi(2)).max(0.0); + if let Some(mut color) = block.get_color() { + let r = color[0] as f32 + + (fade * (color[0] as f32 * 0.5 - color[0] as f32)); + let g = color[1] as f32 + + (fade * (color[1] as f32 * 0.3 - color[1] as f32)); + let b = color[2] as f32 + + (fade * (color[2] as f32 * 0.3 - color[2] as f32)); + // Darken blocks, but not too much + color[0] = (r as u8).max(30); + color[1] = (g as u8).max(30); + color[2] = (b as u8).max(30); + block_change.set(block_pos, Block::new(block.kind(), color)); + } } } }