In my current script I'm trying to detect the type.id of the block located at the newLocation variable coordinates. How would I go about checking? I know using detectable.includes() is required, but what do I need to add to the parameters of it to detect the block at the newLocation coordinates?
Here's my script so far:
``import { world, system, Block } from "@minecraft/server";
world.afterEvents.entityHitBlock.subscribe(e => {
const player = e.damagingEntity;
const block = e.hitBlock;
const bFace = e.blockFace;
const bLocation = block.location;
const startX = bLocation.x;
const startY = bLocation.y;
const startZ = bLocation.z;
const detectable = [
"minecraft:diamond_ore"
];
function checkBlocks() {
if (detectable.includes(block.type.id)) {
console.log(`${block.type.id} detected`);
return;
}
for (let i = 1; i <= 20; i++) {
let newLocation;
switch (bFace) {
case "North":
newLocation = { x: startX, y: startY, z: startZ - i };
break;
case "East":
newLocation = { x: startX - i, y: startY, z: startZ };
break;
case "South":
newLocation = { x: startX, y: startY, z: startZ + i };
break;
case "West":
newLocation = { x: startX + i, y: startY, z: startZ };
break;
case "Up":
newLocation = { x: startX, y: startY - i, z: startZ };
break;
case "Down":
newLocation = { x: startX, y: startY + i, z: startZ };
break;
default: break;
}
}
}
})``