#checks if the player has an item equipped

7 messages · Page 1 of 1 (latest)

alpine pilot
#

How to make a script that checks if the player has an item equipped, and preferably compatibility with trinkets

lilac starBOT
#

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

fathom oak
stone yarrowBOT
#

[Quote ➤](#1049023014479593582 message) feel free to use lol
remember to replace the custom items with your own

onEvent('block.right_click', event => {
    if (event.block.id == "minecraft:bedrock" && event.hand == MAIN_HAND && event.item.id == 'kubejs:bedrock_slicer') {
        var bx = event.block.getX()
        var by = event.block.getY()
        var bz = event.block.getZ()

        const surroundingBlock = 'minecraft:iron_block'

        if (
            // this checks if surrounding blocks except the top block are equal to surroundingBlock defined earlier
            event.level.getBlock(bx, by, bz - 1) == surroundingBlock && 
            event.level.getBlock(bx, by, bz + 1) == surroundingBlock &&
            event.level.getBlock(bx, by - 1, bz) == surroundingBlock &&
            event.level.getBlock(bx - 1, by, bz) == surroundingBlock &&
            event.level.getBlock(bx + 1, by, bz) == surroundingBlock) 
            {
                // initialize creating item entity
                let itemEntity = event.level.createEntity("minecraft:item")

                itemEntity.setX(bx + 0.5)
                itemEntity.setY(by)
                itemEntity.setZ(bz + 0.5)
                itemEntity.item = Item.of("kubejs:bedrock_plate")
                itemEntity.spawn()

                event.block.set("minecraft:air")
        }
    }
})```
fathom oak
#

My bad, first link was wrong one.

alpine pilot
fathom oak
#

Curios slots a bit triky. You need initialize api.

const api = new CuriosApi();```
And then helper function
```let result = api.getCuriosHelper().getEquippedCurios(event.player)```
Which is
```LazyOptional<IItemHandlerModifiable> getEquippedCurios(LivingEntity livingEntity);```
But i don`t understand how to process that type.