1010package org .enginehub .worldeditcui .event .listeners ;
1111
1212import com .mojang .blaze3d .buffers .GpuBufferSlice ;
13- import com .mojang .blaze3d .opengl .GlStateManager ;
1413import com .mojang .blaze3d .systems .RenderSystem ;
1514import net .minecraft .client .Minecraft ;
1615import net .minecraft .client .renderer .fog .FogRenderer ;
1716import net .minecraft .util .profiling .Profiler ;
1817import net .minecraft .util .profiling .ProfilerFiller ;
1918import org .enginehub .worldeditcui .WorldEditCUI ;
20- import org .enginehub .worldeditcui .config .CUIConfiguration ;
21- import org .enginehub .worldeditcui .render .BufferBuilderRenderSink ;
22- import org .enginehub .worldeditcui .render .LineStyle ;
2319import org .enginehub .worldeditcui .render .PipelineProvider ;
2420import org .enginehub .worldeditcui .render .RenderSink ;
2521import org .enginehub .worldeditcui .util .Vector3 ;
2622import org .joml .Matrix4fStack ;
27- import org .lwjgl .opengl .GL32 ;
2823
2924import java .util .HashSet ;
3025import java .util .List ;
@@ -42,41 +37,31 @@ public class CUIListenerWorldRender
4237 private final WorldEditCUI controller ;
4338
4439 private final Minecraft minecraft ;
45- private final CUIConfiguration configuration ;
4640 private final CUIRenderContext ctx = new CUIRenderContext ();
4741 private final List <PipelineProvider > pipelines ;
4842 private final Set <String > disabledPipelines = new HashSet <>();
49- private boolean experimentalRendererSelected ;
5043 private PipelineProvider activePipeline ;
5144 private RenderSink sink ;
5245
53- public CUIListenerWorldRender (final WorldEditCUI controller , final Minecraft minecraft , final CUIConfiguration configuration , final List <PipelineProvider > pipelines )
46+ public CUIListenerWorldRender (final WorldEditCUI controller , final Minecraft minecraft , final List <PipelineProvider > pipelines )
5447 {
5548 this .controller = controller ;
5649 this .minecraft = minecraft ;
57- this .configuration = configuration ;
5850 this .pipelines = List .copyOf (pipelines );
59- this .experimentalRendererSelected = configuration .isExperimentalRenderer ();
6051 }
6152
6253 private RenderSink providePipeline ()
6354 {
64- final boolean useExperimentalRenderer = this .configuration .isExperimentalRenderer ();
65- final PipelineProvider preferred = preferredPipeline ();
66- if (useExperimentalRenderer != this .experimentalRendererSelected ) {
67- this .experimentalRendererSelected = useExperimentalRenderer ;
68- this .disabledPipelines .clear ();
69- this .activePipeline = null ;
70- this .sink = null ;
71- } else if (this .sink != null && this .activePipeline != null
55+ final PipelineProvider preferred = this .pipelines .getFirst ();
56+ if (this .sink != null && this .activePipeline != null
7257 && (this .activePipeline == preferred || !preferred .available () || this .disabledPipelines .contains (preferred .id ()))) {
7358 return this .sink ;
7459 } else if (this .sink != null && this .activePipeline != null && this .disabledPipelines .contains (this .activePipeline .id ())) {
7560 this .activePipeline = null ;
7661 this .sink = null ;
7762 }
7863
79- for (final PipelineProvider pipeline : orderedPipelines () )
64+ for (final PipelineProvider pipeline : this . pipelines )
8065 {
8166 if (this .disabledPipelines .contains (pipeline .id ())) {
8267 continue ;
@@ -108,34 +93,6 @@ private void invalidatePipeline() {
10893 this .sink = null ;
10994 }
11095
111- private PipelineProvider preferredPipeline () {
112- return pipelineById (this .configuration .isExperimentalRenderer () ? "vanilla" : "legacy-vanilla" );
113- }
114-
115- private List <PipelineProvider > orderedPipelines () {
116- if (this .configuration .isExperimentalRenderer ()) {
117- return List .of (
118- pipelineById ("vanilla" ),
119- pipelineById ("legacy-vanilla" ),
120- pipelineById ("optifine" )
121- );
122- }
123- return List .of (
124- pipelineById ("legacy-vanilla" ),
125- pipelineById ("optifine" ),
126- pipelineById ("vanilla" )
127- );
128- }
129-
130- private PipelineProvider pipelineById (final String id ) {
131- for (final PipelineProvider pipeline : this .pipelines ) {
132- if (pipeline .id ().equals (id )) {
133- return pipeline ;
134- }
135- }
136- throw new IllegalStateException ("Missing pipeline provider " + id );
137- }
138-
13996 public void onRender (final float partialTicks ) {
14097 try {
14198 final RenderSink sink = this .providePipeline ();
@@ -146,19 +103,11 @@ public void onRender(final float partialTicks) {
146103 }
147104 final ProfilerFiller profiler = Profiler .get ();
148105 profiler .push ("worldeditcui" );
149- this .ctx .init (new Vector3 (this .minecraft .gameRenderer .getMainCamera ().position ()), partialTicks , sink );
106+ this .ctx .init (new Vector3 (this .minecraft .gameRenderer .mainCamera ().position ()), partialTicks , sink );
150107 final GpuBufferSlice fogStart = RenderSystem .getShaderFog ();
151108 RenderSystem .setShaderFog (this .minecraft .gameRenderer .fogRenderer .getBuffer (FogRenderer .FogMode .NONE ));
152109 final Matrix4fStack poseStack = RenderSystem .getModelViewStack ();
153- final boolean legacySink = sink instanceof BufferBuilderRenderSink ;
154110 poseStack .pushMatrix ();
155- if (legacySink ) {
156- GlStateManager ._enableBlend ();
157- // RenderSystem.disableTexture();
158- GlStateManager ._enableDepthTest ();
159- GlStateManager ._depthMask (true );
160- BufferBuilderRenderSink .LineWidth .set (LineStyle .DEFAULT_WIDTH );
161- }
162111
163112 try {
164113 this .controller .renderSelections (this .ctx );
@@ -168,11 +117,6 @@ public void onRender(final float partialTicks) {
168117 this .invalidatePipeline ();
169118 }
170119
171- if (legacySink ) {
172- GlStateManager ._depthFunc (GL32 .GL_LEQUAL );
173- // RenderSystem.enableTexture();
174- GlStateManager ._disableBlend ();
175- }
176120 poseStack .popMatrix ();
177121 RenderSystem .setShaderFog (fogStart );
178122 profiler .pop ();
0 commit comments