Class MiningLevelManager
java.lang.Object
net.fabricmc.fabric.api.mininglevel.v1.MiningLevelManager
Provides access to block mining levels.
Mining level tags
MiningLevelManager
supports the vanilla minimum mining level tags:
#needs_stone_tool
,
#needs_iron_tool
and
#needs_diamond_tool
.
In addition to them, you can use dynamic mining level tags for any mining level (such as wood, netherite
or a custom one). The dynamic tags are checked automatically.
Dynamic mining level tags are in the format #fabric:needs_tool_level_N
, where N
is the wanted tool level as an integer. For example, a mining level tag for netherite (mining level 4) would be
#fabric:needs_tool_level_4
.
-
Method Summary
Modifier and TypeMethodDescriptiongetBlockTag
(int miningLevel) Gets the mining level block tag corresponding to a given integer mining level.static int
getRequiredMiningLevel
(BlockState state) Gets the tool mining level required to effectively mine and drop a block state.
-
Method Details
-
getRequiredMiningLevel
Gets the tool mining level required to effectively mine and drop a block state.Note: this method does not take into account tool-specific mining levels declared with the tool attribute API.
The default mining level of blocks not modified with mining level tags is -1 (the hand mining level).
- Parameters:
state
- the block state- Returns:
- the mining level of the block state
-
getBlockTag
Gets the mining level block tag corresponding to a given integer mining level. More precisely, return the corresponding vanilla tag (#minecraft:needs_x_tool
) for levels 1 to 3, and the Fabric tag (#fabric:needs_tool_level_N
) for levels above 3.- Parameters:
miningLevel
- the integer mining level- Returns:
- the corresponding mining level block tag
- Throws:
IllegalArgumentException
- if a negative or zero mining level is passed
-