#gather information of a block
12 messages · Page 1 of 1 (latest)
Once your question has been answered, please close this post with </resolve:1050379261372006400> command!
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)
i just want to influence the speed of mining the block
Okay, there should be a forge event for modifying that mining speed.
I’ll post an example below this
[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);
}
}
@warped dew Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!