#Changing blocks' mining level

18 messages · Page 1 of 1 (latest)

near kernel
#

Basically, I want to change the mining level of #minecraft:logs to at minimum, stone. I do not want the block to be punchable, it should require stone and above

blissful violetBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

near kernel
#
//priority 97
ServerEvents.tags('block', event => {
    //Adding tags
    event.add('minecraft:needs_stone_tool','#minecraft:logs')


})
#

That's all I have so far, but doesn't make it so the player can't just mine it with their hands

#

It justs makes the example mining tool stone

#

But doesn't change anything

forest grove
fading charm
#

Do you want them to be unbreakable or just drop nothing?

near kernel
#

WHEN NOT USING STONE TOOLS, I'd like it to be unbreakable

near kernel
# forest grove I believe this is the correct class https://github.com/alcatrazEscapee/no-tree-p...

I was searching through it but I have no idea how to make something like this:

public final class HarvestBlockHandler
{
    public static void setup()
    {
        for (Block block : BuiltInRegistries.BLOCK)
        {
            final AbstractBlockAccessor blockAccess = (AbstractBlockAccessor) block;
            final BlockBehaviour.Properties settings = blockAccess.getProperties();

            // Forcefully set everything to require a tool
            // Need to do both the block settings and the block state since the value is copied there for every state
            settings.requiresCorrectToolForDrops();
            for (BlockState state : block.getStateDefinition().getPossibleStates())
            {
                ((AbstractBlockStateAccessor) state).setRequiresCorrectToolForDrops(true);
            }
        }
    }

But for kubejs

fading charm
#
ForgeEvents.onEvent('net.minecraftforge.event.entity.player.PlayerEvent$BreakSpeed', event => {
    global.harvestChecker(event)
})

global.harvestChecker = (/** @type {Internal.PlayerEvent$BreakSpeed} */ event) => {
    const { entity, state } = event
    if (!state.tags.anyMatch(tag => tag.location() == 'minecraft:logs')) return
    if (!entity.mainHandItem.hasTag('minecraft:axes')) event.setNewSpeed(0)
}

StartupScripts

#

you just need to add a new tag to all the axes above stone level

#

and change the tag in the script

near kernel
#

Wdym by new tag? Like ANY new tag or something specific that I have to set in the code you sent

near kernel
#

I got it working

#

@fading charm Dude thank you so much
You've helped me a lot with my KubeJS issues and I really appreciate it🥲

near kernel