/*
 *  Copyright 2025-2026 R3944Realms
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package top.r3944realms.eroticdungeongame.content.block.type;

import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.properties.WoodType;
import net.minecraft.world.phys.shapes.VoxelShape;
import top.r3944realms.eroticdungeongame.content.block.IWoodTypeBlock;
import top.r3944realms.eroticdungeongame.content.block.multiply.horizontal.HorizontalTripleSeatBlock;
import top.r3944realms.eroticdungeongame.content.block.part.AdvanceSeatPart;
import top.r3944realms.lib39.util.shape.ShapeUtil;

import java.util.EnumMap;
import java.util.Map;

public class RackBlock extends HorizontalTripleSeatBlock implements IWoodTypeBlock {
    private final WoodType woodType;

    public RackBlock(WoodType woodType) {
        super(PROPERTIES);
        this.woodType = woodType;
    }

    public WoodType getWoodType() {
        return woodType;
    }

    @Override
    public void setupShape() {
        VoxelShape foot = ShapeUtil.builder()
                .addPixelBox(0, 8, 0, 16, 10, 16)
                .addPixelBox(0, 0, 11, 2, 8, 13)
                .addPixelBox(14, 0, 11, 16, 8, 13)
                .addPixelBox(0, 10, 11, 2, 17, 16)
                .addPixelBox(14, 10, 11, 16, 17, 16)
                .build();
        VoxelShape middle = ShapeUtil.builder()
                .addPixelBox(0, 8, 0, 16, 10, 16)
                .build();
        VoxelShape head = ShapeUtil.builder()
                .addPixelBox(0, 8, 0, 16, 10, 16)     // 顶部平板
                .addPixelBox(0, 0, 4, 2, 8, 6)        // 左下立柱
                .addPixelBox(14, 0, 4, 16, 8, 6)      // 右下立柱
                .addPixelBox(0, 10, 4, 2, 17, 6)      // 左上立柱
                .addPixelBox(14, 10, 4, 16, 17, 6)    // 右上立柱
                .addPixelBox(7, 10, 4, 9, 15, 6)      // 中间立柱
                .addPixelBox(2, 15, 4, 14, 17, 6)     // 顶部横梁
                .build();
        EnumMap<AdvanceSeatPart, Map<Direction, VoxelShape>> shapes = new EnumMap<>(AdvanceSeatPart.class);
        shapes.put(AdvanceSeatPart.HEAD, ShapeUtil.createUniformDirectionMap(head));
        shapes.put(AdvanceSeatPart.MIDDLE, ShapeUtil.createUniformDirectionMap(middle));
        shapes.put(AdvanceSeatPart.FOOT, ShapeUtil.createUniformDirectionMap(foot));
        setPartMap(shapes);
    }
}
