import BlockTransformation from '../transformations/blockTransformation';
import { transformLogBlock } from './utils';
const rules = [
    {
        from: [
            'minecraft:cobblestone',
            'minecraft:mossy_cobblestone',
            'minecraft:cobblestone_double_slab',
            'minecraft:mossy_cobblestone_double_slab',
        ],
        to: new BlockTransformation('twb_wisu:withered_cobblestone')
    },
    {
        from: [
            'minecraft:smooth_sandstone',
            'minecraft:smooth_red_sandstone',
            'minecraft:smooth_stone',
            'minecraft:smooth_sandstone_double_slab',
            'minecraft:smooth_red_sandstone_double_slab',
            'minecraft:smooth_stone_double_slab',
            'minecraft:sandstone_double_slab',
            'minecraft:red_sandstone_double_slab',
        ],
        to: new BlockTransformation('twb_wisu:ash')
    },
    {
        from: [
            'minecraft:cut_sandstone',
            'minecraft:cut_red_sandstone',
            'minecraft:cut_sandstone_double_slab',
            'minecraft:cut_red_sandstone_double_slab',
            'minecraft:polished_andesite',
            'minecraft:polished_diorite',
            'minecraft:polished_granite',
            'minecraft:polished_tuff',
            'minecraft:polished_andesite_double_slab',
            'minecraft:polished_diorite_double_slab',
            'minecraft:polished_granite_double_slab',
            'minecraft:polished_tuff_double_slab',
            'minecraft:normal_stone_double_slab',
            'minecraft:andesite_double_slab',
            'minecraft:diorite_double_slab',
            'minecraft:granite_double_slab',
        ],
        to: new BlockTransformation('twb_wisu:withered_stone')
    },
    {
        from: [
            'minecraft:hay_block',
        ],
        to: new BlockTransformation(null)
    },
    {
        // Slabs
        from: [
            'minecraft:acacia_slab',
            'minecraft:andesite_slab',
            'minecraft:bamboo_mosaic_slab',
            'minecraft:bamboo_slab',
            'minecraft:birch_slab',
            'minecraft:brick_slab',
            'minecraft:cherry_slab',
            'minecraft:cobblestone_slab',
            'minecraft:cut_red_sandstone_slab',
            'minecraft:cut_sandstone_slab',
            'minecraft:dark_oak_slab',
            'minecraft:diorite_slab',
            'minecraft:granite_slab',
            'minecraft:jungle_slab',
            'minecraft:mangrove_slab',
            'minecraft:mossy_cobblestone_slab',
            'minecraft:mossy_stone_brick_slab',
            'minecraft:mud_brick_slab',
            'minecraft:normal_stone_slab',
            'minecraft:oak_slab',
            'minecraft:pale_oak_slab',
            'minecraft:petrified_oak_slab',
            'minecraft:polished_andesite_slab',
            'minecraft:polished_diorite_slab',
            'minecraft:polished_granite_slab',
            'minecraft:polished_tuff_slab',
            'minecraft:red_sandstone_slab',
            'minecraft:sandstone_slab',
            'minecraft:smooth_red_sandstone_slab',
            'minecraft:smooth_sandstone_slab',
            'minecraft:smooth_stone_slab',
            'minecraft:spruce_slab',
            'minecraft:stone_brick_slab',
            'minecraft:tuff_brick_slab',
            'minecraft:tuff_slab',
        ],
        to: new BlockTransformation(null)
    },
    {
        // Stairs
        from: [
            'minecraft:acacia_stairs',
            'minecraft:andesite_stairs',
            'minecraft:bamboo_mosaic_stairs',
            'minecraft:bamboo_stairs',
            'minecraft:birch_stairs',
            'minecraft:brick_stairs',
            'minecraft:cherry_stairs',
            'minecraft:dark_oak_stairs',
            'minecraft:diorite_stairs',
            'minecraft:granite_stairs',
            'minecraft:jungle_stairs',
            'minecraft:mangrove_stairs',
            'minecraft:mossy_cobblestone_stairs',
            'minecraft:mossy_stone_brick_stairs',
            'minecraft:mud_brick_stairs',
            'minecraft:normal_stone_stairs',
            'minecraft:oak_stairs',
            'minecraft:pale_oak_stairs',
            'minecraft:polished_andesite_stairs',
            'minecraft:polished_diorite_stairs',
            'minecraft:polished_granite_stairs',
            'minecraft:polished_tuff_stairs',
            'minecraft:red_sandstone_stairs',
            'minecraft:sandstone_stairs',
            'minecraft:smooth_red_sandstone_stairs',
            'minecraft:smooth_sandstone_stairs',
            'minecraft:spruce_stairs',
            'minecraft:stone_brick_stairs',
            'minecraft:stone_stairs',
            'minecraft:tuff_brick_stairs',
            'minecraft:tuff_stairs',
        ],
        to: new BlockTransformation(null)
    },
    {
        // Planks
        from: [
            'minecraft:acacia_planks',
            'minecraft:bamboo_planks',
            'minecraft:birch_planks',
            'minecraft:cherry_planks',
            'minecraft:dark_oak_planks',
            'minecraft:jungle_planks',
            'minecraft:mangrove_planks',
            'minecraft:oak_planks',
            'minecraft:pale_oak_planks',
            'minecraft:spruce_planks',
            'minecraft:acacia_double_slab',
            'minecraft:bamboo_double_slab',
            'minecraft:bamboo_mosaic_double_slab',
            'minecraft:birch_double_slab',
            'minecraft:cherry_double_slab',
            'minecraft:dark_oak_double_slab',
            'minecraft:jungle_double_slab',
            'minecraft:mangrove_double_slab',
            'minecraft:oak_double_slab',
            'minecraft:pale_oak_double_slab',
            'minecraft:petrified_oak_double_slab',
            'minecraft:spruce_double_slab',
        ],
        to: new BlockTransformation('twb_wisu:withered_planks')
    },
    {
        // Fences & walls
        from: [
            'minecraft:fence_gate',
            'minecraft:acacia_fence',
            'minecraft:acacia_fence_gate',
            'minecraft:bamboo_fence',
            'minecraft:bamboo_fence_gate',
            'minecraft:birch_fence',
            'minecraft:birch_fence_gate',
            'minecraft:cherry_fence',
            'minecraft:cherry_fence_gate',
            'minecraft:dark_oak_fence',
            'minecraft:dark_oak_fence_gate',
            'minecraft:jungle_fence',
            'minecraft:jungle_fence_gate',
            'minecraft:mangrove_fence',
            'minecraft:mangrove_fence_gate',
            'minecraft:oak_fence',
            'minecraft:pale_oak_fence',
            'minecraft:pale_oak_fence_gate',
            'minecraft:spruce_fence',
            'minecraft:spruce_fence_gate',
            'minecraft:andesite_wall',
            'minecraft:cobblestone_wall',
            'minecraft:diorite_wall',
            'minecraft:granite_wall',
            'minecraft:mossy_cobblestone_wall',
            'minecraft:mossy_stone_brick_wall',
            'minecraft:mud_brick_wall',
            'minecraft:polished_tuff_wall',
            'minecraft:prismarine_wall',
            'minecraft:red_sandstone_wall',
            'minecraft:sandstone_wall',
            'minecraft:stone_brick_wall',
            'minecraft:tuff_brick_wall',
            'minecraft:tuff_wall',
        ],
        to: new BlockTransformation(null)
    },
    {
        // Chiseled Bricks
        from: [
            'minecraft:chiseled_stone_bricks',
            'minecraft:chiseled_tuff',
            'minecraft:chiseled_tuff_bricks',
            'minecraft:infested_chiseled_stone_bricks',
        ],
        to: new BlockTransformation('twb_wisu:chiseled_withered_stone_bricks')
    },
    {
        // Bricks
        from: [
            'minecraft:brick_blcok',
            'minecraft:cracked_stone_bricks',
            'minecraft:infested_cracked_stone_bricks',
            'minecraft:infested_mossy_stone_bricks',
            'minecraft:infested_stone_bricks',
            'minecraft:mossy_stone_bricks',
            'minecraft:mud_bricks',
            'minecraft:stone_bricks',
            'minecraft:tuff_bricks',
            'minecraft:brick_double_slab',
            'minecraft:mossy_stone_brick_double_slab',
            'minecraft:mud_brick_double_slab',
            'minecraft:stone_brick_double_slab',
            'minecraft:tuff_brick_double_slab',
        ],
        to: new BlockTransformation('twb_wisu:withered_stone_bricks')
    },
    {
        from: [
            'minecraft:stripped_oak_log',
            'minecraft:stripped_spruce_log',
            'minecraft:stripped_birch_log',
            'minecraft:stripped_dark_oak_log',
            'minecraft:stripped_cherry_log',
            'minecraft:stripped_creaking_heart',
            'minecraft:stripped_acacia_log',
            'minecraft:stripped_mangrove_log',
            'minecraft:stripped_jungle_log',
            'minecraft:stripped_pale_oak_log',
        ],
        to: new BlockTransformation('twb_wisu:stripped_withered_log', {
            mapStates: {
                pillar_axis: transformLogBlock
            }
        })
    },
    {
        from: [
            'minecraft:stripped_oak_wood',
            'minecraft:stripped_spruce_wood',
            'minecraft:stripped_birch_wood',
            'minecraft:stripped_dark_oak_wood',
            'minecraft:stripped_cherry_wood',
            'minecraft:stripped_creaking_heart',
            'minecraft:stripped_acacia_wood',
            'minecraft:stripped_mangrove_wood',
            'minecraft:stripped_jungle_wood',
            'minecraft:stripped_pale_oak_wood',
        ],
        to: new BlockTransformation('twb_wisu:stripped_withered_wood', {
            mapStates: {
                pillar_axis: transformLogBlock
            }
        })
    },
    {
        from: [
            'minecraft:oak_wood',
            'minecraft:spruce_wood',
            'minecraft:birch_wood',
            'minecraft:dark_oak_wood',
            'minecraft:cherry_wood',
            'minecraft:creaking_heart',
            'minecraft:acacia_wood',
            'minecraft:mangrove_wood',
            'minecraft:jungle_wood',
            'minecraft:pale_oak_wood',
        ],
        to: new BlockTransformation('twb_wisu:withered_wood', {
            mapStates: {
                pillar_axis: transformLogBlock
            }
        })
    },
    {
        from: [
            'minecraft:black_wool',
            'minecraft:blue_wool',
            'minecraft:brown_wool',
            'minecraft:cyan_wool',
            'minecraft:gray_wool',
            'minecraft:green_wool',
            'minecraft:light_blue_wool',
            'minecraft:light_gray_wool',
            'minecraft:lime_wool',
            'minecraft:magenta_wool',
            'minecraft:orange_wool',
            'minecraft:pink_wool',
            'minecraft:purple_wool',
            'minecraft:red_wool',
            'minecraft:white_wool',
            'minecraft:yellow_wool',
            'minecraft:glass',
            'minecraft:tinted_glass',
            'minecraft:black_stained_glass',
            'minecraft:blue_stained_glass',
            'minecraft:brown_stained_glass',
            'minecraft:cyan_stained_glass',
            'minecraft:gray_stained_glass',
            'minecraft:green_stained_glass',
            'minecraft:light_blue_stained_glass',
            'minecraft:light_gray_stained_glass',
            'minecraft:lime_stained_glass',
            'minecraft:magenta_stained_glass',
            'minecraft:orange_stained_glass',
            'minecraft:pink_stained_glass',
            'minecraft:purple_stained_glass',
            'minecraft:red_stained_glass',
            'minecraft:white_stained_glass',
            'minecraft:yellow_stained_glass',
            'minecraft:glass_pane',
            'minecraft:black_stained_glass_pane',
            'minecraft:blue_stained_glass_pane',
            'minecraft:brown_stained_glass_pane',
            'minecraft:cyan_stained_glass_pane',
            'minecraft:gray_stained_glass_pane',
            'minecraft:green_stained_glass_pane',
            'minecraft:light_blue_stained_glass_pane',
            'minecraft:light_gray_stained_glass_pane',
            'minecraft:lime_stained_glass_pane',
            'minecraft:magenta_stained_glass_pane',
            'minecraft:orange_stained_glass_pane',
            'minecraft:pink_stained_glass_pane',
            'minecraft:purple_stained_glass_pane',
            'minecraft:red_stained_glass_pane',
            'minecraft:white_stained_glass_pane',
            'minecraft:yellow_stained_glass_pane',
        ],
        to: new BlockTransformation(null)
    },
    {
        from: [
            'minecraft:wooden_door',
            'minecraft:spruce_door',
            'minecraft:birch_door',
            'minecraft:dark_oak_door',
            'minecraft:cherry_door',
            'minecraft:acacia_door',
            'minecraft:mangrove_door',
            'minecraft:jungle_door',
            'minecraft:pale_oak_door',
        ],
        to: new BlockTransformation('twb_wisu:withered_door', {
            conditions: { upper_block_bit: false },
            mapStates: {
                // eslint-disable-next-line @typescript-eslint/naming-convention
                'minecraft:cardinal_direction': (s) => {
                    const direction = s;
                    let newDirection;
                    if (direction === 'west')
                        newDirection = 'south';
                    else if (direction === 'north')
                        newDirection = 'west';
                    else if (direction === 'east')
                        newDirection = 'north';
                    else
                        newDirection = 'east';
                    return { state: 'minecraft:cardinal_direction', value: newDirection };
                },
                door_hinge_bit: 'twb_wisu:door_hinge_bit',
                open_bit: 'twb_wisu:open_bit',
                upper_block_bit: 'twb_wisu:upper_block_bit'
            },
            afterConvert: (b) => {
                b.above()?.setPermutation(b.permutation.withState('twb_wisu:upper_block_bit', true));
            }
        })
    },
    {
        from: [
            'minecraft:trapdoor',
            'minecraft:spruce_trapdoor',
            'minecraft:birch_trapdoor',
            'minecraft:dark_oak_trapdoor',
            'minecraft:cherry_trapdoor',
            'minecraft:acacia_trapdoor',
            'minecraft:mangrove_trapdoor',
            'minecraft:jungle_trapdoor',
            'minecraft:pale_oak_trapdoor',
        ],
        to: new BlockTransformation('twb_wisu:withered_trapdoor', {
            mapStates: {
                // eslint-disable-next-line @typescript-eslint/naming-convention
                direction: (s) => {
                    const direction = s;
                    const newDirection = ['west', 'east', 'north', 'south'][direction];
                    return { state: 'minecraft:cardinal_direction', value: newDirection };
                },
                open_bit: 'twb_wisu:open_bit',
                // eslint-disable-next-line @typescript-eslint/naming-convention
                upside_down_bit: (s) => ({ state: 'minecraft:vertical_half', value: s ? 'top' : 'bottom' })
            }
        })
    },
];
export default rules;
