/*
 *   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.MultipleFacing;

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 ChorusPlantBoundingBox implements BoundingBoxLoader {

    @Override
    public void load() {
        for (int nx = 0; nx < 2; nx++) {
            for (int ny = 0; ny < 2; ny++) {
                for (int nz = 0; nz < 2; nz++) {
                    for (int px = 0; px < 2; px++) {
                        for (int py = 0; py < 2; py++) {
                            for (int pz = 0; pz < 2; pz++) {
                                MultipleFacing chorusPlant = (MultipleFacing) Material.CHORUS_PLANT.createBlockData();
                                List<String> lore = new ArrayList<>();
                                List<Cuboid> cuboidList = new ArrayList<>();
                                cuboidList.add(pixelCuboid(3, 3, 3, 10, 10, 10));
                                if (nx == 1) {
                                    lore.add("LAUFBAU_CONNECTION_WEST");
                                    chorusPlant.setFace(BlockFace.WEST, true);
                                    cuboidList.add(pixelCuboid(0, 3, 3, 3, 10, 10));
                                }
                                if (ny == 1) {
                                    lore.add("LAUFBAU_CONNECTION_DOWN");
                                    chorusPlant.setFace(BlockFace.DOWN, true);
                                    cuboidList.add(pixelCuboid(3, 0, 3, 10, 3, 10));
                                }
                                if (nz == 1) {
                                    lore.add("LAUFBAU_CONNECTION_NORTH");
                                    chorusPlant.setFace(BlockFace.NORTH, true);
                                    cuboidList.add(pixelCuboid(3, 3, 0, 10, 10, 3));
                                }
                                if (px == 1) {
                                    lore.add("LAUFBAU_CONNECTION_EAST");
                                    chorusPlant.setFace(BlockFace.EAST, true);
                                    cuboidList.add(pixelCuboid(13, 3, 3, 3, 10, 10));
                                }
                                if (py == 1) {
                                    lore.add("LAUFBAU_CONNECTION_UP");
                                    chorusPlant.setFace(BlockFace.UP, true);
                                    cuboidList.add(pixelCuboid(3, 13, 3, 10, 3, 10));
                                }
                                if (pz == 1) {
                                    lore.add("LAUFBAU_CONNECTION_SOUTH");
                                    chorusPlant.setFace(BlockFace.SOUTH, true);
                                    cuboidList.add(pixelCuboid(3, 3, 13, 10, 10, 3));
                                }
                                new BlockBoundingBox(chorusPlant, cuboidList, createItem("LAUFBAU_BLOCK_CHORUS_PLANT", Material.CHORUS_PLANT, lore.toArray(new String[0])));
                            }
                        }
                    }
                }
            }
        }
    }
}
