#anyone know how to detect when a block is stepped on?
1 messages · Page 1 of 1 (latest)
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}`);
}
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)
}
}
No Errors
No errors in [code](#1107456796924321843 message)
still doesn't work
does it throw any errors in minecraft
nope
try increasing the strength of the knockback