I'm trying to destroy a group of blocks, and it works if I just enter them line by line manually to destroy them, but I'd like to understand why it doesn't work in an array.
My attempt at code:
`BlockEvents.broken(event => {
let brBlock = event.getBlock();
let brBlockD = brBlock.down;
const desBlocks = [BlockPos(brBlockD.x + 1, brBlockD.y, brBlockD.z),
BlockPos(brBlockD.x - 1, brBlockD.y, brBlockD.z),
BlockPos(brBlockD.x, brBlockD.y - 1, brBlockD.z),
BlockPos(brBlockD.x, brBlockD.y, brBlockD.z + 1),
BlockPos(brBlockD.x, brBlockD.y, brBlockD.z - 1)];
event.player.tell(`${desBlocks}`);
desBlocks.forEach((block, index) => {
event.level.destroyBlock(block, true);
});
}
});`
On the line with my array declaration, the KubeJS server log gives the error "TypeError: redeclaration of var desBlocks", but I've tried it with event.level.getBlock(brBlockD.x, brBlockD.y, brBlockD.z) for the array entries, and get the same issue.
Is it assuming desBlocks is something other than an array? I'm very lost. :/