#Want to make a certain group of blocks with a certain type of data unbreakable by hand

27 messages · Page 1 of 1 (latest)

hasty plover
#

These dynamic trees are bugging me. You can still chop down the trees by hand and collect the logs. So I just want to make so that dynamic tree logs with a radius of 4 and up just cannot be mined with your bare hands anymore.

livid turtleBOT
#

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

terse yew
#

You can't do this with block tags due to the fact width is stored as a property

#

*blockstate

#

You'd need to code a custom on mine event in KubeJS

#

When mining a dynamic tree

hasty plover
#

That's fine

#
    event.modify('#dynamictrees:branches', block => {
        block.requiresTool = true
    })    
})

ForgeEvents.onEvent('net.minecraftforge.event.entity.player.PlayerEvent$HarvestCheck', event => {
    global.HarvestCheck(event)
})

global.HarvestCheck = (event) => {
    if (!event.canHarvest()) {
        // can't harvest, let's check if we should override
        let blockState = event.getTargetBlock()
        let properties = blockState.getProperties()
        properties.forEach(property => {
            if (property.name == "radius") {
                let radius = property.getName(blockState.getValue(property))
                if (radius <= 3) {
                    // always breakable
                    event.setCanHarvest(true)
                }
            }
        })
    }
}```
terse yew
#

I'm on my phone so can't provide specifics, but you need to write the event that triggers when a specific block is mined, check the blockstate for the width, if it is over 4, check player mainhand

hasty plover
#

Hmm

#

What kind of event is it?

terse yew
#

Doing it in harvest check could work

hasty plover
#

A block modification event?

terse yew
#

I just saw your code after I hit send on that

terse yew
hasty plover
#

This is meant to make it mineable with axes

#

Although it takes a while, you can still chop the tree with your hands

terse yew
#

I have no idea how the intricacies of that method work

#

You'll have to wait for someone more knowledgeable for doing it that way

hasty plover
#

Someone else gave it me

scenic birchBOT
#

You can write your code in a codeblock by typing it between the codeblock delimiters:
Note that these are backticks, not apostrophes

```js :arrow_left:

ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})

``` :arrow_left:

This example will look like this:

ServerEvents.recipes(event => {
  event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
west cradle
#
function harvestCheck(e) {
    const properties = e.block.properties;
    return properties.find(p => {
        const radius = p.getName(e.block.getValue(p));
        if(!radius || radius <= 3) return true;
        else return false;
    })
}
BlockEvents.broken(e=> {
    if(!harvestCheck(e)) e.cancel()
})
hasty plover
#

So will this work only if you try to mine a log with a radius of 4 or higher by hand?

hasty plover
west cradle
#

server scripts

#

idk if it's working, i'm just porting the script you gave

hasty plover
#

well it doesn't appear to work