package com.r3944realms.modernlifepatch.content.blocks.type.mirror.shape;

import com.r3944realms.modernlifepatch.content.blocks.type.mirror.MirrorPart;
import com.r3944realms.modernlifepatch.utils.ShapeUtil;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.shapes.VoxelShape;

import java.util.stream.Stream;

public class MirrorShape implements IMirrorShape{
    public static final VoxelShape SHAPE_NORTH = Block.box(0, 0, 0.099, 16, 16, 1.099), SHAPE_SOUTH, SHAPE_EAST, SHAPE_WEST;
    static {
        SHAPE_EAST = ShapeUtil.RotateVoxelShapeClockwise(SHAPE_NORTH);
        SHAPE_SOUTH = ShapeUtil.RotateVoxelShapeClockwise(SHAPE_EAST);
        SHAPE_WEST = ShapeUtil.RotateVoxelShapeClockwise(SHAPE_SOUTH);
    }
    @Override
    public VoxelShape getDefaultShape(Direction direction) {
        return (VoxelShape) switch (direction) {
            case DOWN, UP -> Stream.empty();
            case NORTH -> SHAPE_NORTH;
            case SOUTH -> SHAPE_SOUTH;
            case WEST -> SHAPE_WEST;
            case EAST -> SHAPE_EAST;
        };
    }

    @Override
    public VoxelShape getShapeByPart(Direction direction, MirrorPart part) {
        if (!testIsRightPart(part)) throw new IllegalArgumentException("Not a right part in mirror shape");
        return getDefaultShape(direction);
    }

    @Override
    public MirrorPart.MirrorType getMirrorType() {
        return MirrorPart.MirrorType.COMMON_MIRROR;
    }


}
