#How to detect blocks around player, run command at detected blocks

1 messages · Page 1 of 1 (latest)

plucky magnet
#

Ex:
Detect if there are diamond blocks within a 9×9×9 area of the player/entity and execute a function from the position of each of those detected blocks.

arctic thorn
# plucky magnet Ex: Detect if there are diamond blocks within a 9×9×9 area of the player/entity ...
mc.system.runInterval(() => {
    const size = 9;
    const offset = Math.ceil(size / 2);
    for (let plr of world.getAllPlayers()) {
        for ( let x = -offset; x < size - offset; x++) {
            for ( let y = -offset; y < size - offset; y++) {
                for ( let z = -offset; z < size - offset; z++) {
                    const block = plr.dimension.getBlock({ x: x + plr.location.x, y: y + plr.location.y, z: z + plr.location.z })
                    if ( block.type.id =='minecraft:diamond_block') {
                        
                    }
                }
            }
        }
    }
});
arctic thorn
#

Should be it's nothing special

arctic thorn
#

I changed it btw

plucky magnet
#

I understand