import { world, system } from "@minecraft/server";


world.afterEvents.playerBreakBlock.subscribe(event => {
	const { dimension, block, player } = event;
	const blockPosition = block.location;
	if (player.getGameMode() !== 'creative') {

	if (event.brokenBlockPermutation.type.id == "ecbl_bc:baobab_double_slab") {
		dimension.runCommand(`kill @e[type=item,x=${blockPosition.x},y=${blockPosition.y},z=${blockPosition.z}]`)
		dimension.runCommand(`setblock ${blockPosition.x} ${blockPosition.y} ${blockPosition.z} air`)
		dimension.runCommand(`structure load "ecbl_bc/b_slab" ${blockPosition.x} ${blockPosition.y} ${blockPosition.z}`)
	}
	}
})

world.afterEvents.playerBreakBlock.subscribe(event => {
	const { dimension, block, player } = event;
	const blockPosition = block.location;
	if (player.getGameMode() !== 'creative') {

	if (event.brokenBlockPermutation.type.id == "ecbl_bc:kapok_double_slab") {
		dimension.runCommand(`kill @e[type=item,x=${blockPosition.x},y=${blockPosition.y},z=${blockPosition.z}]`)
		dimension.runCommand(`setblock ${blockPosition.x} ${blockPosition.y} ${blockPosition.z} air`)
		dimension.runCommand(`structure load "ecbl_bc/k_slab" ${blockPosition.x} ${blockPosition.y} ${blockPosition.z}`)
	}
	}
})

world.afterEvents.playerBreakBlock.subscribe(event => {
	const { dimension, block, player } = event;
	const blockPosition = block.location;
	if (player.getGameMode() !== 'creative') {

	if (event.brokenBlockPermutation.type.id == "ecbl_bc:redwood_double_slab") {
		dimension.runCommand(`kill @e[type=item,x=${blockPosition.x},y=${blockPosition.y},z=${blockPosition.z}]`)
		dimension.runCommand(`setblock ${blockPosition.x} ${blockPosition.y} ${blockPosition.z} air`)
		dimension.runCommand(`structure load "ecbl_bc/r_slab" ${blockPosition.x} ${blockPosition.y} ${blockPosition.z}`)
	}
	}
})