Skip to content

Commit

Permalink
initial port to 1.21.2-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed Oct 28, 2024
1 parent 3b7bc15 commit dc49ef8
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 31 deletions.
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ format = { version = "1.1" }

[versions]
indra = "3.1.3"
minecraft = "1.21.1"
minecraft = "1.21.2-rc1"
fabricLoader = "0.16.7"
fabricApi = "0.106.0+1.21.1"
modmenu = "11.0.1"
fabricApi = "0.106.0+1.21.2"
modmenu = "12.0.0-beta.1"
viafabricplus = "3.3.0"
vineflower = "1.10.1"

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sequenceOf(
"fabric",
"protocol-common",
"protocol-fabric",
"protocol-neoforge",
// "protocol-neoforge", // not until release
).forEach {
include("worldeditcui-$it")
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.FogRenderer;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.client.renderer.CompiledShaderProgram;
import net.minecraft.client.renderer.FogParameters;
import net.minecraft.util.profiling.Profiler;
import net.minecraft.util.profiling.ProfilerFiller;
import org.enginehub.worldeditcui.WorldEditCUI;
import org.enginehub.worldeditcui.render.LineStyle;
import org.enginehub.worldeditcui.render.PipelineProvider;
Expand Down Expand Up @@ -92,10 +93,11 @@ public void onRender(final float partialTicks) {
// allow ignoring eg. shadow pass
return;
}
Minecraft.getInstance().getProfiler().push("worldeditcui");
final ProfilerFiller profiler = Profiler.get();
profiler.push("worldeditcui");
this.ctx.init(new Vector3(this.minecraft.gameRenderer.getMainCamera().getPosition()), partialTicks, sink);
final float fogStart = RenderSystem.getShaderFogStart();
FogRenderer.setupNoFog();
final FogParameters fogStart = RenderSystem.getShaderFog();
RenderSystem.setShaderFog(FogParameters.NO_FOG);
final Matrix4fStack poseStack = RenderSystem.getModelViewStack();
poseStack.pushMatrix();
RenderSystem.disableCull();
Expand All @@ -106,7 +108,7 @@ public void onRender(final float partialTicks) {
RenderSystem.depthMask(true);
RenderSystem.lineWidth(LineStyle.DEFAULT_WIDTH);

final ShaderInstance oldShader = RenderSystem.getShader();
final CompiledShaderProgram oldShader = RenderSystem.getShader();
try {
this.controller.renderSelections(this.ctx);
this.sink.flush();
Expand All @@ -116,13 +118,13 @@ public void onRender(final float partialTicks) {
}

RenderSystem.depthFunc(GL32.GL_LEQUAL);
RenderSystem.setShader(() -> oldShader);
RenderSystem.setShader(oldShader);
// RenderSystem.enableTexture();
RenderSystem.disableBlend();
RenderSystem.enableCull();
poseStack.popMatrix();
RenderSystem.setShaderFogStart(fogStart);
Minecraft.getInstance().getProfiler().pop();
RenderSystem.setShaderFog(fogStart);
profiler.pop();
} catch (final Exception ex)
{
this.controller.getDebugger().error("Failed while preparing state for WorldEdit CUI", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Matrix4fStack matrixStack() {
}

public void applyMatrices() {
RenderSystem.applyModelViewMatrix();
// RenderSystem.applyModelViewMatrix();
}

public float dt() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void onInitialize() {
try {
RenderSystem.getModelViewStack().pushMatrix();
RenderSystem.getModelViewStack().mul(ctx.matrixStack().last().pose());
RenderSystem.applyModelViewMatrix();
// RenderSystem.applyModelViewMatrix();
ctx.worldRenderer().getTranslucentTarget().bindWrite(false);
this.onPostRenderEntities(ctx);
} finally {
Expand All @@ -113,11 +113,11 @@ public void onInitialize() {
try {
RenderSystem.getModelViewStack().pushMatrix();
RenderSystem.getModelViewStack().mul(ctx.matrixStack().last().pose());
RenderSystem.applyModelViewMatrix();
// RenderSystem.applyModelViewMatrix();
this.onPostRenderEntities(ctx);
} finally {
RenderSystem.getModelViewStack().popMatrix();
RenderSystem.applyModelViewMatrix();
// RenderSystem.applyModelViewMatrix();
}
}
});
Expand All @@ -126,7 +126,7 @@ public void onInitialize() {
private void onTick(final Minecraft mc) {
final CUIConfiguration config = this.controller.getConfiguration();
final boolean inGame = mc.player != null;
final boolean clock = mc.getTimer().getGameTimeDeltaPartialTick(false) > 0;
final boolean clock = mc.getDeltaTracker().getGameTimeDeltaPartialTick(false) > 0;

if (inGame && mc.screen == null) {
while (this.keyBindToggleUI.consumeClick()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
import com.mojang.blaze3d.vertex.BufferUploader;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.client.renderer.ShaderProgram;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3f;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL32;

import java.util.Objects;
import java.util.function.Supplier;

public class BufferBuilderRenderSink implements RenderSink {

Expand Down Expand Up @@ -270,9 +269,9 @@ public static class RenderType {
private final VertexFormat.Mode mode;
private final VertexFormat format;
private final boolean hasNormals;
private final Supplier<ShaderInstance> shader;
private final ShaderProgram shader;

public RenderType(final VertexFormat.Mode mode, final VertexFormat format, final Supplier<ShaderInstance> shader) {
public RenderType(final VertexFormat.Mode mode, final VertexFormat format, final ShaderProgram shader) {
this.mode = mode;
this.format = format;
this.hasNormals = format.getElementAttributeNames().contains("Normal");
Expand All @@ -291,7 +290,7 @@ boolean hasNormals() {
return this.hasNormals;
}

Supplier<ShaderInstance> shader() {
ShaderProgram shader() {
return this.shader;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.logging.LogUtils;
import net.minecraft.client.renderer.CoreShaders;
import net.minecraft.client.renderer.GameRenderer;
import org.slf4j.Logger;

Expand Down Expand Up @@ -86,9 +87,9 @@ static String activeProgram() {
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, GameRenderer::getPositionColorShader);
private static final BufferBuilderRenderSink.RenderType LINES = new BufferBuilderRenderSink.RenderType(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR, GameRenderer::getPositionColorShader);
private static final BufferBuilderRenderSink.RenderType LINES_LOOP = new BufferBuilderRenderSink.RenderType(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR, GameRenderer::getPositionColorShader);
private static final BufferBuilderRenderSink.RenderType QUADS = new BufferBuilderRenderSink.RenderType(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR, CoreShaders.POSITION_COLOR);
private static final BufferBuilderRenderSink.RenderType LINES = new BufferBuilderRenderSink.RenderType(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR, CoreShaders.POSITION_COLOR);
private static final BufferBuilderRenderSink.RenderType LINES_LOOP = new BufferBuilderRenderSink.RenderType(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR, CoreShaders.POSITION_COLOR);

private OptifineTypeFactory() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@

import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.client.renderer.CoreShaders;
import net.minecraft.client.renderer.GameRenderer;

public final class VanillaPipelineProvider implements PipelineProvider {

public static class DefaultTypeFactory implements BufferBuilderRenderSink.TypeFactory {
public static final DefaultTypeFactory INSTANCE = new DefaultTypeFactory();

private static final BufferBuilderRenderSink.RenderType QUADS = new BufferBuilderRenderSink.RenderType(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR, GameRenderer::getPositionColorShader);
private static final BufferBuilderRenderSink.RenderType LINES = new BufferBuilderRenderSink.RenderType(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL, GameRenderer::getRendertypeLinesShader);
private static final BufferBuilderRenderSink.RenderType LINES_LOOP = new BufferBuilderRenderSink.RenderType(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL, GameRenderer::getRendertypeLinesShader);
private static final BufferBuilderRenderSink.RenderType QUADS = new BufferBuilderRenderSink.RenderType(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR, CoreShaders.POSITION_COLOR);
private static final BufferBuilderRenderSink.RenderType LINES = new BufferBuilderRenderSink.RenderType(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL, CoreShaders.RENDERTYPE_LINES);
private static final BufferBuilderRenderSink.RenderType LINES_LOOP = new BufferBuilderRenderSink.RenderType(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL, CoreShaders.RENDERTYPE_LINES);

private DefaultTypeFactory() {}

Expand Down
2 changes: 1 addition & 1 deletion worldeditcui-fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"fabric-lifecycle-events-v1": "^2.0.0",
"fabric-screen-api-v1": ">=1.0.9",
"fabric-resource-loader-v0": ">=0.4.17",
"minecraft": ">=1.20.5"
"minecraft": ">=1.21.1"
},
"suggests": {
"worldedit": ">=7.2.0"
Expand Down

0 comments on commit dc49ef8

Please sign in to comment.