#Events triggered when an entity steps on a block

18 messages · Page 1 of 1 (latest)

main void
#

I am trying to realize a feature:

When an entity steps on a custom block I registered, some effects get triggered. I use event.steppedOn() of StartupEvents.registry('block', event => { ... } to realize it, here are my codes

StartupEvents.registry('block', event => {

    event
        .create('eternal_hunt_trap')
        .hardness(0)
        .fullBlock(false)
        .renderType('cutout')
        .texture('down', 'kubejs:block/eternal_hunt_trap')
        .box(0, 0, 0, 16, 1, 16)
        // .noCollision()
        .notSolid()
        .noDrops()
        .noValidSpawns(true)
        .redstoneConductor(false)
        .transparent(true)
        .steppedOn(
            /**
             * 
             * @param {$Level_} level 
             * @param {$Entity_} entity 
             * @param {$BlockPos_} blockPos 
             * @param {$BlockState_} blockState 
             */
            (level, entity, blockPos, blockState) => {
                console.log(entity)
            }
        )
        .displayName('Trap')
        

})

But nothing happens when I step on the block. Can anyone help?

little sorrelBOT
#

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

stray bough
#

the .steppedOn() method only contains a callback. Probably something like this to get the entity:

.steppedOn(ctx => {
  ctx.entity
})
main void
#

Okay, I will try that

#

Okay, it works

#

Thank you

main void
#

I have another question

#

IIf the block isn't a full block, the stepped on event won't trigger

#

As shown in the code

#

Is it by design?

stray bough
#

where exactly is this stated?

main void
#

Where what stated?

#

The code segment I presented is located in kubejs/startup_scripts/

main void
#

startup.log

#

If the block is full block (I commented the .box(*) line) there is output in startup.log

#

But when I cancel the comment there is no log output