KubeJS (Old)

KubeJS (Old)

3M Downloads

Request for Functionality to Retrieve Block Hardness and Blast Resistance

cleep5564 opened this issue ยท 1 comments

commented

Describe the feature

It would be incredibly useful to have a function or method that allows developers to easily retrieve these properties. This would enable us to create more dynamic and interactive gameplay experiences with our custom scripts.

Example Usage:

const hardness = getBlockHardness('minecraft:netherite_block');
const blastResistance = getBlockBlastResistance('minecraft:netherite_block');

// Then sending this information to the chat:
player.sendMessage(The hardness of Netherite Block is ${hardness} and the blast resistance is ${blastResistance}.);
I believe adding such functionality would greatly enhance the capabilities of KubeJS and make it easier for developers to implement features that rely on block properties.

Thank you for your consideration and all the hard work you put into maintaining KubeJS!

Additional info

I am currently working on developing a plugin using KubeJS for my Minecraft server, and I have encountered an issue where I need to retrieve the hardness and blast resistance of blocks programmatically.As far as I can tell from the documentation, there is no direct method provided by KubeJS to access these properties.

commented

Given a net.minecraft.world.level.block.Block instance, call:

block.defaultDestroyTime()
block.getExplosionResistance()

to get a block's destroy time and explosion resistance.

You can get a Block instance from a BlockContainerJS or a BlockState: container.blockState.block.