BlockEvents.modification(event => {
	//Infestation
	event.modify('minecraft:sculk', block => {
        block.setRandomTickCallback(tick => {
            const { level, block, random } = tick
            const pos = block.getPos()
            const Directions = Java.loadClass("net.minecraft.core.Direction");
            Directions.values().forEach(face => {
                const offsetPos = pos.relative(face);
                const adjacentBlockId = level.getBlock(offsetPos).id;
                const chanceOfGrowth = 0.005;

                const blockTypes = {
                        "kubejs:wallpaper1": "minecraft:sculk",
                        "kubejs:stripped_wallpaper1": "minecraft:sculk",
                        "kubejs:wallpaper2": "minecraft:sculk",
                        "kubejs:stripped_wallpaper2": "minecraft:sculk",
                        "kubejs:wallpaper3": "minecraft:sculk",
                        "kubejs:stripped_wallpaper3": "minecraft:sculk",
                        "kubejs:wallpaper4": "minecraft:sculk",
                        "kubejs:wallpaper5": "minecraft:sculk",
                        "kubejs:stripped_wallpaper5": "minecraft:sculk",
                        "kubejs:wallpaper6": "minecraft:sculk",
                        "kubejs:stripped_wallpaper6": "minecraft:sculk",
                        "kubejs:wallpaper7": "minecraft:sculk",
                        "kubejs:stripped_wallpaper7": "minecraft:sculk",
                        "kubejs:wallpaper8": "minecraft:sculk",
                        "kubejs:stripped_wallpaper8": "minecraft:sculk",
                        "kubejs:wallpaper_fake": "minecraft:cave_air",
                        "kubejs:wallpaper_white_fake": "minecraft:cave_air",
                        "kubejs:wallpaper_pink_fake": "minecraft:cave_air",
                        "kubejs:carpeted_drain_soggy": "minecraft:sculk",
                        "kubejs:carpeted_drain_dry": "minecraft:sculk",
                        "kubejs:carpet": "minecraft:sculk",
                        "kubejs:oil_carpet": "minecraft:sculk",
                        "kubejs:soggy_carpet": "minecraft:sculk",
                        "kubejs:carpet_fake": "minecraft:cave_air",
                        "kubejs:red_carpet": "minecraft:sculk",
                        "kubejs:soggy_red_carpet": "minecraft:sculk",
                        "kubejs:red_carpet_fake": "minecraft:cave_air",
                        "kubejs:green_carpet": "minecraft:sculk",
                        "kubejs:soggy_green_carpet": "minecraft:sculk",
                        "kubejs:green_carpet_fake": "minecraft:cave_air",
                        "kubejs:floor_tiles": "minecraft:sculk",
                        "kubejs:floor_tiles_full": "minecraft:sculk",
                        "kubejs:floor_tiles_infinite": "minecraft:sculk",
                        "kubejs:floor_tiles_red": "minecraft:sculk",
                        "kubejs:floor_tiles_red_full": "minecraft:sculk",
                        "kubejs:floor_tiles_green": "minecraft:sculk",
                        "kubejs:floor_tiles_green_full": "minecraft:sculk",
                        "kubejs:ceilling": "minecraft:sculk",
                        "kubejs:ceilling2": "minecraft:sculk",
                        "kubejs:ceilling_edge": "minecraft:sculk",
                        "kubejs:ceilling_lamp": "kubejs:ceilling_lamp_off",
                        "kubejs:ceilling_lamp2": "kubejs:ceilling_lamp_off",
                        "kubejs:wallpaper1_slab": "kubejs:sculk_slab",
                        "kubejs:wallpaper2_slab": "kubejs:sculk_slab",
                        "kubejs:wallpaper3_slab": "kubejs:sculk_slab",
                        "kubejs:wallpaper4_slab": "kubejs:sculk_slab",
                        "kubejs:wallpaper5_slab": "kubejs:sculk_slab",
                        "kubejs:wallpaper6_slab": "kubejs:sculk_slab",
                        "kubejs:wallpaper7_slab": "kubejs:sculk_slab",
                        "kubejs:wallpaper8_slab": "kubejs:sculk_slab",
                        "kubejs:carpet_slab": "kubejs:sculk_slab",
                        "kubejs:soggy_carpet_slab": "kubejs:sculk_slab",
                        "kubejs:red_carpet_slab": "kubejs:sculk_slab",
                        "kubejs:green_carpet_slab": "kubejs:sculk_slab",
                        "kubejs:ceilling_slab": "kubejs:sculk_slab",
                        "kubejs:carpet_grass": "kubejs:sculk_tendrils"
                    };
                const blockType = blockTypes[adjacentBlockId];
                if (blockType && random.nextFloat() < chanceOfGrowth) {
                    level.setBlock(offsetPos, Block.getBlock(blockType).defaultBlockState(), 3)
                }
            })
        })
    })
	
	//environment
	event.modify([
		'minecraft:sculk',
		'minecraft:spawner',
		'immersiveengineering:fluid_placer',
		'antiblocksrechiseled:bright_black',
		'antiblocksrechiseled:bright_cyan',
		'antiblocksrechiseled:bright_white',
		'antiblocksrechiseled:wool_white'
	], block => {
		block.explosionResistance = 10000.0
		block.destroySpeed = -1.0
	})
	
	event.modify([
		'antiblocksrechiseled:wool_white'
	], block => {
		block.hasCollision = false
	})

	event.modify([
		'supplementaries:book_pile',
		'supplementaries:book_pile_horizontal'
	], block => {
		block.destroySpeed = 0.0
	})

	event.modify([
		'supplementaries:timber_frame'
	], block => {
		block.destroySpeed = 1
	})

})

ItemEvents.modification(event => {
	event.modify([
		'dustrial_decor:cardboard_box',
		'dustrial_decor:folded_cardboard',
		'dustrial_decor:smooth_cardboard',
		'dustrial_decor:cardboard_scrap'
	], item => {
		item.setBurnTime(1000)
	})
	event.modify(
		'dustrial_decor:smooth_cardboard_stairs'
	, item => {
		item.setBurnTime(800)
	})
	event.modify(
		'dustrial_decor:smooth_cardboard_slab'
	, item => {
		item.setBurnTime(500)
	})
	event.modify([
		'farmersdelight:flint_knife',
		'dustrial_decor:cardboard'
	], item => {
		item.setBurnTime(200)
	})
	event.modify(
		'storage_shelves:large_cardboard_box'
	, item => {
		item.setBurnTime(6000) //unable to be modified 
	})
	event.modify(
		'storage_shelves:cardboard_box'
	, item => {
		item.setBurnTime(2400) //unable to be modified 
	})

})

ForgeEvents.onEvent("net.minecraftforge.event.entity.player.PlayerEvent$BreakSpeed", event => global.breakSpeed(event))
/**
 * 
 * @param {Internal.PlayerEvent$BreakSpeed} event 
 */
global.breakSpeed = event => {
    try {
        if (event.entity.level.getBlock(event.getPosition().get()).hasTag('kubejs:unbreakable'))
            event.setNewSpeed(0)
    } catch (error) {
        console.log(error)
    }
}