Mined ice melts into water unless the tool has silk touch
This commit is contained in:
@@ -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()?;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>(
|
||||
|
||||
Reference in New Issue
Block a user