import { BlockPermutation } from '@minecraft/server';
class onRandomTick {
    constructor() {
        this.onRandomTick = this.onRandomTick.bind(this);
    }
    onRandomTick(_componentData) { }
}
export class grow extends onRandomTick {
    onRandomTick(componentData) {
        let direction = Math.floor(Math.random() * 6);
        let blockToPlace;
        switch (componentData.block.typeId) {
            case 'endorah_mo:ice_shard_block':
                blockToPlace = 'endorah_mo:ice_small_crystal_bud';
                break;
            case 'endorah_mo:echo_shard_block':
                blockToPlace = 'endorah_mo:echo_small_crystal_bud';
                break;
        }
        switch (direction) {
            case 0:
                {
                    let block = componentData.block.above();
                    if (block.typeId === 'minecraft:air')
                        block.setPermutation(BlockPermutation.resolve(blockToPlace, {
                            'minecraft:block_face': 'up'
                        }));
                }
                break;
            case 1:
                {
                    let block = componentData.block.below();
                    if (block.typeId === 'minecraft:air')
                        block.setPermutation(BlockPermutation.resolve(blockToPlace, {
                            'minecraft:block_face': 'down'
                        }));
                }
                break;
            case 2:
                {
                    let block = componentData.block.north();
                    if (block.typeId === 'minecraft:air')
                        block.setPermutation(BlockPermutation.resolve(blockToPlace, {
                            'minecraft:block_face': 'north'
                        }));
                }
                break;
            case 3:
                {
                    let block = componentData.block.east();
                    if (block.typeId === 'minecraft:air')
                        block.setPermutation(BlockPermutation.resolve(blockToPlace, {
                            'minecraft:block_face': 'east'
                        }));
                }
                break;
            case 4:
                {
                    let block = componentData.block.south();
                    if (block.typeId === 'minecraft:air')
                        block.setPermutation(BlockPermutation.resolve(blockToPlace, {
                            'minecraft:block_face': 'south'
                        }));
                }
                break;
            case 5:
                {
                    let block = componentData.block.west();
                    if (block.typeId === 'minecraft:air')
                        block.setPermutation(BlockPermutation.resolve(blockToPlace, {
                            'minecraft:block_face': 'west'
                        }));
                }
                break;
            default:
                break;
        }
    }
}
export class progressCrystalGrowth extends onRandomTick {
    onRandomTick(componentData) {
        const block = componentData.block;
        const facing = block.permutation.getState('minecraft:block_face');
        if (block.typeId == 'endorah_mo:ice_small_crystal_bud') {
            block.setPermutation(BlockPermutation.resolve('endorah_mo:ice_medium_crystal_bud', {
                'minecraft:block_face': facing
            }));
        }
        if (block.typeId == 'endorah_mo:ice_medium_crystal_bud') {
            block.setPermutation(BlockPermutation.resolve('endorah_mo:ice_crystal_bud', {
                'minecraft:block_face': facing
            }));
        }
        if (block.typeId == 'endorah_mo:echo_small_crystal_bud') {
            block.setPermutation(BlockPermutation.resolve('endorah_mo:echo_crystal_bud', {
                'minecraft:block_face': facing
            }));
        }
    }
}
