diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 8448f0837..20c8a282e 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -3510,6 +3510,20 @@ impl Game<'_> { ); } } + // IceBlock.playerDestroy: the ice melts back into water (the + // #prevents_ice_melting tool tag holds only silk touch). + let prevents_melting = held + .as_ref() + .is_some_and(|h| h.enchantment_level("minecraft:silk_touch") > 0); + self.with_level(|b, level, ticks| { + b.ice_destroyed_by_player( + level, + ticks, + BlockPos::new(pos[0], pos[1], pos[2]), + broken, + prevents_melting, + ); + }); } self.pending.clear(pos); self.process_level_events()?; diff --git a/crates/horizon-world/src/level/hooks.rs b/crates/horizon-world/src/level/hooks.rs index 7f9e8d19a..9b07b8d25 100644 --- a/crates/horizon-world/src/level/hooks.rs +++ b/crates/horizon-world/src/level/hooks.rs @@ -433,6 +433,29 @@ impl Sim<'_, L> { self.game_event(pos, "minecraft:block_destroy"); self.remove_block(pos, false) } + /// `IceBlock.playerDestroy` (after the drops): mined ice turns into water + /// when it sits over a solid block or a liquid, unless the tool prevents + /// ice melting (silk touch). In the nether, where water evaporates, the + /// block stays air. + pub(crate) fn ice_destroyed_by_player( + &mut self, + pos: BlockPos, + destroyed: BlockStateId, + prevents_melting: bool, + ) { + let b = self.b; + if !b.data(destroyed).is(Class::Ice) + || prevents_melting + || self.level.dimension() == super::Dimension::Nether + { + return; + } + let below = self.below_state(pos); + if b.in_set(below, &b.tags.blocks_motion) || b.liquid(below) { + let water = b.default_of(b.named.water); + self.set_block_and_update(pos, water); + } + } /// `entityInside` for entity-sensing blocks. pub(crate) fn entity_inside(&mut self, pos: BlockPos) { let b = self.b; diff --git a/crates/horizon-world/src/level/mod.rs b/crates/horizon-world/src/level/mod.rs index c81bdf369..757660ce4 100644 --- a/crates/horizon-world/src/level/mod.rs +++ b/crates/horizon-world/src/level/mod.rs @@ -646,6 +646,20 @@ impl Behaviours { ) -> bool { self.sim(level, ticks).player_destroy(pos, creative) } + /// `IceBlock.playerDestroy` after the drops: mined ice melts into water + /// unless the tool prevents ice melting (silk touch). `destroyed` is the + /// state that was broken. + pub fn ice_destroyed_by_player( + &self, + level: &mut L, + ticks: &mut Ticks, + pos: BlockPos, + destroyed: BlockStateId, + prevents_melting: bool, + ) { + self.sim(level, ticks) + .ice_destroyed_by_player(pos, destroyed, prevents_melting); + } /// `BaseFireBlock.getState(level, pos)`: soul fire on its base blocks, /// otherwise fire shaped by its neighbours. pub fn fire_state_for(