Falling suspicious sand and gravel break where they land
BrushableBlock.tick makes the falling block entity with disableDrop, so vanilla breaks it on landing (onBrokenAfterFall: level event 2001 and the block_destroy game event) and places nothing. Horizon landed it as a plain block without its archaeology block entity. Seen in pre-generated worlds: suspicious gravel of cold ocean ruins that sits over water fell during the first ticks and landed one block lower without its block entity, so with no loot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,18 @@ impl Damage {
|
||||
..Self::default()
|
||||
}
|
||||
}
|
||||
/// A block that starts to fall: anvils hurt, and a brushable block
|
||||
/// breaks where it lands (BrushableBlock.tick: disableDrop).
|
||||
pub fn falling(block: &str) -> Self {
|
||||
if block.ends_with("anvil") {
|
||||
Self::anvil()
|
||||
} else {
|
||||
Self {
|
||||
cancel_drop: block.starts_with("minecraft:suspicious_"),
|
||||
..Self::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn from_nbt(tag: &Tag, anvil: bool) -> Self {
|
||||
Self {
|
||||
hurt_entities: number(tag.get("HurtEntities")).map_or(anvil, |v| v != 0),
|
||||
@@ -181,6 +193,14 @@ pub fn hurt_mobs(mobs: &mut [Mob], position: Vec3, amount: f32) {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn only_brushable_blocks_break_where_they_land() {
|
||||
assert!(Damage::falling("minecraft:suspicious_gravel").cancel_drop);
|
||||
assert!(Damage::falling("minecraft:suspicious_sand").cancel_drop);
|
||||
assert!(!Damage::falling("minecraft:gravel").cancel_drop);
|
||||
assert!(Damage::falling("minecraft:chipped_anvil").hurt_entities);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn impact_uses_ceil_distance_capped_damage_and_positive_damage_wear() {
|
||||
let damage = Damage::anvil();
|
||||
|
||||
@@ -2971,11 +2971,9 @@ impl Game<'_> {
|
||||
drop_item: true,
|
||||
fall_distance: 0.0,
|
||||
stuck: Vec3::ZERO,
|
||||
damage: if self.res.facts().get(state).name.ends_with("anvil") {
|
||||
horizon_client::falling_block::Damage::anvil()
|
||||
} else {
|
||||
Default::default()
|
||||
},
|
||||
damage: horizon_client::falling_block::Damage::falling(
|
||||
&self.res.facts().get(state).name,
|
||||
),
|
||||
saved: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,6 +64,25 @@ impl Game<'_> {
|
||||
pos: BlockPos::new(pos[0], pos[1], pos[2]),
|
||||
data: 0,
|
||||
});
|
||||
} else if self
|
||||
.res
|
||||
.facts()
|
||||
.get(block.state)
|
||||
.name
|
||||
.starts_with("minecraft:suspicious_")
|
||||
{
|
||||
// BrushableBlock.onBrokenAfterFall.
|
||||
let at = BlockPos::new(pos[0], pos[1], pos[2]);
|
||||
self.level_events.push(LevelEvent::LevelEvent {
|
||||
id: 2001,
|
||||
pos: at,
|
||||
data: block.state.0 as i32,
|
||||
});
|
||||
self.level_events.push(LevelEvent::GameEvent {
|
||||
pos: at,
|
||||
event: "minecraft:block_destroy",
|
||||
state: None,
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user