package client.renderer.chunk;

import java.util.BitSet;
import java.util.Set;

import common.util.Facing;

public class SetVisibility
{
    private static final int COUNT_FACES = Facing.values().length;
    
    private final BitSet bitSet;

    public SetVisibility()
    {
        this.bitSet = new BitSet(COUNT_FACES * COUNT_FACES);
    }

    public void setManyVisible(Set<Facing> p_178620_1_)
    {
        for (Facing enumfacing : p_178620_1_)
        {
            for (Facing enumfacing1 : p_178620_1_)
            {
                this.setVisible(enumfacing, enumfacing1, true);
            }
        }
    }

    public void setVisible(Facing facing, Facing facing2, boolean p_178619_3_)
    {
        this.bitSet.set(facing.ordinal() + facing2.ordinal() * COUNT_FACES, p_178619_3_);
        this.bitSet.set(facing2.ordinal() + facing.ordinal() * COUNT_FACES, p_178619_3_);
    }

    public void setAllVisible(boolean visible)
    {
        this.bitSet.set(0, this.bitSet.size(), visible);
    }

    public boolean isVisible(Facing facing, Facing facing2)
    {
        return this.bitSet.get(facing.ordinal() + facing2.ordinal() * COUNT_FACES);
    }

    public String toString()
    {
        StringBuilder stringbuilder = new StringBuilder();
        stringbuilder.append(' ');

        for (Facing enumfacing : Facing.values())
        {
            stringbuilder.append(' ').append(enumfacing.toString().toUpperCase().charAt(0));
        }

        stringbuilder.append('\n');

        for (Facing enumfacing2 : Facing.values())
        {
            stringbuilder.append(enumfacing2.toString().toUpperCase().charAt(0));

            for (Facing enumfacing1 : Facing.values())
            {
                if (enumfacing2 == enumfacing1)
                {
                    stringbuilder.append("  ");
                }
                else
                {
                    boolean flag = this.isVisible(enumfacing2, enumfacing1);
                    stringbuilder.append(' ').append((char)(flag ? 'Y' : 'n'));
                }
            }

            stringbuilder.append('\n');
        }

        return stringbuilder.toString();
    }
}
