#gather information of a block

12 messages · Page 1 of 1 (latest)

warped dew
#

Is there a way to find the .hardness() of any block? be it vanilla or modded?

feral spindleBOT
#

Once your question has been answered, please close this post with </resolve:1050379261372006400> command!

serene jackal
#

Hmm possibly it’s stored in the block’s material

#

Let me double check really quick

serene jackal
#

given any BlockContainerJS you can do the following:
block.blockState.block. explosionResistance

#

I believe hardness is referring to explosion resistance right?

#

If you’re referring to whether or not something can be mined, then that’s not handled via number anymore and instead is a tag

#

Alternatively another way of checking whether a block can be mined by a player that uses forge’s block state system:
event.block.blockState.canHarvestBlock(event.level, event.block.pos, event.player)

warped dew
serene jackal
dense fjordBOT
#

[Quote ➤](#archived-example-scripts message) Forge 1.18.2 Harvest Speed and Harvest Level scripts that works on modded blocks as well as vanilla. (So far only bedrock seems to be unaffected).

onForgeEvent('net.minecraftforge.event.entity.player.PlayerEvent$HarvestCheck', event => {
    global['harvestcheck'](event);
});
onForgeEvent('net.minecraftforge.event.entity.player.PlayerEvent$BreakSpeed', event => {
    global['harvestspeed'](event);
});
global['harvestcheck'] = (event) => {
    let player = event.player.asKJS();
    if(!event.targetBlock.is('minecraft:dirt')){
        event.setCanHarvest(true);
    }else{
        event.setCanHarvest(false);
    }
}
global['harvestspeed'] = (event) => {
    let player = event.player.asKJS();
    //console.log(event.getOriginalSpeed());
    //console.log(event.getNewSpeed());
    if(!event.state.is('minecraft:dirt')){
        event.setNewSpeed(100);
    }else{
        event.setNewSpeed(0);
    }
}
feral spindleBOT
#

@warped dew Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!