78 lines
3.2 KiB
Java
78 lines
3.2 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.mojang.datafixers.kinds.App
|
|
* com.mojang.datafixers.kinds.Applicative
|
|
* com.mojang.serialization.MapCodec
|
|
* com.mojang.serialization.codecs.RecordCodecBuilder
|
|
* org.joml.Vector3f
|
|
*/
|
|
package net.minecraft.client.renderer.special;
|
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import com.mojang.datafixers.kinds.App;
|
|
import com.mojang.datafixers.kinds.Applicative;
|
|
import com.mojang.serialization.MapCodec;
|
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|
import java.util.Optional;
|
|
import java.util.Set;
|
|
import net.minecraft.client.model.Model;
|
|
import net.minecraft.client.renderer.Sheets;
|
|
import net.minecraft.client.renderer.SubmitNodeCollector;
|
|
import net.minecraft.client.renderer.blockentity.SignRenderer;
|
|
import net.minecraft.client.renderer.special.NoDataSpecialModelRenderer;
|
|
import net.minecraft.client.renderer.special.SpecialModelRenderer;
|
|
import net.minecraft.client.resources.model.Material;
|
|
import net.minecraft.client.resources.model.MaterialSet;
|
|
import net.minecraft.resources.Identifier;
|
|
import net.minecraft.world.item.ItemDisplayContext;
|
|
import net.minecraft.world.level.block.state.properties.WoodType;
|
|
import org.joml.Vector3f;
|
|
|
|
public class StandingSignSpecialRenderer
|
|
implements NoDataSpecialModelRenderer {
|
|
private final MaterialSet materials;
|
|
private final Model.Simple model;
|
|
private final Material material;
|
|
|
|
public StandingSignSpecialRenderer(MaterialSet materials, Model.Simple model, Material material) {
|
|
this.materials = materials;
|
|
this.model = model;
|
|
this.material = material;
|
|
}
|
|
|
|
@Override
|
|
public void submit(ItemDisplayContext type, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, int overlayCoords, boolean hasFoil, int outlineColor) {
|
|
SignRenderer.submitSpecial(this.materials, poseStack, submitNodeCollector, lightCoords, overlayCoords, this.model, this.material);
|
|
}
|
|
|
|
@Override
|
|
public void getExtents(Set<Vector3f> result) {
|
|
PoseStack poseStack = new PoseStack();
|
|
SignRenderer.applyInHandTransforms(poseStack);
|
|
this.model.root().getExtentsForGui(poseStack, result);
|
|
}
|
|
|
|
public record Unbaked(WoodType woodType, Optional<Identifier> texture) implements SpecialModelRenderer.Unbaked
|
|
{
|
|
public static final MapCodec<Unbaked> MAP_CODEC = RecordCodecBuilder.mapCodec(i -> i.group((App)WoodType.CODEC.fieldOf("wood_type").forGetter(Unbaked::woodType), (App)Identifier.CODEC.optionalFieldOf("texture").forGetter(Unbaked::texture)).apply((Applicative)i, Unbaked::new));
|
|
|
|
public Unbaked(WoodType woodType) {
|
|
this(woodType, Optional.empty());
|
|
}
|
|
|
|
public MapCodec<Unbaked> type() {
|
|
return MAP_CODEC;
|
|
}
|
|
|
|
@Override
|
|
public SpecialModelRenderer<?> bake(SpecialModelRenderer.BakingContext context) {
|
|
Model.Simple model = SignRenderer.createSignModel(context.entityModelSet(), this.woodType, true);
|
|
Material material = this.texture.map(Sheets.SIGN_MAPPER::apply).orElseGet(() -> Sheets.getSignMaterial(this.woodType));
|
|
return new StandingSignSpecialRenderer(context.materials(), model, material);
|
|
}
|
|
}
|
|
}
|
|
|