Mojira Archive
MC-221250

You cannot use hoes on blocks that are underwater

The Bug:

You cannot use hoes on blocks that are underwater.

Steps to Reproduce:

  1. Obtain a hoe and right-click on a dirt block that is underwater.
  2. Take note as to whether or not you can use hoes on blocks that are underwater.

Observed Behavior:

You cannot use hoes on blocks that are underwater.

Expected Behavior:

You would be able to use hoes on blocks that are underwater.

Code Analysis:

Code analysis by [Mod] Avoma can be found below.

The following is based on a decompiled version of Minecraft 1.18 using MCP-Reborn.

net.minecraft.world.item.HoeItem.java
public class HoeItem extends DiggerItem {
   protected static final Map<Block, Pair<Predicate<UseOnContext>, Consumer<UseOnContext>>> TILLABLES = Maps.newHashMap(ImmutableMap.of(Blocks.GRASS_BLOCK, Pair.of(HoeItem::onlyIfAirAbove, changeIntoState(Blocks.FARMLAND.defaultBlockState())), Blocks.DIRT_PATH, Pair.of(HoeItem::onlyIfAirAbove, changeIntoState(Blocks.FARMLAND.defaultBlockState())), Blocks.DIRT, Pair.of(HoeItem::onlyIfAirAbove, changeIntoState(Blocks.FARMLAND.defaultBlockState())), Blocks.COARSE_DIRT, Pair.of(HoeItem::onlyIfAirAbove, changeIntoState(Blocks.DIRT.defaultBlockState())), Blocks.ROOTED_DIRT, Pair.of(($$0) -> {
      return true;
   }, changeIntoStateAndDropItem(Blocks.DIRT.defaultBlockState(), Items.HANGING_ROOTS))));
   ...
   public static boolean onlyIfAirAbove(UseOnContext $$1) {
      return $$1.getClickedFace() != Direction.DOWN && $$1.getLevel().getBlockState($$1.getClickedPos().above()).isAir();
   }
}

If we look at the above class, we can see that you can only till blocks using hoes if air is above them. This is evident through the following line of code:

HoeItem::onlyIfAirAbove