mojira.dev
MC-272651

"replace_block" enchantment effect doesn't work in certain circumstances

If you have an enchantment like the JSON file below, where the "replace block" effect is called after hitting a block, the changes made by this effect will be completely overridden by air if the block you hit can be broken instantly.

Steps to reproduce the issue

 

1. Download the provided datapack, or create an enchantment in a datapack under the "data/harvest/enchantment/till.json" path:

 
 

{
  "anvil_cost": 5,
  "description": {
    "translate": "enchantment.harvest.till"
  },
  "effects": {
    "minecraft:hit_block": [
      {
        "effect": {
          "type": "minecraft:replace_block",
          "block_state": {
            "type": "simple_state_provider",
            "state": {
              "Name": "minecraft:bedrock"
            }
          }
        }
      }
    ]
  },
  "max_cost": {
    "base": 65,
    "per_level_above_first": 9
  },
  "max_level": 3,
  "min_cost": {
    "base": 15,
    "per_level_above_first": 9
  },
  "primary_items": "#minecraft:hoes",
  "slots": [
    "mainhand"
  ],
  "supported_items": "#minecraft:hoes",
  "weight": 4
}

 

2. Give yourself a hoe and enchant it with the enchantment (harvest:till) using the /enchant command.

3. Try to hit any block that can be broken instantly, such as grass, crops, torches, etc.

Behavior

Current behavior: The block hit will break.

Expected behavior: The block hit will be replaced by bedrock.

Note:

Hitting any other block with the enchantment will replace it with bedrock, as expected.

 

Attachments

Comments 1

Please update the description to include steps to reproduce this issue, as well as expected VS observed results.

Please also attach any needed commands, datapacks, resourcepacks, screenshots, videos or worlds needed to help reproduce this issue.

Manchick

(Unassigned)

Confirmed

Platform

Normal

Data Packs, Enchantments

1.21 Pre-Release 1, 1.21 Pre-Release 4

Retrieved