#Want to make a certain group of blocks with a certain type of data unbreakable by hand
27 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
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
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)
}
}
})
}
}```
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
Doing it in harvest check could work
A block modification event?
I just saw your code after I hit send on that
Uhh its been so long since I've done stuff like that
This is meant to make it mineable with axes
Although it takes a while, you can still chop the tree with your hands
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
Someone else gave it me
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)
})
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()
})
So will this work only if you try to mine a log with a radius of 4 or higher by hand?
Also where do i put this
well it doesn't appear to work