The Bug:
Ice with non-solid blocks below them doesn't create water when mined by players.
Steps to Reproduce:
Place down some ice and ensure that there's air below it.
Break the ice.
Take note as to whether or not ice with non-solid blocks below them doesn't create water when mined by players.
Observed Behavior:
No water is created.
Expected Behavior:
Water would be created.
Code Analysis:
Code analysis by @unknown can be found below. An additional code analysis by @unknown can be found in this comment.
The following is based on a decompiled version of Minecraft 1.19.2 using MCP-Reborn.
net.minecraft.world.level.block.IceBlock.java
public class IceBlock extends HalfTransparentBlock {
...
public void playerDestroy(Level level, Player player, BlockPos blockPos, BlockState blockState, @Nullable BlockEntity blockEntity, ItemStack itemStack) {
super.playerDestroy(level, player, blockPos, blockState, blockEntity, itemStack);
if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, itemStack) == 0) {
if (level.dimensionType().ultraWarm()) {
level.removeBlock(blockPos, false);
return;
}
Material material = level.getBlockState(blockPos.below()).getMaterial();
if (material.blocksMotion() || material.isLiquid()) {
level.setBlockAndUpdate(blockPos, Blocks.WATER.defaultBlockState());
}
}
}
...
If we look at the above class, we can see that there are two checks that are carried out before allowing ice blocks to be converted into water upon being mined by players. One of these checks is to make sure that the player isn't holding an item enchanted with silk touch at the time of the interaction, and the other is to check if the material below the ice block blocks motion or is a liquid. Because of the material check that's in place here, when ice with non-solid blocks below them is mined by players, it doesn't create water, therefore resulting in this problem occurring.
Fix:
Simply removing the material check within this piece of code before allowing ice blocks to be converted into water upon being mined by players will resolve this problem.
Current Code:
...
Material material = level.getBlockState(blockPos.below()).getMaterial();
if (material.blocksMotion() || material.isLiquid()) {
level.setBlockAndUpdate(blockPos, Blocks.WATER.defaultBlockState());
}
...
Fixed Code:
...
level.setBlockAndUpdate(blockPos, Blocks.WATER.defaultBlockState());
...
Linked issues
is duplicated by 5
relates to 2
Attachments
Comments 12
Is there anyone that still thinks that this is a bug, or is the community consensous that this is Intended?
Version 1.15.2
This still happens.
Yes i view it as a bug. Breaking ice without silk touch is supposed to cause a water block, not vanish.
Can confirm in 20w51a. I'd like to request ownership of this ticket since the reporter has been inactive since July 2014.
Using yarn mappings for 21w05b, at net.minecraft.block.IceBlock.afterBreak()
there seems to be a check specifically making sure the block beneath the ice is not air as seen in the last if statement here:
public void afterBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack stack) {
super.afterBreak(world, player, pos, state, blockEntity, stack);
if (EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, stack) == 0) {
if (world.getDimension().isUltrawarm()) {
world.removeBlock(pos, false);
return;
}
Material lv = world.getBlockState(pos.down()).getMaterial();
if (lv.blocksMovement() || lv.isLiquid()) {
world.setBlockState(pos, Blocks.WATER.getDefaultState());
}
}
}
I am pretty sure this is WAI
Relates to MC-206185
Following on from my code analysis, I've double-checked my proposed fix and I can confidently confirm that it's fully functioning and works as expected, so I've attached two screenshots to this report, one of which shows the current code and the other that shows the fixed code. I feel this information may be quite insightful hence my reasoning for providing it.
Please don't put down the affected version as a future version, as you DON'T have access to it yet!