/*
 *   This file is a part of the SteamWar software.
 *
 *   Copyright (C) 2025 SteamWar.de-Serverteam
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;

import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.Bell;

import java.util.ArrayList;
import java.util.List;

import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;

@Linked
public class BellBoundingBox implements BoundingBoxLoader {

    @Override
    public void load() {
        ceilingBell();

        floorNorthBell();
        floorEastBell();

        doubleWallNorthBell();
        doubleWallEastBell();

        singleWallNorthBell();
        singleWallSouthBell();
        singleWallEastBell();
        singleWallWestBell();
    }

    public void ceilingBell() {
        Bell bell = (Bell) Material.BELL.createBlockData();
        bell.setAttachment(Bell.Attachment.CEILING);
        bell.setFacing(BlockFace.NORTH);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
        cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
        cuboidList.add(pixelCuboid(7, 13, 7, 2, 3, 2));
        new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_CEILING"));
    }

    public void floorNorthBell() {
        Bell bell = (Bell) Material.BELL.createBlockData();
        bell.setAttachment(Bell.Attachment.FLOOR);
        bell.setFacing(BlockFace.NORTH);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(0, 0, 4, 16, 16, 8));
        new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_FLOOR", "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH"));
    }

    public void floorEastBell() {
        Bell bell = (Bell) Material.BELL.createBlockData();
        bell.setAttachment(Bell.Attachment.FLOOR);
        bell.setFacing(BlockFace.EAST);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(4, 0, 0, 8, 16, 16));
        new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_FLOOR", "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST"));
    }

    public void doubleWallNorthBell() {
        Bell bell = (Bell) Material.BELL.createBlockData();
        bell.setAttachment(Bell.Attachment.DOUBLE_WALL);
        bell.setFacing(BlockFace.NORTH);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
        cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
        cuboidList.add(pixelCuboid(7, 13, 0, 2, 2, 16));
        new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_DOUBLE_WALL", "LAUFBAU_FACING_NORTH"));
    }

    public void doubleWallEastBell() {
        Bell bell = (Bell) Material.BELL.createBlockData();
        bell.setAttachment(Bell.Attachment.DOUBLE_WALL);
        bell.setFacing(BlockFace.EAST);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
        cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
        cuboidList.add(pixelCuboid(0, 13, 7, 16, 2, 2));
        new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_DOUBLE_WALL", "LAUFBAU_FACING_EAST"));
    }

    public void singleWallNorthBell() {
        Bell bell = (Bell) Material.BELL.createBlockData();
        bell.setAttachment(Bell.Attachment.SINGLE_WALL);
        bell.setFacing(BlockFace.NORTH);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
        cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
        cuboidList.add(pixelCuboid(7, 13, 0, 2, 2, 13));
        new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_SINGLE_WALL", "LAUFBAU_FACING_NORTH"));
    }

    public void singleWallSouthBell() {
        Bell bell = (Bell) Material.BELL.createBlockData();
        bell.setAttachment(Bell.Attachment.SINGLE_WALL);
        bell.setFacing(BlockFace.SOUTH);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
        cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
        cuboidList.add(pixelCuboid(7, 13, 3, 2, 2, 13));
        new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_SINGLE_WALL", "LAUFBAU_FACING_SOUTH"));
    }

    public void singleWallEastBell() {
        Bell bell = (Bell) Material.BELL.createBlockData();
        bell.setAttachment(Bell.Attachment.SINGLE_WALL);
        bell.setFacing(BlockFace.EAST);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
        cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
        cuboidList.add(pixelCuboid(3, 13, 7, 13, 2, 2));
        new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_SINGLE_WALL", "LAUFBAU_FACING_EAST"));
    }

    public void singleWallWestBell() {
        Bell bell = (Bell) Material.BELL.createBlockData();
        bell.setAttachment(Bell.Attachment.SINGLE_WALL);
        bell.setFacing(BlockFace.WEST);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
        cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
        cuboidList.add(pixelCuboid(0, 13, 7, 13, 2, 2));
        new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_SINGLE_WALL", "LAUFBAU_FACING_WEST"));
    }
}
