#how to do a right click event

10 messages · Page 1 of 1 (latest)

whole ruin
#

right click grass with shear to get custom grass seed and turn the right clicked grass to regular dirt

hidden thunderBOT
#

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

whole ruin
#

i am completely new to this, but ive been wanting to make a modpack, and i dont know if this is possible

#

and if it isnt too much, right click dirt with custom grass seed to turn it to a grass block

safe patio
#

maybe you can use this unstead

molten sorrel
# safe patio

That is an extremely over complicated example for what they wanted lol
This is also not what they need

molten sorrel
#
// Reference: https://hunter19823.github.io/kubejsoffline/1.20.1/forge/#?focus=global-bindings-BlockEvents.rightClicked%28BlockRightClickedEventJS%2C+net.minecraft.world.level.block.Block%29&global-bindings-expanded=true
BlockEvents.rightClicked((event) => {
    // Log some debug info.
    console.log(`${event.entity.profile.name} clicked on block with id ${event.block.id} with the item ${event.mainHandItem.id}.`);
    if (event.block.id != 'minecraft:grass_block') {
        // Check if the block is a grass block. If it is not, do not continue.
        return;
    }
    // Log some more debug info.
    console.log(`${event.mainHandItem.id} has the following tags:`, event.mainHandItem.tags);
    // Idk what the shears tag is
    if (!event.mainHandItem.id.hasTag('shears tag')) {
        // Check if the item being held is not shears. If it is not, then return.
        return;
    }
    // 'Pop' an item out of the block.
    event.block.popItem('minecraft:stick'); 
    // Set the block to dirt.
    event.block.set('minecraft:dirt');
    // if the block is not dameable, do not continue.
    if (!event.mainHandItem.isDamageableItem()) {
        return;
    }
    // if the player is in creative, do not continue.
    if (event.entity.isCreative()){
        return;
    }
    // Damage the shears.
    event.mainHandItem.damageValue--;
});