package net.minecraft.client.renderer.texture;

import net.minecraft.client.resources.model.Material;
import java.util.stream.Collectors;
import java.util.function.Function;
import java.util.Collection;
import net.minecraft.resources.ResourceLocation;
import java.util.Map;

public class AtlasSet implements AutoCloseable {
    private final Map<ResourceLocation, TextureAtlas> atlases;
    
    public AtlasSet(final Collection<TextureAtlas> collection) {
        this.atlases = collection.stream().collect(Collectors.toMap(TextureAtlas::location, Function.<TextureAtlas>identity()));
    }
    
    public TextureAtlas getAtlas(final ResourceLocation sm) {
        return this.atlases.get(sm);
    }
    
    public TextureAtlasSprite getSprite(final Material eby) {
        return this.atlases.get(eby.atlasLocation()).getSprite(eby.texture());
    }
    
    @Override
    public void close() {
        this.atlases.values().forEach(TextureAtlas::clearTextureData);
        this.atlases.clear();
    }
}
