#anyone know how to detect when a block is stepped on?

1 messages · Page 1 of 1 (latest)

lone hill
#

with script api

sand phoenix
# lone hill with script api
import { world, Vector } from "@minecraft/server"

for (const player of world.getAllPlayers()) {
    const dimension = world.getDimension("minecraft:overworld");
    let location = new Vector(player.location.x, player.location.y - 1, player.location.z)
    const block = dimension.getBlock(location);
    console.log(`Player stepped on block: ${block}`);
}
lone hill
sand phoenix
# lone hill how to detect a specific block like slime and apply kb?
import { world, Vector } from "@minecraft/server"

for (const player of world.getAllPlayers()) {
    const dimension = world.getDimension("minecraft:overworld");
    let location = new Vector(player.location.x, player.location.y - 1, player.location.z)
    const block = dimension.getBlock(location);
   if (block.typeId == 'minecraft:slime_block'){
    player.applyKnockback(player.location.x,player.location.z, 1, 1)
   }
}
stoic rockBOT
#
No Errors

No errors in [code](#1107456796924321843 message)

sand phoenix
#

does it throw any errors in minecraft

lone hill
sand phoenix
#

try increasing the strength of the knockback