Mined ice melts into water unless the tool has silk touch

This commit is contained in:
Kacpherek
2026-10-26 19:08:19 +01:00
parent 6af65a142b
commit 872409ea57
3 changed files with 51 additions and 0 deletions
+14
View File
@@ -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()?;
+23
View File
@@ -433,6 +433,29 @@ impl<L: LevelAccess + ?Sized> 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;
+14
View File
@@ -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<L: LevelAccess + ?Sized>(
&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<L: LevelAccess + ?Sized>(