RenderType .java

net.minecraft.client.renderer.rendertype.RenderType (class): members: canConsolidateConsecutiveGeometry, TRANSIENT_BUFFER_SIZE, SMALL_BUFFER_SIZE, outline.

net.minecraft.client.renderer.rendertypeclass130 linesclient4.0 KB

API Surface (13)

RenderType create(final String name, final RenderSetup state)
String toString()
boolean hasBlending()
PreparedRenderType prepare()
VertexFormat format()
PrimitiveTopology primitiveTopology()
Optional<RenderType> outline()
boolean isOutline()
RenderPipeline pipeline()
boolean affectsCrumbling()
boolean canConsolidateConsecutiveGeometry()
boolean sortOnUpload()
boolean forceSolidModelPhase()

Fields & Constants (8)

MEGABYTE
BIG_BUFFER_SIZE
SMALL_BUFFER_SIZE
TRANSIENT_BUFFER_SIZE
state
hasBlending
outline
name

String literals (2)

"Sampler0"
"RenderType["

Full Source

RenderType.java130 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.rendertype;
2
3
import com.mojang.blaze3d.systems.RenderSystem;
4
import com.mojang.blaze3d.systems.ScissorState;
5
import com.mojang.renderpearl.api.buffers.GpuBufferSlice;
6
import com.mojang.renderpearl.api.pipeline.ColorTargetState;
7
import com.mojang.renderpearl.api.pipeline.PrimitiveTopology;
8
import com.mojang.renderpearl.api.pipeline.RenderPipeline;
9
import com.mojang.renderpearl.api.vertex.VertexFormat;
10
import java.util.List;
11
import java.util.Objects;
12
import java.util.Optional;
13
import java.util.function.Consumer;
14
import net.fabricmc.api.EnvType;
15
import net.fabricmc.api.Environment;
16
import net.minecraft.client.Minecraft;
17
import org.joml.Matrix4f;
18
19
/**
20
 * Access widened by fabric-transitive-access-wideners-v1 to accessible
21
 */
22
@Environment(EnvType.CLIENT)
23
public class RenderType {
24
	private static final int MEGABYTE = 1048576;
25
	public static final int BIG_BUFFER_SIZE = 4194304;
26
	public static final int SMALL_BUFFER_SIZE = 786432;
27
	public static final int TRANSIENT_BUFFER_SIZE = 1536;
28
	private final RenderSetup state;
29
	private final boolean hasBlending;
30
	private final Optional<RenderType> outline;
31
	protected final String name;
32
33
	private RenderType(final String name, final RenderSetup state) {
34
		this.name = name;
35
		this.state = state;
36
		this.outline = state.outlineProperty == RenderSetup.OutlineProperty.AFFECTS_OUTLINE
37
			? Optional.ofNullable(state.textures.get(Objects.requireNonNullElse(state.outlineTextureName, "Sampler0")))
38
				.map(texture -> RenderTypes.OUTLINE.apply(texture.location(), state.pipeline.isCull()))
39
			: Optional.empty();
40
		this.hasBlending = this.calculateHasBlending();
41
	}
42
43
	/**
44
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
45
	 */
46
	public static RenderType create(final String name, final RenderSetup state) {
47
		return new RenderType(name, state);
48
	}
49
50
	@Override
51
	public String toString() {
52
		return "RenderType[" + this.name + ":" + this.state + "]";
53
	}
54
55
	public boolean hasBlending() {
56
		return this.hasBlending;
57
	}
58
59
	private boolean calculateHasBlending() {
60
		for (ColorTargetState colorTargetState : this.state.pipeline.getColorTargetStates()) {
61
			if (colorTargetState != null && colorTargetState.blendFunction().isPresent()) {
62
				return true;
63
			}
64
		}
65
66
		return false;
67
	}
68
69
	public PreparedRenderType prepare() {
70
		Minecraft minecraft = Minecraft.getInstance();
71
		List<PreparedRenderType.Texture> textures = this.state
72
			.prepareTextures(
73
				minecraft.getTextureManager(), RenderSystem.getSamplerCache(), minecraft.gameRenderer.overlayTexture().getTextureView(), minecraft.gameRenderer.lightmap()
74
			);
75
		return new PreparedRenderType(
76
			this.name,
77
			this.state.pipeline,
78
			this.state.oitPipelineSet,
79
			this.writeDynamicTransforms(RenderSystem.getModelViewMatrixCopy()),
80
			new ScissorState(RenderSystem.getScissorStateForRenderTypeDraws()),
81
			textures
82
		);
83
	}
84
85
	private GpuBufferSlice writeDynamicTransforms(final Matrix4f modelViewMatrix) {
86
		Consumer<Matrix4f> modelViewModifier = this.state.layeringTransform.getModifier();
87
		if (modelViewModifier != null) {
88
			modelViewModifier.accept(modelViewMatrix);
89
		}
90
91
		return RenderSystem.getDynamicUniforms().writeTransform(modelViewMatrix, this.state.textureTransform.createMatrix());
92
	}
93
94
	public VertexFormat format() {
95
		return this.state.pipeline.getVertexFormatBinding(0);
96
	}
97
98
	public PrimitiveTopology primitiveTopology() {
99
		return this.state.pipeline.getPrimitiveTopology();
100
	}
101
102
	public Optional<RenderType> outline() {
103
		return this.outline;
104
	}
105
106
	public boolean isOutline() {
107
		return this.state.outlineProperty == RenderSetup.OutlineProperty.IS_OUTLINE;
108
	}
109
110
	public RenderPipeline pipeline() {
111
		return this.state.pipeline;
112
	}
113
114
	public boolean affectsCrumbling() {
115
		return this.state.affectsCrumbling;
116
	}
117
118
	public boolean canConsolidateConsecutiveGeometry() {
119
		return !this.primitiveTopology().connectedPrimitives;
120
	}
121
122
	public boolean sortOnUpload() {
123
		return this.state.sortOnUpload;
124
	}
125
126
	public boolean forceSolidModelPhase() {
127
		return this.state.forceSolidModelPhase;
128
	}
129
}
130

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