/
WorldRenderContext.java
142 lines (117 loc) · 4.62 KB
/
WorldRenderContext.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.api.client.rendering.v1;
import org.jetbrains.annotations.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.Frustum;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.profiler.Profiler;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
/**
* Except as noted below, the properties exposed here match the parameters passed to
* {@link WorldRenderer#render(MatrixStack, float, long, boolean, Camera, GameRenderer, LightmapTextureManager, Matrix4f)}.
*/
@Environment(EnvType.CLIENT)
public interface WorldRenderContext {
/**
* The world renderer instance doing the rendering and invoking the event.
*
* @return WorldRenderer instance invoking the event
*/
WorldRenderer worldRenderer();
MatrixStack matrixStack();
float tickDelta();
long limitTime();
boolean blockOutlines();
Camera camera();
GameRenderer gameRenderer();
LightmapTextureManager lightmapTextureManager();
Matrix4f projectionMatrix();
/**
* Convenient access to {WorldRenderer.world}.
*
* @return world renderer's client world instance
*/
ClientWorld world();
/**
* Convenient access to game performance profiler.
*
* @return the active profiler
*/
Profiler profiler();
/**
* Test to know if "fabulous" graphics mode is enabled.
*
* <p>Use this for renders that need to render on top of all translucency to activate or deactivate different
* event handlers to get optimal depth testing results. When fabulous is off, it may be better to render
* during {@code WorldRenderLastCallback} after clouds and weather are drawn. Conversely, when fabulous mode is on,
* it may be better to draw during {@code WorldRenderPostTranslucentCallback}, before the fabulous mode composite
* shader runs, depending on which translucent buffer is being targeted.
*
* @return {@code true} when "fabulous" graphics mode is enabled.
*/
boolean advancedTranslucency();
/**
* The {@code VertexConsumerProvider} instance being used by the world renderer for most non-terrain renders.
* Generally this will be better for most use cases because quads for the same layer can be buffered
* incrementally and then drawn all at once by the world renderer.
*
* <p>IMPORTANT - all vertex coordinates sent to consumers should be relative to the camera to
* be consistent with other quads emitted by the world renderer and other mods. If this isn't
* possible, caller should use a separate "immediate" instance.
*
* <p>This property is {@code null} before {@link WorldRenderEvents#BEFORE_ENTITIES} and after
* {@link WorldRenderEvents#BEFORE_DEBUG_RENDER} because the consumer buffers are not available before or
* drawn after that in vanilla world rendering. Renders that cannot draw in one of the supported events
* must be drawn directly to the frame buffer, preferably in {@link WorldRenderEvents#LAST} to avoid being
* overdrawn or cleared.
*/
@Nullable VertexConsumerProvider consumers();
/**
* View frustum, after it is initialized. Will be {@code null} during
* {@link WorldRenderEvents#START}.
*/
@Nullable Frustum frustum();
/**
* Used in {@code BLOCK_OUTLINE} to convey the parameters normally sent to
* {@code WorldRenderer.drawBlockOutline}.
*/
@Environment(EnvType.CLIENT)
interface BlockOutlineContext {
/**
* @deprecated Use {@link #consumers()} directly.
*/
@Deprecated
VertexConsumer vertexConsumer();
Entity entity();
double cameraX();
double cameraY();
double cameraZ();
BlockPos blockPos();
BlockState blockState();
}
}