/*
 *  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.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import top.r3944realms.eroticdungeongame.content.block.IColorBlock;
import top.r3944realms.eroticdungeongame.content.block.multiply.vertical.VerticalDoubleSeatBlock;
import top.r3944realms.eroticdungeongame.content.block.part.SeatPart;
import top.r3944realms.eroticdungeongame.util.ColorContent;
import top.r3944realms.lib39.util.shape.ShapeUtil;

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

public class GlassDisplayRackBlock extends VerticalDoubleSeatBlock implements IColorBlock {
    @Nullable
    public final ColorContent color;

    private static final BlockBehaviour.Properties PROPERTIES = BlockBehaviour.Properties.of()
            .strength(2.0f)
            .explosionResistance(3.0f)
            .sound(SoundType.GLASS)
            .isViewBlocking((state, level, pos) -> false)
            .isSuffocating((state, level, pos) -> false)
            .noOcclusion();

    public GlassDisplayRackBlock(@Nullable ColorContent color) {
        super(PROPERTIES);
        this.color = color;
    }

    public GlassDisplayRackBlock() {
        this(null);
    }

    @Override
    @Nullable
    public ColorContent getColor() {
        return color;
    }

    @Override
    public void setupShape() {
        VoxelShape voxelShape = ShapeUtil.builder()
                .addPixelBox(0, 0, 0, 16, 16, 16)
                .build();
        Map<Direction, VoxelShape> uniformDirectionMap = ShapeUtil.createUniformDirectionMap(voxelShape);
        EnumMap<SeatPart, Map<Direction, VoxelShape>> shapes = new EnumMap<>(SeatPart.class);
        shapes.put(SeatPart.FOOT, uniformDirectionMap);
        shapes.put(SeatPart.HEAD, uniformDirectionMap);
        setPartMap(shapes);
    }

    @Override
    public int getLightEmission(BlockState state, BlockGetter level, BlockPos pos) {
        return 15;
    }
}
