mojira.dev
MC-204127

Farmland cannot be turned into dirt paths with a shovel

Relates to MC-8231 and MC-213770.

The bug

Many more dirt-like blocks gained the ability to be made into paths in the latest snapshot, however farmland was not one of them, which may be an oversight.

One potential way to fix this could be to have all blocks that can be directly converted to farmland or dirt paths use a block tag, such that eligible blocks could simply be added to this tag.

Steps to Reproduce

  • Build the setup as shown in the attachment below. setup.png

  • Obtain a shovel and attempt to convert all six different blocks into dirt paths.

  • Take note of the blocks that did convert into dirt paths and the blocks that didn't.

Observed Behavior

Farmland cannot be converted into dirt paths with shovels.

Expected Behavior

Farmland would be able to be converted into dirt paths with shovels.

Code Analysis

Code provided by @unknown in this comment

Linked issues

Attachments

Comments 28

Can confirm, however dirt path ("grass path" was renamed to "dirt path" in 20w45a) can be turned into farmland.

jump on it. once.

Well, farmland and path blocks are on the same level preety much. So it would not make sense to be able to change between them. For the farm to path: Jump on it so it becomes dirt, for the path to farm: Break, replace the block and then shovel it. This is not a bug.

If it's not a bug then explain why it has an assignee and priority.

@Connor Steppie So that it still gets looked into, and a decision can be taken? Not every assigned ticket ends up being a bug. The resolution afterwards could very well be "WAI". Or the "request" for this to be a feature gets honored. But in itself, this is not a bug. Just a slight annoyance, but rationally it currently makes sence, any change may increase playability, but decrease logic... 

18 more comments

I can confirm this behavior in 1.18.1.

Here's a code analysis along with a potential fix regarding this issue. The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn. 🙂

Code Analysis:

net.minecraft.world.item.ShovelItem.java

public class ShovelItem extends DiggerItem {
   protected static final Map<Block, BlockState> FLATTENABLES = Maps.newHashMap((new Builder()).put(Blocks.GRASS_BLOCK, Blocks.DIRT_PATH.defaultBlockState()).put(Blocks.DIRT, Blocks.DIRT_PATH.defaultBlockState()).put(Blocks.PODZOL, Blocks.DIRT_PATH.defaultBlockState()).put(Blocks.COARSE_DIRT, Blocks.DIRT_PATH.defaultBlockState()).put(Blocks.MYCELIUM, Blocks.DIRT_PATH.defaultBlockState()).put(Blocks.ROOTED_DIRT, Blocks.DIRT_PATH.defaultBlockState()).build());
   ...

If we look at the above class, we can see that only grass blocks, dirt, podzol, coarse dirt, mycelium, and rooted dirt can be converted into dirt paths using shovels. Farmland isn't included within this particular piece of code, resulting in this problem occurring.

Potential Fix:

Simply adding .put(Blocks.FARMLAND, Blocks.DIRT_PATH.defaultBlockState()) where appropriate within this piece of code should resolve this problem and allow you to convert farmland into dirt paths using shovels. The correct line of code within its class should look something like the following:

net.minecraft.world.item.ShovelItem.java

public class ShovelItem extends DiggerItem {
   protected static final Map<Block, BlockState> FLATTENABLES = Maps.newHashMap((new Builder()).put(Blocks.GRASS_BLOCK, Blocks.DIRT_PATH.defaultBlockState()).put(Blocks.FARMLAND, Blocks.DIRT_PATH.defaultBlockState()).put(Blocks.DIRT, Blocks.DIRT_PATH.defaultBlockState()).put(Blocks.PODZOL, Blocks.DIRT_PATH.defaultBlockState()).put(Blocks.COARSE_DIRT, Blocks.DIRT_PATH.defaultBlockState()).put(Blocks.MYCELIUM, Blocks.DIRT_PATH.defaultBlockState()).put(Blocks.ROOTED_DIRT, Blocks.DIRT_PATH.defaultBlockState()).build());
   ...

Can confirm in 1.18.2.

Can confirm in 1.19.

Can confirm in 1.19.2.

muzikbike

(Unassigned)

1262037

Confirmed

Gameplay

Normal

Block states, Items

block-tag-recommended, farmland, shovel

20w45a, 20w46a, 20w48a, 20w49a, 20w51a, ..., 23w14a, 1.20.1, 1.20.4, 1.21, 1.21.3

Retrieved