#Pasture Seed

3 messages · Page 1 of 1 (latest)

short mauve
#

Lets make some grass spread

    let { block, player } = event;
    let item = player.mainHandItem; // Get the item in the main hand

    // Ensure the block exists, is dirt, and the player is holding the item
    if (block && block.id === 'minecraft:dirt' && item && item.id === 'kubejs:pasture_seed') {
        // Directly change the block to grass
        block.set('minecraft:grass_block');

        // Play a soft, magical nature sound
        player.server.runCommandSilent(
            `execute as ${player.username} at @s run playsound minecraft:entity.allay.ambient_with_item master ${player.username}`
        );

        // Spawn a green sparkle effect
        player.server.runCommandSilent(
            `execute as ${player.username} at @s run particle minecraft:happy_villager ~ ~1 ~ 0.5 0.5 0.5 0.1 20`
        );

        // Consume one item (only in Survival Mode)
        if (!player.isCreative()) {
            item.count--;
        }
    }
});
haughty parcel
#

if (block is pointless, and the id check should be put in the event handler

coral condor
#

like```js
BlockEvents.leftClicked("minecraft:dirt", event => { });