/*
 * This file is a part of the SteamWar software.
 *
 * Copyright (C) 2022  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.Hopper;

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

    @Override
    public void load() {
        downHopper();
        northHopper();
        southHopper();
        eastHopper();
        westHopper();
    }

    public void downHopper() {
        Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
        hopper.setFacing(BlockFace.DOWN);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
        cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
        cuboidList.add(pixelCuboid(6, 0, 6, 4, 4, 4));
        new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_FLOOR"));
    }

    public void northHopper() {
        Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
        hopper.setFacing(BlockFace.NORTH);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
        cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
        cuboidList.add(pixelCuboid(6, 4, 0, 4, 4, 4));
        new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_NORTH"));
    }

    public void southHopper() {
        Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
        hopper.setFacing(BlockFace.SOUTH);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
        cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
        cuboidList.add(pixelCuboid(6, 4, 12, 4, 4, 4));
        new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_SOUTH"));
    }

    public void eastHopper() {
        Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
        hopper.setFacing(BlockFace.EAST);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
        cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
        cuboidList.add(pixelCuboid(12, 4, 6, 4, 4, 4));
        new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_EAST"));
    }

    public void westHopper() {
        Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
        hopper.setFacing(BlockFace.WEST);
        List<Cuboid> cuboidList = new ArrayList<>();
        cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
        cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
        cuboidList.add(pixelCuboid(0, 4, 6, 4, 4, 4));
        new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_WEST"));
    }
}
