Skip to content

Commit

Permalink
feat: add alternative divination rod render method from 1.45
Browse files Browse the repository at this point in the history
Adds setting occultism-client.toml#visual.useAlternativeDivinationRodRenderer

Closes #866
  • Loading branch information
klikli-dev committed Dec 21, 2022
1 parent b8d651e commit d9640c6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ public class OccultismRenderType extends RenderType {
.createCompositeState(false));


public static final RenderType OVERLAY_LINES_ALTERNATIVE = create("overlay_lines_alternative", DefaultVertexFormat.POSITION_COLOR_NORMAL, VertexFormat.Mode.LINES,
256, false, false, RenderType.CompositeState.builder()
.setShaderState(RENDERTYPE_LINES_SHADER)
.setLineState(new LineStateShard(OptionalDouble.empty()))
.setLayeringState(VIEW_OFFSET_Z_LAYERING)
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
.setDepthTestState(NO_DEPTH_TEST)
.setOutputState(OutputStateShard.ITEM_ENTITY_TARGET)
.setCullState(NO_CULL)
.setWriteMaskState(COLOR_DEPTH_WRITE)
.createCompositeState(false));


public OccultismRenderType(String name, VertexFormat vertexFormat, VertexFormat.Mode drawMode, int bufferSize,
boolean useDelegate, boolean needsSorting, Runnable setupTaskIn,
Runnable clearTaskIn) {
Expand All @@ -54,4 +67,8 @@ public OccultismRenderType(String name, VertexFormat vertexFormat, VertexFormat.
public static RenderType overlayLines() {
return OVERLAY_LINES;
}

public static RenderType overlayLinesAlternative() {
return OVERLAY_LINES_ALTERNATIVE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package com.github.klikli_dev.occultism.client.render;

import com.github.klikli_dev.occultism.Occultism;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
Expand Down Expand Up @@ -85,7 +86,12 @@ public void RenderLevelLastEvent(RenderLevelStageEvent event) {
}

protected void renderSelectedBlocks(RenderLevelStageEvent event) {
if (event.getStage() != Stage.AFTER_PARTICLES)
var useAltRenderer = Occultism.CLIENT_CONFIG.visuals.useAlternativeDivinationRodRenderer.get();

if (!useAltRenderer && event.getStage() != Stage.AFTER_PARTICLES)
return;

if (useAltRenderer && event.getStage() != Stage.AFTER_TRANSLUCENT_BLOCKS)
return;

if (!this.selectedBlocks.isEmpty()) {
Expand All @@ -102,7 +108,7 @@ protected void renderSelectedBlocks(RenderLevelStageEvent event) {

PoseStack matrixStack = event.getPoseStack();
MultiBufferSource.BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource();
VertexConsumer builder = buffer.getBuffer(OccultismRenderType.overlayLines());
VertexConsumer builder = buffer.getBuffer(useAltRenderer ? OccultismRenderType.overlayLinesAlternative() : OccultismRenderType.overlayLines());
matrixStack.pushPose();

var camera = Minecraft.getInstance().gameRenderer.getMainCamera();
Expand All @@ -119,7 +125,7 @@ protected void renderSelectedBlocks(RenderLevelStageEvent event) {

matrixStack.popPose();
RenderSystem.disableDepthTest();
buffer.endBatch(OccultismRenderType.overlayLines());
buffer.endBatch(useAltRenderer ? OccultismRenderType.overlayLinesAlternative() : OccultismRenderType.overlayLines());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public OccultismClientConfig() {
public static class VisualSettings {
public final BooleanValue disableDemonsDreamShaders;
public final BooleanValue disableHolidayTheming;
public final BooleanValue useAlternativeDivinationRodRenderer;

public VisualSettings(ForgeConfigSpec.Builder builder) {
builder.comment("Visual Settings").push("visual");
Expand All @@ -50,6 +51,10 @@ public VisualSettings(ForgeConfigSpec.Builder builder) {
.define("disableDemonsDreamShaders", false);
this.disableHolidayTheming = builder.comment("Disables holiday themed visual content such as familiar skins.")
.define("disableHolidayTheming", false);
this.useAlternativeDivinationRodRenderer = builder.comment(
"When true the old divination rod selected block renderer will be used.",
"May work for some people that do not see selected block outlines when using the divination rod.")
.define("useAlternativeDivinationRodRenderer", false);
builder.pop();
}
}
Expand Down

0 comments on commit d9640c6

Please sign in to comment.