mojira.dev
MC-103899

Coarse dirt and grass block can't be tilled under torches, buttons, levers, or other non-full blocks

The bug

Coarse dirt and grass block can't be tilled if buttons, torches, and other non-full blocks are placed above it. Even if these non-full blocks are placed on the sides of blocks above the dirt.

Expected Result

You would be able to till coarse dirt and grass blocks when non-full blocks are placed above them.

Code analysis

Code analysis by @unknown provided in this comment.

Linked issues

Attachments

Comments 9

marcono1234

I misunderstood MC-3914 and thought the bug was that you could not till grass, but the bug was instead that you could till dirt. This report is probably invalid / Works as intended then.

Irbis

20w06a affected

Avoma

I can confirm this behavior in 1.18.

Here's a code analysis of this issue. The following is based on a decompiled version of Minecraft 1.18 using MCP-Reborn. Please note that I'm quite tentative about this analysis, although I'm persuaded to believe that this is likely the cause of the problem. 🙂

Code Analysis (tentative):

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

This basically means that if any block other than air is present above a tillable block, it cannot be tilled.

Avoma

Can confirm in 1.18.1.

Avoma

Can confirm in 1.18.2.

Cenecal

Can confirm in 1.19pre-3

Avoma

Can confirm in 1.19 and 22w24a.

Avoma

Can confirm in 1.19.2.

himazinn_Japan

Can confirm in 1.21.4.

Samson Gainor

(Unassigned)

Confirmed

Gameplay

Normal

Block states

Minecraft 1.10, Minecraft 1.10.2, Minecraft 16w42a, Minecraft 16w43a, Minecraft 1.11, ..., 1.19.4, 1.20.1, 1.20.3 Release Candidate 1, 1.21, 1.21.5

Retrieved