BakedQuad .java

net.minecraft.client.resources.model.geometry.BakedQuad (record): members: position0, position1, position2, position3, packedUV0, packedUV1, packedUV2.

net.minecraft.client.resources.model.geometryrecord111 linesclient3.8 KB

API Surface (6)

record BakedQuad(Vector3fc position0, Vector3fc position1, Vector3fc position2, Vector3fc position3, long packedUV0, long packedUV1, long packedUV2, long packedUV3, Direction direction, BakedQuad.MaterialInfo materialInfo)
Vector3fc position(final int vertex)
long packedUV(final int vertex)
record MaterialInfo(TextureAtlasSprite sprite, ChunkSectionLayer layer, RenderType itemRenderType, RenderType itemGlintRenderType, RenderType itemGlintSpecialRenderType, int tintIndex, @Nullable Direction shadeDirectionOverride, int lightEmission)
BakedQuad.MaterialInfo of(final Material.Baked material, final Transparency transparency, final int tintIndex, final @Nullable Direction shadeDirectionOverride, final int lightEmission)
boolean isTinted()

Fields & Constants (10)

VERTEX_COUNT
FLAG_TRANSLUCENT
FLAG_ANIMATED
sprite
layer
itemRenderType
itemGlintRenderType
itemGlintSpecialRenderType
tintIndex
shadeDirectionOverride

Full Source

BakedQuad.java111 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.resources.model.geometry;
2
3
import com.mojang.blaze3d.platform.Transparency;
4
import java.lang.annotation.ElementType;
5
import java.lang.annotation.Retention;
6
import java.lang.annotation.RetentionPolicy;
7
import java.lang.annotation.Target;
8
import net.fabricmc.api.EnvType;
9
import net.fabricmc.api.Environment;
10
import net.minecraft.client.renderer.Sheets;
11
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
12
import net.minecraft.client.renderer.rendertype.RenderType;
13
import net.minecraft.client.renderer.texture.TextureAtlas;
14
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
15
import net.minecraft.client.resources.model.sprite.Material;
16
import net.minecraft.core.Direction;
17
import org.joml.Vector3fc;
18
import org.jspecify.annotations.Nullable;
19
20
@Environment(EnvType.CLIENT)
21
public record BakedQuad(
22
	Vector3fc position0,
23
	Vector3fc position1,
24
	Vector3fc position2,
25
	Vector3fc position3,
26
	long packedUV0,
27
	long packedUV1,
28
	long packedUV2,
29
	long packedUV3,
30
	Direction direction,
31
	BakedQuad.MaterialInfo materialInfo
32
) {
33
	public static final int VERTEX_COUNT = 4;
34
	public static final int FLAG_TRANSLUCENT = 1;
35
	public static final int FLAG_ANIMATED = 2;
36
37
	public Vector3fc position(final int vertex) {
38
		return switch (vertex) {
39
			case 0 -> this.position0;
40
			case 1 -> this.position1;
41
			case 2 -> this.position2;
42
			case 3 -> this.position3;
43
			default -> throw new IndexOutOfBoundsException(vertex);
44
		};
45
	}
46
47
	public long packedUV(final int vertex) {
48
		return switch (vertex) {
49
			case 0 -> this.packedUV0;
50
			case 1 -> this.packedUV1;
51
			case 2 -> this.packedUV2;
52
			case 3 -> this.packedUV3;
53
			default -> throw new IndexOutOfBoundsException(vertex);
54
		};
55
	}
56
57
	@Retention(RetentionPolicy.CLASS)
58
	@Target(ElementType.TYPE_USE)
59
	@Environment(EnvType.CLIENT)
60
	public @interface MaterialFlags {
61
	}
62
63
	@Environment(EnvType.CLIENT)
64
	public record MaterialInfo(
65
		TextureAtlasSprite sprite,
66
		ChunkSectionLayer layer,
67
		RenderType itemRenderType,
68
		RenderType itemGlintRenderType,
69
		RenderType itemGlintSpecialRenderType,
70
		int tintIndex,
71
		@Nullable Direction shadeDirectionOverride,
72
		int lightEmission
73
	) {
74
		public static BakedQuad.MaterialInfo of(
75
			final Material.Baked material,
76
			final Transparency transparency,
77
			final int tintIndex,
78
			final @Nullable Direction shadeDirectionOverride,
79
			final int lightEmission
80
		) {
81
			ChunkSectionLayer layer = ChunkSectionLayer.byTransparency(transparency);
82
			RenderType itemRenderType;
83
			RenderType itemGlintRenderType;
84
			RenderType itemGlintSpecialRenderType;
85
			if (material.sprite().atlasLocation().equals(TextureAtlas.LOCATION_BLOCKS)) {
86
				itemRenderType = transparency.hasTranslucent() ? Sheets.translucentBlockItemSheet() : Sheets.cutoutBlockItemSheet();
87
				itemGlintRenderType = transparency.hasTranslucent() ? Sheets.translucentBlockItemGlintSheet() : Sheets.cutoutBlockItemGlintSheet();
88
				itemGlintSpecialRenderType = transparency.hasTranslucent() ? Sheets.translucentBlockItemGlintSpecialSheet() : Sheets.cutoutBlockItemGlintSpecialSheet();
89
			} else {
90
				itemRenderType = transparency.hasTranslucent() ? Sheets.translucentItemSheet() : Sheets.cutoutItemSheet();
91
				itemGlintRenderType = transparency.hasTranslucent() ? Sheets.translucentItemGlintSheet() : Sheets.cutoutItemGlintSheet();
92
				itemGlintSpecialRenderType = transparency.hasTranslucent() ? Sheets.translucentItemGlintSpecialSheet() : Sheets.cutoutItemGlintSpecialSheet();
93
			}
94
95
			return new BakedQuad.MaterialInfo(
96
				material.sprite(), layer, itemRenderType, itemGlintRenderType, itemGlintSpecialRenderType, tintIndex, shadeDirectionOverride, lightEmission
97
			);
98
		}
99
100
		public boolean isTinted() {
101
			return this.tintIndex != -1;
102
		}
103
104
		public @BakedQuad.MaterialFlags int flags() {
105
			int flags = 0;
106
			flags |= this.layer.translucent() ? 1 : 0;
107
			return flags | (this.sprite.contents().isAnimated() ? 2 : 0);
108
		}
109
	}
110
}
111

Decompiled Minecraft 26.3 source of BakedQuad (net/minecraft/client/resources/model/geometry/BakedQuad.java) with Mojang official mappings, stored verbatim on the site.