how can i make it so it only check when the play is on the block, cause it still launches me even when im above the block and i press space bar
import { world, system } from "@minecraft/server";
// Run every tick
system.runInterval(() => {
for (const player of world.getPlayers()) {
const dim = player.dimension;
const loc = player.location;
const view = player.getViewDirection();
// Block directly under player
const block = dim.getBlockBelow(player.location);
if (block?.typeId === "minecraft:resin_bricks" && player.inputInfo.getButtonState("Jump") === "Pressed") {
// Apply knockback in the direction they're facing
player.applyKnockback({ x: view.x * 0, y: 3, z: view.z * 0 }, 1);
player.playSound("jump", { volume: 1 })
}
}
}, 1); // check every tick