diff --git a/build.gradle.kts b/build.gradle.kts index ea0396fb..97a1e8a7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,6 +13,12 @@ allprojects { version = "${rootProject.libs.versions.minecraft.get()}+01" repositories { + mavenCentral { + name = "MavenCentralLWJGL" + mavenContent { + includeGroup("org.lwjgl") + } + } // mirrors: // - https://maven.minecraftforge.net/ // - https://maven.neoforged.net/ diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 25c6591f..1396e291 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,10 +3,10 @@ format = { version = "1.1" } [versions] indra = "3.1.3" -minecraft = "26.1.1" -fabricLoader = "0.18.6" -fabricApi = "0.145.4+26.1.1" -modmenu = "18.0.0-alpha.8" +minecraft = "26.2" +fabricLoader = "0.19.3" +fabricApi = "0.152.1+26.2" +modmenu = "20.0.0-beta.2" viafabricplus = "4.5.1" vineflower = "1.11.2" cuiProtocol = "4.0.3" @@ -30,7 +30,7 @@ curseForgeGradle = { id = "net.darkhax.curseforgegradle", version = "1.1.26" } indra-git = { id = "net.kyori.indra.git", version.ref = "indra" } indra-spotlessLicenser = { id = "net.kyori.indra.licenser.spotless", version.ref = "indra" } jvmConflictResolution = { id = "org.gradlex.jvm-dependency-conflict-resolution", version = "2.1.2" } -loom = { id = "dev.architectury.loom-no-remap", version = "1.14.471" } +loom = { id = "dev.architectury.loom-no-remap", version = "1.14.476" } minotaur = { id = "com.modrinth.minotaur", version = "2.8.7" } publishGithubRelease = { id = "ca.stellardrift.publish-github-release", version = "0.1.0" } shadow = { id = "com.gradleup.shadow", version = "8.3.5" } @@ -38,13 +38,13 @@ spotless = { id = "com.diffplug.spotless", version = "6.25.0" } versions = { id = "com.github.ben-manes.versions", version = "0.51.0" } [libraries.cuiProtocol-common] -module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-common-mc26.1" +module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-common-mc26.2" version.ref = "cuiProtocol" [libraries.cuiProtocol-fabric] -module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-fabric-mc26.1" +module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-fabric-mc26.2" version.ref = "cuiProtocol" [libraries.cuiProtocol-neoforge] -module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-neoforge-mc26.1" +module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-neoforge-mc26.2" version.ref = "cuiProtocol" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 61285a65..b1b8ef56 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c61a118f..df6a6ad7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,9 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip networkTimeout=10000 +retries=0 +retryBackOffMs=500 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index adff685a..b9bb139f 100755 --- a/gradlew +++ b/gradlew @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. diff --git a/gradlew.bat b/gradlew.bat index e509b2dd..aa5f10b0 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -23,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -51,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -65,7 +65,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line @@ -73,21 +73,10 @@ goto fail @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/config/CUIConfiguration.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/config/CUIConfiguration.java index 5733129f..37607366 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/config/CUIConfiguration.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/config/CUIConfiguration.java @@ -80,7 +80,6 @@ public void write( private boolean debugMode = false; private boolean promiscuous = false; - private boolean compatibilityRenderer = false; private boolean clearAllOnKey = false; private Colour cuboidGridColor = ConfiguredColour.CUBOIDGRID.getDefault(); @@ -136,10 +135,6 @@ public void setPromiscuous(boolean promiscuous) { this.promiscuous = promiscuous; } - public boolean isExperimentalRenderer() { - return this.compatibilityRenderer; - } - public boolean isClearAllOnKey() { return this.clearAllOnKey; } @@ -172,7 +167,6 @@ public static CUIConfiguration create() { configArray.put("debugMode", config.debugMode); configArray.put("promiscuous", config.promiscuous); - configArray.put("compatibilityRenderer", config.compatibilityRenderer); configArray.put("clearAllOnKey", config.clearAllOnKey); configArray.put("cuboidGridColor", config.cuboidGridColor); @@ -208,7 +202,6 @@ public Map getConfigArray() { public void configChanged() { debugMode = (Boolean) configArray.get("debugMode"); promiscuous = (Boolean) configArray.get("promiscuous"); - compatibilityRenderer = (Boolean) configArray.get("compatibilityRenderer"); clearAllOnKey = (Boolean) configArray.get("clearAllOnKey"); cuboidGridColor = (Colour) configArray.get("cuboidGridColor"); @@ -230,7 +223,7 @@ public void configChanged() { public Object getDefaultValue(String text) { return switch (text) { - case "debugMode", "promiscuous", "compatibilityRenderer", "clearAllOnKey" -> false; + case "debugMode", "promiscuous", "clearAllOnKey" -> false; case "cuboidGridColor" -> ConfiguredColour.CUBOIDGRID.getDefault(); case "cuboidEdgeColor" -> ConfiguredColour.CUBOIDBOX.getDefault(); case "cuboidFirstPointColor" -> ConfiguredColour.CUBOIDPOINT1.getDefault(); @@ -272,7 +265,6 @@ public Object getDefaultValue(String text) { return switch (text) { case "debugMode" -> "worldeditcui.options.debugMode"; case "promiscuous" -> "worldeditcui.options.compat.spammy"; - case "compatibilityRenderer" -> "worldeditcui.options.compat.renderer"; case "clearAllOnKey" -> "worldeditcui.options.extra.clearall"; case "cuboidGridColor" -> "worldeditcui.color.cuboidgrid"; case "cuboidEdgeColor" -> "worldeditcui.color.cuboidedge"; diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/event/listeners/CUIListenerWorldRender.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/event/listeners/CUIListenerWorldRender.java index 371214ed..282c2868 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/event/listeners/CUIListenerWorldRender.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/event/listeners/CUIListenerWorldRender.java @@ -10,21 +10,16 @@ package org.enginehub.worldeditcui.event.listeners; import com.mojang.blaze3d.buffers.GpuBufferSlice; -import com.mojang.blaze3d.opengl.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.fog.FogRenderer; import net.minecraft.util.profiling.Profiler; import net.minecraft.util.profiling.ProfilerFiller; import org.enginehub.worldeditcui.WorldEditCUI; -import org.enginehub.worldeditcui.config.CUIConfiguration; -import org.enginehub.worldeditcui.render.BufferBuilderRenderSink; -import org.enginehub.worldeditcui.render.LineStyle; import org.enginehub.worldeditcui.render.PipelineProvider; import org.enginehub.worldeditcui.render.RenderSink; import org.enginehub.worldeditcui.util.Vector3; import org.joml.Matrix4fStack; -import org.lwjgl.opengl.GL32; import java.util.HashSet; import java.util.List; @@ -42,33 +37,23 @@ public class CUIListenerWorldRender private final WorldEditCUI controller; private final Minecraft minecraft; - private final CUIConfiguration configuration; private final CUIRenderContext ctx = new CUIRenderContext(); private final List pipelines; private final Set disabledPipelines = new HashSet<>(); - private boolean experimentalRendererSelected; private PipelineProvider activePipeline; private RenderSink sink; - public CUIListenerWorldRender(final WorldEditCUI controller, final Minecraft minecraft, final CUIConfiguration configuration, final List pipelines) + public CUIListenerWorldRender(final WorldEditCUI controller, final Minecraft minecraft, final List pipelines) { this.controller = controller; this.minecraft = minecraft; - this.configuration = configuration; this.pipelines = List.copyOf(pipelines); - this.experimentalRendererSelected = configuration.isExperimentalRenderer(); } private RenderSink providePipeline() { - final boolean useExperimentalRenderer = this.configuration.isExperimentalRenderer(); - final PipelineProvider preferred = preferredPipeline(); - if (useExperimentalRenderer != this.experimentalRendererSelected) { - this.experimentalRendererSelected = useExperimentalRenderer; - this.disabledPipelines.clear(); - this.activePipeline = null; - this.sink = null; - } else if (this.sink != null && this.activePipeline != null + final PipelineProvider preferred = this.pipelines.getFirst(); + if (this.sink != null && this.activePipeline != null && (this.activePipeline == preferred || !preferred.available() || this.disabledPipelines.contains(preferred.id()))) { return this.sink; } else if (this.sink != null && this.activePipeline != null && this.disabledPipelines.contains(this.activePipeline.id())) { @@ -76,7 +61,7 @@ private RenderSink providePipeline() this.sink = null; } - for (final PipelineProvider pipeline : orderedPipelines()) + for (final PipelineProvider pipeline : this.pipelines) { if (this.disabledPipelines.contains(pipeline.id())) { continue; @@ -108,34 +93,6 @@ private void invalidatePipeline() { this.sink = null; } - private PipelineProvider preferredPipeline() { - return pipelineById(this.configuration.isExperimentalRenderer() ? "vanilla" : "legacy-vanilla"); - } - - private List orderedPipelines() { - if (this.configuration.isExperimentalRenderer()) { - return List.of( - pipelineById("vanilla"), - pipelineById("legacy-vanilla"), - pipelineById("optifine") - ); - } - return List.of( - pipelineById("legacy-vanilla"), - pipelineById("optifine"), - pipelineById("vanilla") - ); - } - - private PipelineProvider pipelineById(final String id) { - for (final PipelineProvider pipeline : this.pipelines) { - if (pipeline.id().equals(id)) { - return pipeline; - } - } - throw new IllegalStateException("Missing pipeline provider " + id); - } - public void onRender(final float partialTicks) { try { final RenderSink sink = this.providePipeline(); @@ -146,19 +103,11 @@ public void onRender(final float partialTicks) { } final ProfilerFiller profiler = Profiler.get(); profiler.push("worldeditcui"); - this.ctx.init(new Vector3(this.minecraft.gameRenderer.getMainCamera().position()), partialTicks, sink); + this.ctx.init(new Vector3(this.minecraft.gameRenderer.mainCamera().position()), partialTicks, sink); final GpuBufferSlice fogStart = RenderSystem.getShaderFog(); RenderSystem.setShaderFog(this.minecraft.gameRenderer.fogRenderer.getBuffer(FogRenderer.FogMode.NONE)); final Matrix4fStack poseStack = RenderSystem.getModelViewStack(); - final boolean legacySink = sink instanceof BufferBuilderRenderSink; poseStack.pushMatrix(); - if (legacySink) { - GlStateManager._enableBlend(); - // RenderSystem.disableTexture(); - GlStateManager._enableDepthTest(); - GlStateManager._depthMask(true); - BufferBuilderRenderSink.LineWidth.set(LineStyle.DEFAULT_WIDTH); - } try { this.controller.renderSelections(this.ctx); @@ -168,11 +117,6 @@ public void onRender(final float partialTicks) { this.invalidatePipeline(); } - if (legacySink) { - GlStateManager._depthFunc(GL32.GL_LEQUAL); - // RenderSystem.enableTexture(); - GlStateManager._disableBlend(); - } poseStack.popMatrix(); RenderSystem.setShaderFog(fogStart); profiler.pop(); diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/fabric/FabricModWorldEditCUI.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/fabric/FabricModWorldEditCUI.java index eb49e856..3ca50639 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/fabric/FabricModWorldEditCUI.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/fabric/FabricModWorldEditCUI.java @@ -29,10 +29,8 @@ import org.enginehub.worldeditcui.config.CUIConfiguration; import org.enginehub.worldeditcui.event.listeners.CUIListenerChannel; import org.enginehub.worldeditcui.event.listeners.CUIListenerWorldRender; -import org.enginehub.worldeditcui.render.LegacyVanillaPipelineProvider; import org.enginehub.worldeditcui.protocol.CUIPacket; import org.enginehub.worldeditcui.protocol.CUIPacketHandler; -import org.enginehub.worldeditcui.render.OptifinePipelineProvider; import org.enginehub.worldeditcui.render.PipelineProvider; import org.enginehub.worldeditcui.render.VanillaPipelineProvider; import org.lwjgl.glfw.GLFW; @@ -59,8 +57,6 @@ public final class FabricModWorldEditCUI implements ModInitializer { private final KeyMapping keyBindChunkBorder = key("chunk", GLFW.GLFW_KEY_UNKNOWN); private static final List RENDER_PIPELINES = List.of( - new OptifinePipelineProvider(), - new LegacyVanillaPipelineProvider(), new VanillaPipelineProvider() ); @@ -124,7 +120,7 @@ private void onTick(final Minecraft mc) { final boolean inGame = mc.player != null; final boolean clock = mc.getDeltaTracker().getGameTimeDeltaPartialTick(false) > 0; - if (inGame && mc.screen == null) { + if (inGame && mc.gui.screen() == null) { while (this.keyBindToggleUI.consumeClick()) { this.visible = !this.visible; } @@ -178,7 +174,7 @@ private void onPluginMessage(final CUIPacket payload, final CUIPacketHandler.Pac public void onGameInitDone(final Minecraft client) { this.controller = new WorldEditCUI(); this.controller.initialise(client); - this.worldRenderListener = new CUIListenerWorldRender(this.controller, client, this.controller.getConfiguration(), RENDER_PIPELINES); + this.worldRenderListener = new CUIListenerWorldRender(this.controller, client, RENDER_PIPELINES); this.channelListener = new CUIListenerChannel(this.controller); } diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/gui/CUIConfigPanel.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/gui/CUIConfigPanel.java index 3715198c..1ed1d2b0 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/gui/CUIConfigPanel.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/gui/CUIConfigPanel.java @@ -43,7 +43,7 @@ protected void init() { this.addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, (button) -> { configuration.configChanged(); assert minecraft != null; - this.minecraft.setScreen(parent); + this.minecraft.gui.setScreen(parent); }).bounds((this.width - BUTTON_DONE_WIDTH) / 2, this.height - (BUTTON_HEIGHT + 7), BUTTON_DONE_WIDTH, BUTTON_HEIGHT).build()); this.configList = CUIConfigList.create(this, this.minecraft); diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/BatchedRenderSink.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/BatchedRenderSink.java index 11630412..1836daa7 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/BatchedRenderSink.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/BatchedRenderSink.java @@ -9,10 +9,10 @@ */ package org.enginehub.worldeditcui.render; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.MeshData; -import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.blaze3d.PrimitiveTopology; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexFormat; +import net.minecraft.client.renderer.StagedVertexBuffer; import org.jetbrains.annotations.Nullable; import org.joml.Vector3f; @@ -27,7 +27,9 @@ private enum Primitive { private @Nullable VariantSet currentVariants; private @Nullable RenderTarget activeTarget; private @Nullable Primitive activePrimitive; - private @Nullable BufferBuilder builder; + private final StagedVertexBuffer vertexBuffer = new StagedVertexBuffer(() -> "WorldEditCUI", 1536); + private @Nullable StagedVertexBuffer.Draw draw; + private @Nullable VertexConsumer builder; private boolean active; private float r = -1f; private float g; @@ -180,11 +182,23 @@ public void flush() { if (this.active) { throw new IllegalStateException("Tried to flush while still active"); } - final MeshData mesh = this.builder.buildOrThrow(); - this.activeTarget.draw(mesh); - this.builder = null; - this.activeTarget = null; - this.activePrimitive = null; + this.vertexBuffer.upload(); + try { + final StagedVertexBuffer.Draw draw = this.draw; + if (draw == null) { + throw new IllegalStateException("No active draw"); + } + final StagedVertexBuffer.ExecuteInfo executeInfo = this.vertexBuffer.getExecuteInfo(draw); + if (executeInfo != null) { + this.activeTarget.draw(executeInfo); + } + } finally { + this.vertexBuffer.endFrame(); + this.draw = null; + this.builder = null; + this.activeTarget = null; + this.activePrimitive = null; + } } private void end(final RenderTarget target, final Primitive primitive) { @@ -205,7 +219,8 @@ private void transitionState(final RenderTarget target, final Primitive primitiv this.flush(); } if (this.activeTarget == null) { - this.builder = Tesselator.getInstance().begin(target.mode(), target.format()); + this.draw = this.vertexBuffer.appendDraw(target.format(), target.primitiveTopology()); + this.builder = this.vertexBuffer.getVertexBuilder(this.draw); this.activeTarget = target; } this.activePrimitive = primitive; @@ -228,24 +243,24 @@ private RenderTarget activeTargetOrThrow() { @FunctionalInterface public interface MeshDrawer { - void draw(MeshData mesh); + void draw(StagedVertexBuffer.ExecuteInfo executeInfo); } public static final class RenderTarget { - private final VertexFormat.Mode mode; + private final PrimitiveTopology primitiveTopology; private final VertexFormat format; private final boolean hasNormals; private final MeshDrawer drawer; - public RenderTarget(final VertexFormat.Mode mode, final VertexFormat format, final MeshDrawer drawer) { - this.mode = mode; + public RenderTarget(final PrimitiveTopology primitiveTopology, final VertexFormat format, final MeshDrawer drawer) { + this.primitiveTopology = primitiveTopology; this.format = format; - this.hasNormals = format.getElementAttributeNames().contains("Normal"); + this.hasNormals = format.contains("Normal"); this.drawer = drawer; } - VertexFormat.Mode mode() { - return this.mode; + PrimitiveTopology primitiveTopology() { + return this.primitiveTopology; } VertexFormat format() { @@ -256,8 +271,8 @@ boolean hasNormals() { return this.hasNormals; } - void draw(final MeshData mesh) { - this.drawer.draw(mesh); + void draw(final StagedVertexBuffer.ExecuteInfo executeInfo) { + this.drawer.draw(executeInfo); } } diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/BufferBuilderRenderSink.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/BufferBuilderRenderSink.java deleted file mode 100644 index f809f128..00000000 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/BufferBuilderRenderSink.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright (c) 2011-2024 WorldEditCUI team and contributors - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.enginehub.worldeditcui.render; - -import com.mojang.blaze3d.opengl.GlConst; -import com.mojang.blaze3d.opengl.GlStateManager; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.Tesselator; -import com.mojang.blaze3d.vertex.VertexFormat; -import org.jetbrains.annotations.Nullable; -import org.joml.Vector3f; -import com.mojang.blaze3d.platform.CompareOp; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL32; - -import java.util.Objects; - -public class BufferBuilderRenderSink implements RenderSink { - - private final RenderType lines; - private final RenderType lineLoop; - private final RenderType quads; - private final Runnable preFlush; - private final Runnable postFlush; - private BufferBuilder builder; - private @Nullable BufferBuilderRenderSink.RenderType activeRenderType; - private boolean active; - private boolean canFlush; - private float r = -1f, g, b, a; - private float loopX, loopY, loopZ; // track previous vertices for lines_loop - private float loopFirstX, loopFirstY, loopFirstZ; // track initial vertices for lines_loop - private boolean canLoop; - - // line state - private float lastLineWidth = -1; - private @Nullable CompareOp lastDepthTest; - - public BufferBuilderRenderSink(final TypeFactory types) { - this(types, () -> {}, () -> {}); - } - - public BufferBuilderRenderSink(final TypeFactory types, final Runnable preFlush, final Runnable postFlush) { - this.lines = types.lines(); - this.lineLoop = types.linesLoop(); - this.quads = types.quads(); - this.preFlush = preFlush; - this.postFlush = postFlush; - } - - public static class LineWidth { - private static final boolean HAS_COMPATIBILITY = (GL11.glGetInteger(GL32.GL_CONTEXT_PROFILE_MASK) & GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0; - private static float lineWidth = GL11.glGetInteger(GL11.GL_LINE_WIDTH); - - public static void set(final float width) { - if (HAS_COMPATIBILITY && lineWidth != width) { - GL11.glLineWidth(width); - } - - lineWidth = width; - } - - } - - @Override - public RenderSink color(final float r, final float g, final float b, final float alpha) { - this.r = r; - this.g = g; - this.b = b; - this.a = alpha; - return this; - } - - @Override - public boolean apply(final LineStyle line, final RenderStyle.RenderType type) { - if (line.renderType.matches(type)) - { - if (line.lineWidth != this.lastLineWidth || line.renderType.depthTest() != this.lastDepthTest) { - this.flush(); - if (this.active && this.activeRenderType != null) { - this.canFlush = true; - this.builder = Tesselator.getInstance().begin(this.activeRenderType.mode, this.activeRenderType.format); - } - LineWidth.set(this.lastLineWidth = line.lineWidth); - GlStateManager._depthFunc(GlConst.toGl(this.lastDepthTest = line.renderType.depthTest())); - } - return true; - } - - return false; - } - - @Override - public RenderSink vertex(final double x, final double y, final double z) { - if (this.r == -1f) { - throw new IllegalStateException("No colour has been set!"); - } - if (!this.active) { - throw new IllegalStateException("Tried to draw when not active"); - } - - final BufferBuilder builder = this.builder; - if (this.activeRenderType == this.lineLoop) { - // duplicate last - if (this.canLoop) { - final Vector3f normal = this.activeRenderType.hasNormals ? this.computeNormal(this.loopX, this.loopY, this.loopZ, x, y, z) : null; - builder.addVertex(this.loopX, this.loopY, this.loopZ).setColor(this.r, this.g, this.b, this.a).setLineWidth(LineWidth.lineWidth); - if (normal != null) { - // we need to compute normals pointing directly towards the screen - builder.setNormal(normal.x(), normal.y(), normal.z()); - } - builder.addVertex((float) x, (float) y, (float) z).setColor(this.r, this.g, this.b, this.a).setLineWidth(LineWidth.lineWidth); - if (normal != null) { - builder.setNormal(normal.x(), normal.y(), normal.z()); - } - } else { - this.loopFirstX = (float) x; - this.loopFirstY = (float) y; - this.loopFirstZ = (float) z; - } - this.loopX = (float) x; - this.loopY = (float) y; - this.loopZ = (float) z; - this.canLoop = true; - } else if (this.activeRenderType == this.lines) { - // we buffer vertices so we can compute normals here - if (this.canLoop) { - final Vector3f normal = this.activeRenderType.hasNormals ? this.computeNormal(this.loopX, this.loopY, this.loopZ, x, y, z) : null; - builder.addVertex(this.loopX, this.loopY, this.loopZ).setColor(this.r, this.g, this.b, this.a).setLineWidth(LineWidth.lineWidth); - if (normal != null) { - builder.setNormal(normal.x(), normal.y(), normal.z()); - } - builder.addVertex((float) x, (float) y, (float) z).setColor(this.r, this.g, this.b, this.a).setLineWidth(LineWidth.lineWidth); - if (normal != null) { - builder.setNormal(normal.x(), normal.y(), normal.z()); - } - this.canLoop = false; - } else { - this.loopX = (float) x; - this.loopY = (float) y; - this.loopZ = (float) z; - this.canLoop = true; - } - } else { - builder.addVertex((float) x, (float) y, (float) z).setColor(this.r, this.g, this.b, this.a).setLineWidth(LineWidth.lineWidth); - } - return this; - } - - private Vector3f computeNormal(final double x0, final double y0, final double z0, final double x1, final double y1, final double z1) { - // we need to compute normals so all drawn planes appear perpendicular to the screen - final double dX = (x1 - x0); - final double dY = (y1 - y0); - final double dZ = (z1 - z0); - final double length = Math.sqrt(dX * dX + dY * dY + dZ * dZ); - final Vector3f normal = new Vector3f((float) (dX / length), (float) (dY / length), (float) (dZ / length)); - // normal.transform(RenderSystem.getModelViewStack().last().normal()); - return normal; - } - - @Override - public RenderSink beginLineLoop() { - this.transitionState(this.lineLoop); - return this; - } - - @Override - public RenderSink endLineLoop() { - this.end(this.lineLoop); - if (this.canLoop) { - this.canLoop = false; - final Vector3f normal = this.activeRenderType.hasNormals ? this.computeNormal(this.loopX, this.loopY, this.loopZ, this.loopFirstX, this.loopFirstY, this.loopFirstZ) : null; - this.builder.addVertex(this.loopX, this.loopY, this.loopZ).setColor(this.r, this.g, this.b, this.a).setLineWidth(LineWidth.lineWidth); - if (normal != null) { - this.builder.setNormal(normal.x(), normal.y(), normal.z()); - } - - this.builder.addVertex(this.loopFirstX, this.loopFirstY, this.loopFirstZ).setColor(this.r, this.g, this.b, this.a).setLineWidth(LineWidth.lineWidth); - if (normal != null) { - this.builder.setNormal(normal.x(), normal.y(), normal.z()); - } - } - return this; - } - - @Override - public RenderSink beginLines() { - this.transitionState(this.lines); - return this; - } - - @Override - public RenderSink endLines() { - this.end(this.lines); - return this; - } - - @Override - public RenderSink beginQuads() { - this.transitionState(this.quads); - return this; - } - - @Override - public RenderSink endQuads() { - this.end(this.quads); - return this; - } - - @Override - public void flush() { - if (!this.canFlush) { - return; - } - if (this.active) { - throw new IllegalStateException("Tried to flush while still active"); - } - this.canFlush = false; - this.preFlush.run(); - try { - if (this.activeRenderType == null) { - throw new IllegalStateException("Active type cannot be null"); - } - this.activeRenderType.type.draw(this.builder.buildOrThrow()); - } finally { - this.postFlush.run(); - this.builder = null; - this.activeRenderType = null; - } - } - - private void end(final RenderType renderType) { - if (!this.active) { - throw new IllegalStateException("Could not exit " + renderType + ", was not active"); - } - if (this.activeRenderType != renderType) { - throw new IllegalStateException("Expected to end state " + renderType + " but was in " + this.activeRenderType); - } - this.active = false; - } - - private void transitionState(final RenderType renderType) { - if (this.active) { - throw new IllegalStateException("Tried to enter new state before previous operation had been completed"); - } - if (this.activeRenderType != null && renderType.mustFlushAfter(this.activeRenderType)) { - this.flush(); - } - if (this.activeRenderType == null || this.activeRenderType.mode != renderType.mode) { - this.canFlush = true; - this.builder = Tesselator.getInstance().begin(renderType.mode, renderType.format); - } - this.activeRenderType = renderType; - this.active = true; - } - - public static class RenderType { - - private final VertexFormat.Mode mode; - private final VertexFormat format; - private final boolean hasNormals; - private final net.minecraft.client.renderer.rendertype.RenderType type; - - public RenderType(final VertexFormat.Mode mode, final VertexFormat format, @Nullable final net.minecraft.client.renderer.rendertype.RenderType renderPipeline) { - this.mode = mode; - this.format = format; - this.hasNormals = format.getElementAttributeNames().contains("Normal"); - this.type = renderPipeline; - } - - VertexFormat.Mode mode() { - return this.mode; - } - - VertexFormat format() { - return this.format; - } - - boolean hasNormals() { - return this.hasNormals; - } - - boolean mustFlushAfter(final RenderType previous) { - return previous.mode != this.mode || !Objects.equals(previous.format, this.format); - } - } - - public interface TypeFactory { - RenderType quads(); - RenderType lines(); - RenderType linesLoop(); - } -} diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/LegacyVanillaPipelineProvider.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/LegacyVanillaPipelineProvider.java deleted file mode 100644 index 1712a4cf..00000000 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/LegacyVanillaPipelineProvider.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2011-2024 WorldEditCUI team and contributors - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.enginehub.worldeditcui.render; - -import com.mojang.blaze3d.pipeline.BlendFunction; -import com.mojang.blaze3d.pipeline.ColorTargetState; -import com.mojang.blaze3d.pipeline.RenderPipeline; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.VertexFormat; -import net.minecraft.client.renderer.RenderPipelines; -import net.minecraft.client.renderer.rendertype.RenderSetup; -import net.minecraft.client.renderer.rendertype.RenderType; -import net.minecraft.client.renderer.rendertype.RenderTypes; - -public final class LegacyVanillaPipelineProvider implements PipelineProvider { - - public static class DefaultTypeFactory implements BufferBuilderRenderSink.TypeFactory { - public static final DefaultTypeFactory INSTANCE = new DefaultTypeFactory(); - private static final RenderSetup QUADS_SETUP = RenderSetup.builder( - RenderPipeline.builder(RenderPipeline.builder(RenderPipelines.MATRICES_PROJECTION_SNIPPET) - .withVertexShader("core/position_color") - .withFragmentShader("core/position_color") - .withColorTargetState(new ColorTargetState(BlendFunction.TRANSLUCENT)) - .withVertexFormat(DefaultVertexFormat.POSITION_COLOR, VertexFormat.Mode.QUADS) - .buildSnippet()) - .withLocation("pipeline/wecui_legacy_quads") - .withCull(false) - .build() - ).bufferSize(1536).sortOnUpload().createRenderSetup(); - private static final BufferBuilderRenderSink.RenderType QUADS = new BufferBuilderRenderSink.RenderType( - VertexFormat.Mode.QUADS, - DefaultVertexFormat.POSITION_COLOR, - RenderType.create("wecui_legacy_quads", QUADS_SETUP) - ); - private static final BufferBuilderRenderSink.RenderType LINES = new BufferBuilderRenderSink.RenderType( - VertexFormat.Mode.LINES, - DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH, - RenderTypes.LINES - ); - private static final BufferBuilderRenderSink.RenderType LINES_LOOP = new BufferBuilderRenderSink.RenderType( - VertexFormat.Mode.LINES, - DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH, - RenderTypes.LINES - ); - - private DefaultTypeFactory() {} - - @Override - public BufferBuilderRenderSink.RenderType quads() { - return QUADS; - } - - @Override - public BufferBuilderRenderSink.RenderType lines() { - return LINES; - } - - @Override - public BufferBuilderRenderSink.RenderType linesLoop() { - return LINES_LOOP; - } - } - - @Override - public String id() { - return "legacy-vanilla"; - } - - @Override - public boolean available() { - return true; - } - - @Override - public RenderSink provide() { - return new BufferBuilderRenderSink(DefaultTypeFactory.INSTANCE); - } -} diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/OptifinePipelineProvider.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/OptifinePipelineProvider.java deleted file mode 100644 index e191ae24..00000000 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/OptifinePipelineProvider.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2011-2024 WorldEditCUI team and contributors - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.enginehub.worldeditcui.render; - -import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.VertexFormat; -import com.mojang.logging.LogUtils; -import org.slf4j.Logger; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; - -/** - * Optifine shaders uses a lot more frame buffers to render the world -- we have to make sure we're on the right one. - * - * @see the shaders documentation - */ -public final class OptifinePipelineProvider implements PipelineProvider { - private static final Logger LOGGER = LogUtils.getLogger(); - private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); - - // For inspection purposes, get the active program - private static final MethodHandle SHADERS_ACTIVE_PROGRAM; - private static final MethodHandle PROGRAM_GET_NAME; - - // Our part of the rendering pipeline -- we want to disable textures (maybe more?) - private static final MethodHandle CONFIG_IS_SHADERS; - private static final MethodHandle SHADERS_BEGIN_LEASH; - private static final MethodHandle SHADERS_END_LEASH; - private static final MethodHandle SHADERS_IS_SHADOW_PASS; - private static boolean optifineDisabled = false; - - static { - MethodHandle configIsShaders = null; - MethodHandle shadersEndLeash = null; - MethodHandle shadersBeginLeash = null; - MethodHandle programGetName = null; - MethodHandle shadersActiveProgram = null; - MethodHandle shadersIsShadowPass = null; - try { - final Class config = Class.forName("net.optifine.Config"); - final Class shaders = Class.forName("net.optifine.shaders.Shaders"); - final Class program = Class.forName("net.optifine.shaders.Program"); - configIsShaders = LOOKUP.findStatic(config, "isShaders", MethodType.methodType(boolean.class)); - shadersEndLeash = LOOKUP.findStatic(shaders, "endLeash", MethodType.methodType(void.class)); - shadersBeginLeash = LOOKUP.findStatic(shaders, "beginLeash", MethodType.methodType(void.class)); - programGetName = LOOKUP.findVirtual(program, "getName", MethodType.methodType(String.class)); - shadersActiveProgram = LOOKUP.findStaticGetter(shaders, "activeProgram", program); - shadersIsShadowPass = LOOKUP.findStaticGetter(shaders, "isShadowPass", boolean.class); - LOGGER.debug("Optifine integration successfully initialized"); - } catch (final IllegalAccessException | ClassNotFoundException | NoSuchMethodException | NoSuchFieldException ignore) { - // Optifine not available - optifineDisabled = true; - } - - CONFIG_IS_SHADERS = configIsShaders; - SHADERS_END_LEASH = shadersEndLeash; - SHADERS_BEGIN_LEASH = shadersBeginLeash; - PROGRAM_GET_NAME = programGetName; - SHADERS_ACTIVE_PROGRAM = shadersActiveProgram; - SHADERS_IS_SHADOW_PASS = shadersIsShadowPass; - } - - static String activeProgram() { - if (SHADERS_ACTIVE_PROGRAM == null || PROGRAM_GET_NAME == null) { - return ""; - } - - try { - return (String) PROGRAM_GET_NAME.invoke(SHADERS_ACTIVE_PROGRAM.invoke()); - } catch (final Throwable ex) { - LOGGER.debug("Failed to query OptiFine shader program", ex); - return ""; - } - } - - public static class OptifineTypeFactory implements BufferBuilderRenderSink.TypeFactory { - public static final OptifineTypeFactory INSTANCE = new OptifineTypeFactory(); - - private static final BufferBuilderRenderSink.RenderType QUADS = new BufferBuilderRenderSink.RenderType(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR, null); - private static final BufferBuilderRenderSink.RenderType LINES = new BufferBuilderRenderSink.RenderType(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR, null); - private static final BufferBuilderRenderSink.RenderType LINES_LOOP = new BufferBuilderRenderSink.RenderType(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR, null); - - private OptifineTypeFactory() {} - - @Override - public BufferBuilderRenderSink.RenderType quads() { - return QUADS; - } - - @Override - public BufferBuilderRenderSink.RenderType lines() { - return LINES; - } - - @Override - public BufferBuilderRenderSink.RenderType linesLoop() { - return LINES_LOOP; - } - } - - @Override - public String id() { - return "optifine"; - } - - @Override - public boolean available() { - return SHADERS_END_LEASH != null && SHADERS_BEGIN_LEASH != null && CONFIG_IS_SHADERS != null && !optifineDisabled; - } - - @Override - public boolean shouldRender() { - try { - return !(boolean) SHADERS_IS_SHADOW_PASS.invoke(); - } catch (final Throwable thr) { - optifineDisabled = true; - LOGGER.error("Failed to render WECUI using OptiFine hooks", thr); - return true; // skip optifine hooks - } - } - - /** - * If optifine is available, modify shader state to do our rendering. - * - *

Otherwise, just perform standard operations.

- */ - @Override - public RenderSink provide() { - return new BufferBuilderRenderSink( - OptifineTypeFactory.INSTANCE, // optifine doesn't use the vanilla shader system? - () -> { - if (!this.available()) { - return; - } - - try { - final boolean shadersEnabled = (boolean) CONFIG_IS_SHADERS.invoke(); - if (shadersEnabled) { - SHADERS_BEGIN_LEASH.invoke(); - } - } catch (final Throwable thr) { - optifineDisabled = true; - LOGGER.error("Failed to render WECUI using OptiFine hooks", thr); - } - }, - () -> { - if (!this.available()) { - return; - } - - try { - final boolean shadersEnabled = (boolean) CONFIG_IS_SHADERS.invoke(); - if (shadersEnabled) { - SHADERS_END_LEASH.invoke(); - } - } catch (final Throwable thr) { - optifineDisabled = true; - LOGGER.error("Failed to render WECUI using OptiFine hooks", thr); - } - } - ); - } -} diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/RenderStyle.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/RenderStyle.java index 6629ee33..df909c6d 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/RenderStyle.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/RenderStyle.java @@ -33,12 +33,12 @@ public enum RenderType /** * Render type for "hidden" lines (under world geometry) */ - HIDDEN(CompareOp.GREATER_THAN_OR_EQUAL), + HIDDEN(CompareOp.GREATER_THAN), /** * Render type for visible lines (over world geometry) */ - VISIBLE(CompareOp.LESS_THAN); + VISIBLE(CompareOp.LESS_THAN_OR_EQUAL); final CompareOp depthTest; diff --git a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/VanillaPipelineProvider.java b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/VanillaPipelineProvider.java index e1cabeba..f1388108 100644 --- a/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/VanillaPipelineProvider.java +++ b/worldeditcui-fabric/src/main/java/org/enginehub/worldeditcui/render/VanillaPipelineProvider.java @@ -9,6 +9,7 @@ */ package org.enginehub.worldeditcui.render; +import com.mojang.blaze3d.PrimitiveTopology; import com.mojang.blaze3d.pipeline.BlendFunction; import com.mojang.blaze3d.pipeline.ColorTargetState; import com.mojang.blaze3d.pipeline.DepthStencilState; @@ -28,26 +29,33 @@ public final class VanillaPipelineProvider implements PipelineProvider { public static class DefaultTypeFactory implements BatchedRenderSink.TypeFactory { public static final DefaultTypeFactory INSTANCE = new DefaultTypeFactory(); - private static final RenderPipeline.Snippet QUADS_SNIPPET = RenderPipeline.builder(RenderPipelines.MATRICES_PROJECTION_SNIPPET) - .withVertexShader("core/position_color") - .withFragmentShader("core/position_color") - .withColorTargetState(new ColorTargetState(BlendFunction.TRANSLUCENT)) - .withVertexFormat(DefaultVertexFormat.POSITION_COLOR, VertexFormat.Mode.QUADS) - .withCull(false) - .withDepthStencilState(DepthStencilState.DEFAULT) - .buildSnippet(); - private static final RenderPipeline.Snippet LINES_SNIPPET = RenderPipeline.builder(RenderPipelines.MATRICES_FOG_SNIPPET, RenderPipelines.GLOBALS_SNIPPET) - .withVertexShader("core/rendertype_lines") - .withFragmentShader("core/rendertype_lines") - .withColorTargetState(new ColorTargetState(BlendFunction.TRANSLUCENT)) - .withCull(false) - .withVertexFormat(DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH, VertexFormat.Mode.LINES) - .withDepthStencilState(DepthStencilState.DEFAULT) - .buildSnippet(); + private static final RenderPipeline.Snippet QUADS_SNIPPET = createSnippet( + RenderPipelines.DEBUG_QUADS, + DefaultVertexFormat.POSITION_COLOR, + PrimitiveTopology.QUADS + ); + private static final RenderPipeline.Snippet LINES_SNIPPET = createSnippet( + RenderPipelines.LINES, + DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH, + PrimitiveTopology.LINES + ); private static final Map VARIANTS = createVariants(); private DefaultTypeFactory() {} + private static RenderPipeline.Snippet createSnippet(final RenderPipeline base, final VertexFormat vertexFormat, final PrimitiveTopology primitiveTopology) { + final RenderPipeline.Builder builder = RenderPipeline.builder() + .withVertexShader(base.getVertexShader()) + .withFragmentShader(base.getFragmentShader()) + .withColorTargetState(new ColorTargetState(BlendFunction.TRANSLUCENT)) + .withCull(false) + .withVertexBinding(0, vertexFormat) + .withPrimitiveTopology(primitiveTopology) + .withDepthStencilState(DepthStencilState.DEFAULT); + base.getBindGroupLayouts().forEach(builder::withBindGroupLayout); + return builder.buildSnippet(); + } + @Override public BatchedRenderSink.VariantSet forStyle(final RenderStyle.RenderType renderType) { final BatchedRenderSink.VariantSet variants = VARIANTS.get(renderType); @@ -78,11 +86,14 @@ private static BatchedRenderSink.RenderTarget createQuadsTarget(final String idS .withDepthStencilState(new DepthStencilState(depthTest, true)) .build(); final RenderSetup setup = RenderSetup.builder(pipeline) - .bufferSize(1536) .sortOnUpload() .createRenderSetup(); final RenderType renderType = RenderType.create("wecui_quads_" + idSuffix, setup); - return new BatchedRenderSink.RenderTarget(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR, renderType::draw); + return new BatchedRenderSink.RenderTarget( + PrimitiveTopology.QUADS, + DefaultVertexFormat.POSITION_COLOR, + executeInfo -> renderType.prepare().drawFromBuffer(executeInfo) + ); } private static BatchedRenderSink.RenderTarget createLinesTarget(final String idSuffix, final CompareOp depthTest) { @@ -92,7 +103,11 @@ private static BatchedRenderSink.RenderTarget createLinesTarget(final String idS .build(); final RenderSetup setup = RenderSetup.builder(pipeline).createRenderSetup(); final RenderType renderType = RenderType.create("wecui_lines_" + idSuffix, setup); - return new BatchedRenderSink.RenderTarget(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH, renderType::draw); + return new BatchedRenderSink.RenderTarget( + PrimitiveTopology.LINES, + DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH, + executeInfo -> renderType.prepare().drawFromBuffer(executeInfo) + ); } } diff --git a/worldeditcui-fabric/src/main/resources/assets/worldeditcui/lang/en_us.json b/worldeditcui-fabric/src/main/resources/assets/worldeditcui/lang/en_us.json index b31e3223..8cb54396 100644 --- a/worldeditcui-fabric/src/main/resources/assets/worldeditcui/lang/en_us.json +++ b/worldeditcui-fabric/src/main/resources/assets/worldeditcui/lang/en_us.json @@ -35,8 +35,6 @@ "worldeditcui.options.compat.title": "Compatibility Options", "worldeditcui.options.compat.spammy": "Promiscuous Mode", "worldeditcui.options.compat.spammy.tooltip": "Enable this option to send /we cui all the time", - "worldeditcui.options.compat.renderer": "Experimental Renderer", - "worldeditcui.options.compat.renderer.tooltip": "Use the new batched vanilla renderer instead of the default legacy renderer", "worldeditcui.options.color.title": "Display Colors", "worldeditcui.options.extra.title": "Advanced Options", "worldeditcui.options.extra.clearall": "Clear displayed regions", diff --git a/worldeditcui-fabric/src/main/resources/fabric.mod.json b/worldeditcui-fabric/src/main/resources/fabric.mod.json index ee814efd..8cac2d18 100644 --- a/worldeditcui-fabric/src/main/resources/fabric.mod.json +++ b/worldeditcui-fabric/src/main/resources/fabric.mod.json @@ -43,10 +43,10 @@ "fabric-screen-api-v1": ">=1.0.9", "fabric-resource-loader-v0": ">=0.4.17", "fabric-transitive-access-wideners-v1": "*", - "minecraft": ">=26.1" + "minecraft": ">=26.2" }, "suggests": { - "worldedit": ">=7.3.17" + "worldedit": ">=7.4.0" }, "breaks": { "worldedit": ["7.3.1", "7.3.2", "7.3.3", "7.3.4-beta-01", "7.3.4", "7.3.5", "7.3.6", "7.3.7", "7.3.8", "7.3.9-beta-01", "7.3.9", "7.3.10-beta-01", "7.3.10", "7.3.11", "7.3.12-beta-01", "7.3.12-beta-02"]