import crafttweaker.api.ingredient.IIngredient;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.recipe.replacement.Replacer;

val blockInteractWhitelist = <tag:blocks:ftbchunks:interact_whitelist>;
val entityInteractWhitelist = <tag:entity_types:ftbchunks:entity_interact_whitelist>;

val blockWhitelist = [
	//<block:secretroomsmod:secret_door>,
	//<block:secretroomsmod:secret_trapdoor>,
	//<block:secretroomsmod:secret_wooden_button>,
	//<block:secretroomsmod:secret_stone_button>,
	//<block:secretroomsmod:torch_lever>,
	//<block:secretroomsmod:secret_pressure_plate>,
	//<block:secretroomsmod:secret_player_pressure_plate>,
	//<block:secretroomsmod:secret_chest>,
	//<block:secretroomsmod:secret_trapped_chest>,
	//<block:secretroomsmod:secret_gate>,
	//<block:rsgauges:industrial_lever>,
	//<block:rsgauges:industrial_small_lever>,
	//<block:rsgauges:industrial_rotary_lever>,
	//<block:rsgauges:industrial_rotary_machine_switch>,
	//<block:rsgauges:industrial_machine_switch>,
	//<block:rsgauges:industrial_estop_switch>,
	//<block:rsgauges:industrial_hopper_switch>,
	//<block:rsgauges:industrial_button>,
	//<block:rsgauges:industrial_fenced_button>,
	//<block:rsgauges:industrial_double_pole_button>,
	//<block:rsgauges:industrial_foot_button>,
	//<block:rsgauges:industrial_pull_handle>,
	//<block:rsgauges:industrial_dimmer>,
	//<block:rsgauges:industrial_door_contact_mat>,
	//<block:rsgauges:industrial_contact_mat>,
	//<block:rsgauges:industrial_shock_sensitive_contact_mat>,
	//<block:rsgauges:industrial_shock_sensitive_trapdoor>,
	//<block:rsgauges:industrial_high_sensitive_trapdoor>,
	//<block:rsgauges:industrial_comparator_switch>,
	//<block:rsgauges:rustic_lever>,
	//<block:rsgauges:rustic_two_hinge_lever>,
	//<block:rsgauges:rustic_angular_lever>,
	//<block:rsgauges:rustic_nail_lever>,
	//<block:rsgauges:rustic_button>,
	//<block:rsgauges:rustic_small_button>,
	//<block:rsgauges:rustic_spring_reset_chain>,
	//<block:rsgauges:rustic_nail_button>,
	//<block:rsgauges:glass_rotary_switch>,
	//<block:rsgauges:glass_touch_switch>,
	//<block:rsgauges:glass_button>,
	//<block:rsgauges:glass_small_button>,
	//<block:rsgauges:glass_touch_button>,
	//<block:rsgauges:oldfancy_bistableswitch1>,
	//<block:rsgauges:oldfancy_bistableswitch2>,
	//<block:rsgauges:oldfancy_button>,
	//<block:rsgauges:oldfancy_spring_reset_chain>,
	//<block:rsgauges:oldfancy_small_button>,
	//<block:rsgauges:light_switch>,
	//<block:rsgauges:valve_wheel_switch>,
	//<block:rsgauges:elevator_button>,
	//<block:securitycraft:keypad>,
	<block:minecraft:lever>,
	<block:supplementaries:sconce_lever>,
	//<block:lightmanscurrency:cash_register>,
	//<block:lightmanscurrency:terminal>,
	//<block:lightmanscurrency:gem_terminal>,
	<block:create:hand_crank>
];

val entityTypeWhitelist = [
	//<entitytype:iceandfire:fire_dragon>,
	//<entitytype:iceandfire:ice_dragon>,
	//<entitytype:iceandfire:lightning_dragon>,
	<entitytype:minecraft:horse>
];

val tagWhitelist = [
	<tag:blocks:lootr:containers>,
	//<tag:blocks:furnish:crimson_furniture>,
	//<tag:blocks:handcrafted:chairs>,
	//<tag:blocks:dramaticdoors:short_doors>,
	//<tag:blocks:dramaticdoors:tall_doors>,
	<tag:blocks:minecraft:trapdoors>,
	<tag:blocks:minecraft:doors>,
	<tag:blocks:minecraft:buttons>
];

blockInteractWhitelist.add(blockWhitelist);
entityInteractWhitelist.add(entityTypeWhitelist);
for tag in tagWhitelist {
	blockInteractWhitelist.add(tag);
}

val blank = <item:minecraft:air>;

val tagArray = [
	[<tag:items:minecraft:pickaxes>, <tag:items:forge:pickaxes>, <tag:items:forge:tools/pickaxes>],
	[<tag:items:minecraft:axes>, <tag:items:forge:axes>, <tag:items:forge:tools/axes>],
	[<tag:items:minecraft:swords>, <tag:items:forge:swords>, <tag:items:forge:tools/swords>],
	[<tag:items:minecraft:shovels>, <tag:items:forge:shovels>, <tag:items:forge:tools/shovels>],
	[<tag:items:minecraft:hoes>, <tag:items:forge:hoes>, <tag:items:forge:tools/hoes>]
];

for t in tagArray {
	if (t[1].exists) {
		val items = t[1].idElements();
		for item in items {
			t[0].addId(item);
			t[1].removeId(item);
		}
	}
	if (t[2].exists) {
		val items = t[2].idElements();
		for item in items {
			t[0].addId(item);
			t[2].removeId(item);
		}
	}
}

val fixYourTagsCataclysm = <tag:items:forge:tools/axe>.idElements();
for item in fixYourTagsCataclysm {
	<tag:items:minecraft:axes>.addId(item);
	<tag:items:forge:tools/axe>.removeId(item);
}

val plates = <tag:items:forge:plates>;
val goodItems = {
	<item:immersiveengineering:plate_iron>: <tag:items:forge:plates/iron>,
	<item:immersiveengineering:plate_steel>: <tag:items:forge:plates/steel>,
	<item:immersiveengineering:plate_copper>: <tag:items:forge:plates/copper>,
	<item:immersiveengineering:plate_gold>: <tag:items:forge:plates/gold>,
	<item:immersiveengineering:plate_electrum>: <tag:items:forge:plates/electrum>,
};

val badItems = {
	//<item:ad_astra:iron_plate>: <tag:items:forge:plates/iron>,
	<item:create:iron_sheet>: <tag:items:forge:plates/iron>,
	//<item:ad_astra:steel_plate>: <tag:items:forge:plates/steel>,
	<item:create:copper_sheet>: <tag:items:forge:plates/copper>,
	<item:create:golden_sheet>: <tag:items:forge:plates/gold>,
	<item:createaddition:electrum_sheet>: <tag:items:forge:plates/electrum>,
};

val replacer = Replacer.create();
for i, t in goodItems {
	replacer.replace<IIngredient>(<recipecomponent:crafttweaker:input/ingredients>, i, t.asIIngredient());
}
for i, t in badItems {
	replacer.replace<IIngredient>(<recipecomponent:crafttweaker:input/ingredients>, i, t.asIIngredient());
	t.remove(i);
}
replacer.execute();

### Script written by FoxMcloud5655