37
37
@ Environment (EnvType .CLIENT )
38
38
public abstract class LiminalQuadRenderer {
39
39
40
- public List <Runnable > renderQueue = Lists .newArrayList ();
40
+ public List <Runnable > heldItemRenderQueue = Lists .newArrayList ();
41
+
42
+ public List <Runnable > itemRenderQueue = Lists .newArrayList ();
41
43
42
44
public abstract void renderQuad (BakedQuad quad , BufferBuilder bufferBuilder , Matrix4f matrix , Camera camera , World world , MatrixStack matrices , List <Pair <BakedQuad , Optional <Direction >>> quads );
43
45
44
46
public void renderQuads (List <Pair <BakedQuad , Optional <Direction >>> quads , World world , BlockPos pos , BlockState state , MatrixStack matrices , Camera camera ) {
45
- Matrix4f matrix = new MatrixStack ().peek ().getPositionMatrix ().copy ();
46
-
47
- // Stationize
48
- matrix .multiply (Vec3f .NEGATIVE_Y .getDegreesQuaternion (180 ));
49
- matrix .multiply (Vec3f .NEGATIVE_Y .getDegreesQuaternion (camera .getYaw ()));
50
- matrix .multiply (Vec3f .NEGATIVE_X .getDegreesQuaternion (camera .getPitch ()));
51
-
52
- matrix .multiply (matrices .peek ().getPositionMatrix ().copy ());
53
-
54
- RenderSystem .disableTexture ();
55
- RenderSystem .depthMask (true );
56
- RenderSystem .enableBlend ();
57
- RenderSystem .enableDepthTest ();
58
- RenderSystem .blendFuncSeparate (GlStateManager .SrcFactor .SRC_ALPHA , GlStateManager .DstFactor .ONE_MINUS_SRC_ALPHA , GlStateManager .SrcFactor .ONE , GlStateManager .DstFactor .ONE_MINUS_SRC_ALPHA );
59
- RenderSystem .polygonOffset (this .renderBehind () ? 3.0F : -3.0F , this .renderBehind () ? 3.0F : -3.0F );
60
- RenderSystem .enablePolygonOffset ();
61
- BufferBuilder bufferBuilder = Tessellator .getInstance ().getBuffer ();
62
- bufferBuilder .begin (drawMode (), vertexFormat ());
47
+ Matrix4f matrix = setupMatrix (matrices , camera );
48
+ BufferBuilder bufferBuilder = setupRenderer (matrices , camera );
63
49
64
50
for (Pair <BakedQuad , Optional <Direction >> quadPair : quads ) {
65
51
BakedQuad quad = quadPair .getFirst ();
@@ -72,23 +58,19 @@ public void renderQuads(List<Pair<BakedQuad, Optional<Direction>>> quads, World
72
58
}
73
59
}
74
60
75
- BufferRenderer .drawWithShader (bufferBuilder .end ());
76
- RenderSystem .polygonOffset (0.0F , 0.0F );
77
- RenderSystem .disablePolygonOffset ();
78
- RenderSystem .disableBlend ();
79
- RenderSystem .enableTexture ();
61
+ this .endRenderer (bufferBuilder , matrices , camera );
80
62
}
81
63
82
64
public void renderItemQuads (List <Pair <BakedQuad , Optional <Direction >>> quads , World world , ItemStack stack , MatrixStack matrices , Camera camera ) {
83
- Matrix4f matrix = new MatrixStack ().peek ().getPositionMatrix ().copy ();
65
+ Matrix4f matrix = setupMatrix (matrices , camera );
66
+ BufferBuilder bufferBuilder = setupRenderer (matrices , camera );
84
67
85
- // Stationize
86
- matrix .multiply (Vec3f .NEGATIVE_Y .getDegreesQuaternion (180 ));
87
- matrix .multiply (Vec3f .NEGATIVE_Y .getDegreesQuaternion (camera .getYaw ()));
88
- matrix .multiply (Vec3f .NEGATIVE_X .getDegreesQuaternion (camera .getPitch ()));
68
+ quads .forEach ((pair ) -> this .renderQuad (pair .getFirst (), bufferBuilder , matrix , camera , world , matrices , quads ));
89
69
90
- matrix .multiply (matrices .peek ().getPositionMatrix ().copy ());
70
+ this .endRenderer (bufferBuilder , matrices , camera );
71
+ }
91
72
73
+ public BufferBuilder setupRenderer (MatrixStack matrices , Camera camera ) {
92
74
RenderSystem .disableTexture ();
93
75
RenderSystem .depthMask (true );
94
76
RenderSystem .enableBlend ();
@@ -99,8 +81,22 @@ public void renderItemQuads(List<Pair<BakedQuad, Optional<Direction>>> quads, Wo
99
81
BufferBuilder bufferBuilder = Tessellator .getInstance ().getBuffer ();
100
82
bufferBuilder .begin (drawMode (), vertexFormat ());
101
83
102
- quads .forEach ((pair ) -> this .renderQuad (pair .getFirst (), bufferBuilder , matrix , camera , world , matrices , quads ));
84
+ return bufferBuilder ;
85
+ }
86
+
87
+ public Matrix4f setupMatrix (MatrixStack matrices , Camera camera ) {
88
+ Matrix4f matrix = new MatrixStack ().peek ().getPositionMatrix ().copy ();
89
+
90
+ // Stationize
91
+ matrix .multiply (Vec3f .NEGATIVE_Y .getDegreesQuaternion (180 ));
92
+ matrix .multiply (Vec3f .NEGATIVE_Y .getDegreesQuaternion (camera .getYaw ()));
93
+ matrix .multiply (Vec3f .NEGATIVE_X .getDegreesQuaternion (camera .getPitch ()));
94
+
95
+ matrix .multiply (matrices .peek ().getPositionMatrix ().copy ());
96
+ return matrix ;
97
+ }
103
98
99
+ public void endRenderer (BufferBuilder bufferBuilder , MatrixStack matrices , Camera camera ) {
104
100
BufferRenderer .drawWithShader (bufferBuilder .end ());
105
101
RenderSystem .polygonOffset (0.0F , 0.0F );
106
102
RenderSystem .disablePolygonOffset ();
0 commit comments