package client.renderer.blockmodel;

import java.util.Map;
import java.util.Map.Entry;

import common.block.Block;
import common.collect.Maps;
import common.properties.Property;
import common.world.State;

public abstract class StateMap
{
    protected Map<State, String> mapStateModelLocations = Maps.<State, String>newLinkedHashMap();

    public String getPropertyString(Map<Property, Comparable> p_178131_1_)
    {
        StringBuilder stringbuilder = new StringBuilder();

        for (Entry<Property, Comparable> entry : p_178131_1_.entrySet())
        {
            if (stringbuilder.length() != 0)
            {
                stringbuilder.append(",");
            }

            Property iproperty = (Property)entry.getKey();
            Comparable comparable = (Comparable)entry.getValue();
            stringbuilder.append(iproperty.getName());
            stringbuilder.append("=");
            stringbuilder.append(iproperty.getName(comparable));
        }

        if (stringbuilder.length() == 0)
        {
            stringbuilder.append("normal");
        }

        return stringbuilder.toString();
    }

    public Map<State, String> putStateModelLocations(Block blockIn)
    {
        for (State iblockstate : blockIn.getValidStates())
        {
            this.mapStateModelLocations.put(iblockstate, this.getResourceLocation(iblockstate));
        }

        return this.mapStateModelLocations;
    }

    protected abstract String getResourceLocation(State state);
}
