Skip to content

Commit

Permalink
Merge pull request #141 from rybot666/1.20.5
Browse files Browse the repository at this point in the history
Remove sign and nametag buffering for good
  • Loading branch information
tr7zw authored Apr 29, 2024
2 parents bea581a + d357bb9 commit f89d7f7
Show file tree
Hide file tree
Showing 22 changed files with 27 additions and 646 deletions.
29 changes: 8 additions & 21 deletions src/main/java/dev/tr7zw/exordium/ExordiumModBase.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
package dev.tr7zw.exordium;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

import dev.tr7zw.exordium.util.DelayedRenderCallManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.blaze3d.pipeline.RenderTarget;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;

import dev.tr7zw.exordium.config.Config;
import dev.tr7zw.exordium.config.ConfigUpgrader;
import dev.tr7zw.exordium.config.ExordiumConfigScreen;
import dev.tr7zw.exordium.util.CustomShaderManager;
import dev.tr7zw.exordium.util.NametagScreenBuffer;
import dev.tr7zw.exordium.util.DelayedRenderCallManager;
import net.minecraft.client.gui.screens.Screen;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

public abstract class ExordiumModBase {

Expand All @@ -31,10 +28,7 @@ public abstract class ExordiumModBase {
public Config config;
private final File settingsFile = new File("config", "exordium.json");
private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
private NametagScreenBuffer nametagScreenBuffer;
private RenderTarget temporaryScreenOverwrite = null;
public static SignSettings signSettings = new SignSettings();
public static NametagSettings nametagSettings = new NametagSettings();
private final DelayedRenderCallManager delayedRenderCallManager = new DelayedRenderCallManager();
private final CustomShaderManager customShaderManager = new CustomShaderManager();
private final BufferManager bufferManager = new BufferManager();
Expand Down Expand Up @@ -72,13 +66,6 @@ public void writeConfig() {
}
}

public NametagScreenBuffer getNameTagScreenBuffer() {
if (nametagScreenBuffer == null) {
nametagScreenBuffer = new NametagScreenBuffer(1000 / config.targetFPSNameTags);
}
return nametagScreenBuffer;
}

public DelayedRenderCallManager getDelayedRenderCallManager() {
return delayedRenderCallManager;
}
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/dev/tr7zw/exordium/NametagSettings.java

This file was deleted.

17 changes: 0 additions & 17 deletions src/main/java/dev/tr7zw/exordium/SignSettings.java

This file was deleted.

3 changes: 0 additions & 3 deletions src/main/java/dev/tr7zw/exordium/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
public class Config {

public int configVersion = 2;
public boolean enableSignBuffering = true;
public int targetFPSNameTags = 60;
public boolean enableNametagScreenBuffering = false;
public int pollRate = 60;
public ComponentSettings chatSettings = new ComponentSettings(true, 20);
public ComponentSettings debugScreenSettings = new ComponentSettings(true, 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ public void initialize() {
Config config = ExordiumModBase.instance.config;
List<OptionInstance<?>> options = new ArrayList<>();

options.add(getOnOffOption("text.exordium.enableSignBuffering", () -> config.enableSignBuffering,
(b) -> config.enableSignBuffering = b));

options.add(getOnOffOption("text.exordium.enableNametagScreenBuffering",
() -> config.enableNametagScreenBuffering, (b) -> config.enableNametagScreenBuffering = b));
options.add(getIntOption("text.exordium.targetFPSNameTags", 30, 80, () -> config.targetFPSNameTags,
(v) -> config.targetFPSNameTags = v));
options.add(getIntOption("text.exordium.pollRate", 20, 240, () -> config.pollRate, (v) -> config.pollRate = v));

addSettings(options, config.chatSettings, "chat", false);
Expand Down
62 changes: 0 additions & 62 deletions src/main/java/dev/tr7zw/exordium/mixin/EntityRendererMixin.java

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/java/dev/tr7zw/exordium/mixin/GameRendererMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,8 @@
@Mixin(value = GameRenderer.class, priority = 500) // needs to be lower to cancel Architectury for REI
public abstract class GameRendererMixin {

@Inject(method = "render(FJZ)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getWindow()Lcom/mojang/blaze3d/platform/Window;", ordinal = 0, shift = Shift.AFTER))
public void postWorldRender(float tickDelta, long startTime, boolean tick, CallbackInfo ci) {
ExordiumModBase.instance.getDelayedRenderCallManager().execRenderCalls();
}

@Redirect(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;resetProjectionMatrix(Lorg/joml/Matrix4f;)V"))
public void renderLevel(GameRenderer gr, Matrix4f matrix4f, float f, long l) {
ExordiumModBase.instance.getDelayedRenderCallManager().setProjectionMatrix(matrix4f);
resetProjectionMatrix(matrix4f);
}

Expand Down
56 changes: 0 additions & 56 deletions src/main/java/dev/tr7zw/exordium/mixin/SignBlockEntityMixin.java

This file was deleted.

57 changes: 0 additions & 57 deletions src/main/java/dev/tr7zw/exordium/mixin/SignRendererMixin.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.mojang.blaze3d.platform.GlStateManager;

public class BlendSateHolder {
public class BlendStateHolder {

private boolean blendStateFetched = false;
private int srcRgb = 1;
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/dev/tr7zw/exordium/util/BufferedComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public abstract class BufferedComponent {
private int reloadCount = 0;
private boolean isRendering = false;
private boolean forceBlending = false;
private BlendSateHolder blendSateHolder = new BlendSateHolder();
private BlendStateHolder blendStateHolder = new BlendStateHolder();

public static Model getModel() {
return model;
Expand Down Expand Up @@ -60,8 +60,9 @@ public boolean render() {
if (!settings.get().enabled) {
return false;
}
if (!blendSateHolder.isBlendStateFetched()) { // the intended blendstate is not know. Skip the buffer logic, let
// it render normally, then grab the expected state
if (!blendStateHolder.isBlendStateFetched()) { // the intended blendstate is not know. Skip the buffer logic,
// let
// it render normally, then grab the expected state
return false;
}
int screenWidth = minecraft.getWindow().getGuiScaledWidth();
Expand All @@ -82,7 +83,7 @@ public boolean render() {
if (!updateFrame) {
// renderTextureOverlay(guiTarget.getColorTextureId());
ExordiumModBase.instance.getDelayedRenderCallManager().addBufferedComponent(this);
blendSateHolder.apply();
blendStateHolder.apply();
return true;
}
guiTarget.setClearColor(0, 0, 0, 0);
Expand All @@ -104,9 +105,9 @@ protected boolean shouldForceRender() {
}

public void renderEnd() {
if (!blendSateHolder.isBlendStateFetched()) {
if (!blendStateHolder.isBlendStateFetched()) {
// capture the expected blend state
blendSateHolder.fetch();
blendStateHolder.fetch();
}
if (!isRendering) {
return;
Expand All @@ -122,7 +123,7 @@ public void renderEnd() {
}
// renderTextureOverlay(guiTarget.getColorTextureId());
ExordiumModBase.instance.getDelayedRenderCallManager().addBufferedComponent(this);
blendSateHolder.apply();
blendStateHolder.apply();
}

private void renderTextureOverlay(int textureid) {
Expand Down
Loading

0 comments on commit f89d7f7

Please sign in to comment.