74 lines
2.6 KiB
Java
74 lines
2.6 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* org.jspecify.annotations.Nullable
|
|
*/
|
|
package net.minecraft.client.resources.model;
|
|
|
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
|
import java.util.Comparator;
|
|
import java.util.Objects;
|
|
import java.util.function.Function;
|
|
import net.minecraft.client.renderer.MultiBufferSource;
|
|
import net.minecraft.client.renderer.entity.ItemRenderer;
|
|
import net.minecraft.client.renderer.rendertype.RenderType;
|
|
import net.minecraft.client.resources.model.MaterialSet;
|
|
import net.minecraft.resources.Identifier;
|
|
import org.jspecify.annotations.Nullable;
|
|
|
|
public class Material {
|
|
public static final Comparator<Material> COMPARATOR = Comparator.comparing(Material::atlasLocation).thenComparing(Material::texture);
|
|
private final Identifier atlasLocation;
|
|
private final Identifier texture;
|
|
private @Nullable RenderType renderType;
|
|
|
|
public Material(Identifier atlasLocation, Identifier texture) {
|
|
this.atlasLocation = atlasLocation;
|
|
this.texture = texture;
|
|
}
|
|
|
|
public Identifier atlasLocation() {
|
|
return this.atlasLocation;
|
|
}
|
|
|
|
public Identifier texture() {
|
|
return this.texture;
|
|
}
|
|
|
|
public RenderType renderType(Function<Identifier, RenderType> renderType) {
|
|
if (this.renderType == null) {
|
|
this.renderType = renderType.apply(this.atlasLocation);
|
|
}
|
|
return this.renderType;
|
|
}
|
|
|
|
public VertexConsumer buffer(MaterialSet materials, MultiBufferSource bufferSource, Function<Identifier, RenderType> renderType) {
|
|
return materials.get(this).wrap(bufferSource.getBuffer(this.renderType(renderType)));
|
|
}
|
|
|
|
public VertexConsumer buffer(MaterialSet materials, MultiBufferSource bufferSource, Function<Identifier, RenderType> renderType, boolean sheeted, boolean hasFoil) {
|
|
return materials.get(this).wrap(ItemRenderer.getFoilBuffer(bufferSource, this.renderType(renderType), sheeted, hasFoil));
|
|
}
|
|
|
|
public boolean equals(Object o) {
|
|
if (this == o) {
|
|
return true;
|
|
}
|
|
if (o == null || this.getClass() != o.getClass()) {
|
|
return false;
|
|
}
|
|
Material material = (Material)o;
|
|
return this.atlasLocation.equals(material.atlasLocation) && this.texture.equals(material.texture);
|
|
}
|
|
|
|
public int hashCode() {
|
|
return Objects.hash(this.atlasLocation, this.texture);
|
|
}
|
|
|
|
public String toString() {
|
|
return "Material{atlasLocation=" + String.valueOf(this.atlasLocation) + ", texture=" + String.valueOf(this.texture) + "}";
|
|
}
|
|
}
|
|
|