package net.minecraft.client.resources.model;

import java.util.Objects;
import net.minecraft.client.renderer.entity.ItemRenderer;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.renderer.MultiBufferSource;
import java.util.function.Function;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;

public class Material {
    private final ResourceLocation atlasLocation;
    private final ResourceLocation texture;
    @Nullable
    private RenderType renderType;
    
    public Material(final ResourceLocation uh1, final ResourceLocation uh2) {
        this.atlasLocation = uh1;
        this.texture = uh2;
    }
    
    public ResourceLocation atlasLocation() {
        return this.atlasLocation;
    }
    
    public ResourceLocation texture() {
        return this.texture;
    }
    
    public TextureAtlasSprite sprite() {
        return Minecraft.getInstance().getTextureAtlas(this.atlasLocation()).apply(this.texture());
    }
    
    public RenderType renderType(final Function<ResourceLocation, RenderType> function) {
        if (this.renderType == null) {
            this.renderType = function.apply(this.atlasLocation);
        }
        return this.renderType;
    }
    
    public VertexConsumer buffer(final MultiBufferSource ebz, final Function<ResourceLocation, RenderType> function) {
        return this.sprite().wrap(ebz.getBuffer(this.renderType(function)));
    }
    
    public VertexConsumer buffer(final MultiBufferSource ebz, final Function<ResourceLocation, RenderType> function, final boolean boolean3) {
        return this.sprite().wrap(ItemRenderer.getFoilBufferDirect(ebz, this.renderType(function), true, boolean3));
    }
    
    @Override
    public boolean equals(final Object object) {
        if (this == object) {
            return true;
        }
        if (object == null || this.getClass() != object.getClass()) {
            return false;
        }
        final Material enk3 = (Material)object;
        return this.atlasLocation.equals(enk3.atlasLocation) && this.texture.equals(enk3.texture);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(this.atlasLocation, this.texture);
    }
    
    @Override
    public String toString() {
        return "Material{atlasLocation=" + this.atlasLocation + ", texture=" + this.texture + '}';
    }
}
