/*
 *   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 de.steamwar.linkage.MinVersion;
import org.bukkit.Axis;
import org.bukkit.Material;
import org.bukkit.block.data.Orientable;

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
@MinVersion(19)
public class ChainBoundingBox implements BoundingBoxLoader {

    @Override
    public void load() {
        bottomTopChain();
        northSouthChain();
        eastWestChain();
    }

    private void bottomTopChain() {
        Orientable chainBottomTop = (Orientable) Material.CHAIN.createBlockData();
        chainBottomTop.setAxis(Axis.Y);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(6.5, 0, 6.5, 3, 16, 3));
        new BlockBoundingBox(chainBottomTop, cuboidList, createItem("LAUFBAU_BLOCK_CHAIN", Material.CHAIN, "LAUFBAU_FACING_UP", "LAUFBAU_FACING_DOWN"));
    }

    private void northSouthChain() {
        Orientable chainBottomTop = (Orientable) Material.CHAIN.createBlockData();
        chainBottomTop.setAxis(Axis.Z);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(6.5, 6.5, 0, 3, 3, 16));
        new BlockBoundingBox(chainBottomTop, cuboidList, createItem("LAUFBAU_BLOCK_CHAIN", Material.CHAIN, "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH"));
    }

    private void eastWestChain() {
        Orientable chainBottomTop = (Orientable) Material.CHAIN.createBlockData();
        chainBottomTop.setAxis(Axis.X);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(0, 6.5, 6.5, 16, 3, 3));
        new BlockBoundingBox(chainBottomTop, cuboidList, createItem("LAUFBAU_BLOCK_CHAIN", Material.CHAIN, "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST"));
    }
}
