SkullSpecialRenderer .java

net.minecraft.client.renderer.special.SkullSpecialRenderer (class): members: animation, hasFoil, getExtents, renderType, overlayCoords, Unbaked, model.

net.minecraft.client.renderer.specialclass85 linesclient3.2 KB

Implements

API Surface (3)

void submit(final PoseStack poseStack, final SubmitNodeCollector submitNodeCollector, final int lightCoords, final int overlayCoords, final boolean hasFoil, final int outlineColor)
void getExtents(final Consumer<Vector3fc> output)
MapCodec<SkullSpecialRenderer.Unbaked> type()

Fields & Constants (8)

model
animation
renderType
poseStack
submitNodeCollector
lightCoords
overlayCoords
hasFoil

String literals (5)

"kind"
"texture"
"animation"
"textures/entity/"
".png"

Full Source

SkullSpecialRenderer.java85 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.special;
2
3
import com.mojang.blaze3d.vertex.PoseStack;
4
import com.mojang.serialization.Codec;
5
import com.mojang.serialization.MapCodec;
6
import com.mojang.serialization.codecs.RecordCodecBuilder;
7
import java.util.Optional;
8
import java.util.function.Consumer;
9
import net.fabricmc.api.EnvType;
10
import net.fabricmc.api.Environment;
11
import net.minecraft.client.model.object.skull.SkullModelBase;
12
import net.minecraft.client.renderer.SubmitNodeCollector;
13
import net.minecraft.client.renderer.blockentity.SkullBlockRenderer;
14
import net.minecraft.client.renderer.rendertype.RenderType;
15
import net.minecraft.resources.Identifier;
16
import net.minecraft.world.level.block.SkullBlock.Type;
17
import org.joml.Vector3fc;
18
import org.jspecify.annotations.Nullable;
19
20
@Environment(EnvType.CLIENT)
21
public class SkullSpecialRenderer implements NoDataSpecialModelRenderer {
22
	private final SkullModelBase model;
23
	private final float animation;
24
	private final RenderType renderType;
25
26
	public SkullSpecialRenderer(final SkullModelBase model, final float animation, final RenderType renderType) {
27
		this.model = model;
28
		this.animation = animation;
29
		this.renderType = renderType;
30
	}
31
32
	@Override
33
	public void submit(
34
		final PoseStack poseStack,
35
		final SubmitNodeCollector submitNodeCollector,
36
		final int lightCoords,
37
		final int overlayCoords,
38
		final boolean hasFoil,
39
		final int outlineColor
40
	) {
41
		SkullBlockRenderer.submitSkull(this.animation, poseStack, submitNodeCollector, lightCoords, this.model, this.renderType, outlineColor, null);
42
	}
43
44
	@Override
45
	public void getExtents(final Consumer<Vector3fc> output) {
46
		PoseStack poseStack = new PoseStack();
47
		SkullModelBase.State modelState = new SkullModelBase.State();
48
		modelState.animationPos = this.animation;
49
		this.model.setupAnim(modelState);
50
		this.model.root().getExtentsForGui(poseStack, output);
51
	}
52
53
	@Environment(EnvType.CLIENT)
54
	public record Unbaked(Type kind, Optional<Identifier> textureOverride, float animation) implements NoDataSpecialModelRenderer.Unbaked {
55
		public static final MapCodec<SkullSpecialRenderer.Unbaked> MAP_CODEC = RecordCodecBuilder.mapCodec(
56
			i -> i.group(
57
					Type.CODEC.fieldOf("kind").forGetter(SkullSpecialRenderer.Unbaked::kind),
58
					Identifier.CODEC.optionalFieldOf("texture").forGetter(SkullSpecialRenderer.Unbaked::textureOverride),
59
					Codec.FLOAT.optionalFieldOf("animation", 0.0F).forGetter(SkullSpecialRenderer.Unbaked::animation)
60
				)
61
				.apply(i, SkullSpecialRenderer.Unbaked::new)
62
		);
63
64
		public Unbaked(final Type kind) {
65
			this(kind, Optional.empty(), 0.0F);
66
		}
67
68
		@Override
69
		public MapCodec<SkullSpecialRenderer.Unbaked> type() {
70
			return MAP_CODEC;
71
		}
72
73
		public @Nullable SkullSpecialRenderer bake(final SpecialModelRenderer.BakingContext context) {
74
			SkullModelBase model = SkullBlockRenderer.createModel(context.entityModelSet(), this.kind);
75
			Identifier textureOverride = this.textureOverride.<Identifier>map(t -> t.withPath(p -> "textures/entity/" + p + ".png")).orElse(null);
76
			if (model == null) {
77
				return null;
78
			}
79
80
			RenderType renderType = SkullBlockRenderer.getSkullRenderType(this.kind, textureOverride);
81
			return new SkullSpecialRenderer(model, this.animation, renderType);
82
		}
83
	}
84
}
85

Decompiled Minecraft 26.3 source of SkullSpecialRenderer (net/minecraft/client/renderer/special/SkullSpecialRenderer.java) with Mojang official mappings, stored verbatim on the site.