I can't understand what's the problem here can anyone help me fix it this error came in latest version of minecraft it was not a problem before
import {
BlockTypes,
ItemStack,
ItemTypes,
world
} from '@minecraft/server';
await null;
function createRandomBlockMapping() {
const validBlockTypes = BlockTypes.getAll().filter(blockType =>
ItemTypes.get(blockType.id) !== undefined
);
const shuffledBlockTypes = validBlockTypes.slice().sort(() => Math.random() - 0.5);
const mapping = new Map();
for (let i = 0; i < validBlockTypes.length; i++) {
mapping.set(validBlockTypes[i].id, shuffledBlockTypes[i].id);
}
return mapping;
}
const randomizedBlockMap = createRandomBlockMapping();
world.afterEvents.playerBreakBlock.subscribe(event => {
const brokenBlockId = event.brokenBlockPermutation.type.id;
if (!randomizedBlockMap.has(brokenBlockId)) return;
const droppedItem = new ItemStack(randomizedBlockMap.get(brokenBlockId));
event.block.dimension.spawnItem(droppedItem, event.block.location);
});
it throws error
at <anonymous> (mrg.js:25)```