// priority: 0

settings.logAddedRecipes = true
settings.logRemovedRecipes = true
settings.logSkippedRecipes = false
settings.logErroringRecipes = true

console.info('KubeJS server script loaded for Geecraft')

const removeItemRecipes = [
	// Stop anyone editing trains
	'mtr:dashboard',
	
	// Bugged items
	'mtr:ceiling',
	'mtr:ceiling_light',
	'mtr:ceiling_no_light'
]

onEvent('recipes', event => {
	for(let key of removeItemRecipes) {
		event.remove({ output: key })
	}
	
	event.shaped('6x londonunderground:platform_tfl_1', [
		'SSS',
		'SSW',
		'YG '
	], {
		S: 'minecraft:stone_bricks',
		W: 'minecraft:white_dye',
		G: 'minecraft:gray_dye',
		Y: 'minecraft:yellow_dye'
	})

	event.shaped('8x londonunderground:platform_block', [
		'GSS',
		'SSS',
		'SSS'
	], {
		S: 'minecraft:stone_bricks',
		G: 'minecraft:gray_dye'
	})
	
	event.shapeless('londonunderground:platform_tfl_1', ['londonunderground:platform_tfl_gap'])
	event.shapeless('londonunderground:platform_tfl_gap', ['londonunderground:platform_tfl_1'])
	
	event.shaped('16x londonunderground:station_light', [
		'IGI',
		'IGI',
		'IGI'
	], {
		I: 'minecraft:iron_ingot',
		G: 'minecraft:glowstone_dust'
	})

	event.shaped('4x londonunderground:exit_sign', [
		'III',
		'IGI',
		' D '
	], {
		I: 'minecraft:iron_ingot',
		G: 'minecraft:glowstone_dust',
		D: 'minecraft:green_dye'
	})

	event.shaped('londonunderground:sounds/see_it_say_it_sorted', [
		'SSS',
		'SNS',
		'SSS'
	], {
		S: 'minecraft:stone',
		N: 'minecraft:note_block'
	})

	event.shapeless('londonunderground:sounds/tube_station_ambience1', ['londonunderground:sounds/see_it_say_it_sorted'])
	event.shapeless('londonunderground:sounds/outside_ambience', ['londonunderground:sounds/tube_station_ambience1'])
	event.shapeless('londonunderground:sounds/see_it_say_it_sorted', ['londonunderground:sounds/outside_ambience'])

	event.shaped('londonunderground:morden_sign', [
		'RPB',
		'PTP',
		' S '
	], {
		P: '#minecraft:planks',
		T: '#minecraft:signs',
		S: 'minecraft:stick',
		R: 'minecraft:red_dye',
		B: 'minecraft:blue_dye'
	})

	event.shaped('londonunderground:block_roundel_1', [
		'RPB',
		'PTP',
		' P '
	], {
		P: '#minecraft:planks',
		T: '#minecraft:signs',
		R: 'minecraft:red_dye',
		B: 'minecraft:blue_dye'
	})

	event.shaped('16x londonunderground:track_1', [
		'   ',
		'IBI',
		'III'
	], {
		I: 'minecraft:iron_ingot',
		B: 'minecraft:black_dye'
	})

	event.shapeless('londonunderground:track_2', ['londonunderground:track_1'])
	event.shapeless('londonunderground:track_1', ['londonunderground:track_2'])
	
	event.custom({
	    type: 'techreborn:grinder',
		power: 4,
	    time: 270,
	    ingredients: [
	        Ingredient.of('geodes:quartz_geode').toJson()
	    ],
	    results: [
	        Item.of('techreborn:quartz_dust', 2).toResultJson()
	    ]
    })
})

onEvent('block.break', event => {
	if (!event.getPlayer().isCreativeMode()) {
		if (/londonunderground:.*/.test(event.getBlock().getId())) {
			event.getPlayer().give(event.getBlock().getItem())
		}
	}
})