Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.17.1]How to set a block's harvest level limit?


QWERTY 52 38
 Share

Recommended Posts

Code of the block:

public class BlockMcbbsWiki extends Block {
    public BlockMcbbsWiki(){
        super((Properties.of(Material.STONE)
                .strength(2.5F, 10.0F)
                .requiresCorrectToolForDrops()));
    }
}

and the loot table (in src/main/resources/data/mcbbswiki/loot_tables/blocks):

{
  "type": "minecraft:block",
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "minecraft:item",
          "name": "mcbbswiki:block_mcbbswiki"
        }
      ]
    }
  ]
}

I want to make BlockMcbbsWiki drops itself if I use pickaxes leveled at least level 3(diamond), or nothing if the tool is not right. 

But now, it drops nothing with any tools. And there isn't a method that can set a harvest level limit in Blocks class.

Please help me.

 

Mod code: https://github.com/QWERTY770/MCBBS-Wiki-Mod

Link to comment
Share on other sites

30 minutes ago, uSkizzik said:

Harvest Level & Harvest Tool were moved to Tags because of vanilla.
They're now requires<Tier>Tool (eg requiresIronTool) and mineable/<Tool> (It's a directory, eg mineable/pickaxe).

Thanks!

 

By the way, could you tell me what's wrong with this custom advancement JSON?

{
  "display": {
    "icon": {
      "item": "mcbbswiki:item_mcbbswiki_chestplate_level1"
    },
    "title": {
      "translate": "advancements.mcbbswiki.armor_level1.title"
    },
    "description": {
      "translate": "advancements.mcbbswiki.armor_level1.description"
    },
    "frame": "goal"
  },
  "parent": "mcbbswiki:ingot",
  "criteria": {
    "armor_level1_1": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "item": "mcbbswiki:item_mcbbswiki_helmet_level1"
          }
        ]
      }
    },
    "armor_level1_2": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "item": "mcbbswiki:item_mcbbswiki_chestplate_level1"
          }
        ]
      }
    },
    "armor_level1_3": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "item": "mcbbswiki:item_mcbbswiki_leggings_level1"
          }
        ]
      }
    },
    "armor_level1_4": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "item": "mcbbswiki:item_mcbbswiki_boots_level1"
          }
        ]
      }
    }
  },
  "requirements": [
    ["armor_level1_1"],
    ["armor_level1_2"],
    ["armor_level1_3"],
    ["armor_level1_4"]
  ],
  "rewards": {
    "loot": [
      "mcbbswiki:advancements/tools_level1"
    ],
    "experience": 100
  }
}

I expect the advancement could be made if I get all the four armors

But actually, when I get any items, I will make the advancement.

That's too strange. Could you help me?

Link to comment
Share on other sites

15 minutes ago, QWERTY 52 38 said:

Thanks!

 

By the way, could you tell me what's wrong with this custom advancement JSON?

{
  "display": {
    "icon": {
      "item": "mcbbswiki:item_mcbbswiki_chestplate_level1"
    },
    "title": {
      "translate": "advancements.mcbbswiki.armor_level1.title"
    },
    "description": {
      "translate": "advancements.mcbbswiki.armor_level1.description"
    },
    "frame": "goal"
  },
  "parent": "mcbbswiki:ingot",
  "criteria": {
    "armor_level1_1": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "item": "mcbbswiki:item_mcbbswiki_helmet_level1"
          }
        ]
      }
    },
    "armor_level1_2": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "item": "mcbbswiki:item_mcbbswiki_chestplate_level1"
          }
        ]
      }
    },
    "armor_level1_3": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "item": "mcbbswiki:item_mcbbswiki_leggings_level1"
          }
        ]
      }
    },
    "armor_level1_4": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "item": "mcbbswiki:item_mcbbswiki_boots_level1"
          }
        ]
      }
    }
  },
  "requirements": [
    ["armor_level1_1"],
    ["armor_level1_2"],
    ["armor_level1_3"],
    ["armor_level1_4"]
  ],
  "rewards": {
    "loot": [
      "mcbbswiki:advancements/tools_level1"
    ],
    "experience": 100
  }
}

I expect the advancement could be made if I get all the four armors

But actually, when I get any items, I will make the advancement.

That's too strange. Could you help me?

Never dealt with advancements before.
Also, I recommend using data gen.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.