Skip to content

Commit

Permalink
Rotation Lock and Variant Selector HUD overlays can now render like c…
Browse files Browse the repository at this point in the history
…rosshair, improving visibility in bright areas
  • Loading branch information
MehVahdJukaar committed Jun 1, 2024
1 parent 88632bf commit 0701e12
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@

public final class QuarkNetwork {

public static final int PROTOCOL_VERSION = 3;
// bump when you change messages
public static final int PROTOCOL_VERSION = 4;

public static void init() {
ZetaNetworkHandler network = Quark.ZETA.createNetworkHandler(PROTOCOL_VERSION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.List;
import java.util.Objects;

import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.gui.Gui;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11;
Expand Down Expand Up @@ -97,6 +99,9 @@ public class VariantSelectorModule extends ZetaModule {
@Config
public static int hudOffsetY = 0;

@Config(description = "When true, selector arrow will render in same style as crosshair")
public static boolean renderLikeCrossHair = true;

@Config
public static VariantsConfig variants = new VariantsConfig();

Expand Down Expand Up @@ -351,15 +356,19 @@ public void onRender(ZRenderGuiOverlay.Crosshair.Pre event) {
int posX = x - offset - width + hudOffsetX;
int posY = y + hudOffsetY;

if(!showSimpleHud) {
if( !showSimpleHud) {
guiGraphics.renderFakeItem(displayLeft, posX, posY);

RenderSystem.enableBlend();
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 0.75F);

if(renderLikeCrossHair) {
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ONE_MINUS_DST_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1);
}else{
RenderSystem.defaultBlendFunc();
RenderSystem.setShaderColor(0.8f, 0.8f, 0.8f, 0.7f);
}
guiGraphics.blit(ClientUtil.GENERAL_ICONS, posX + 8, posY, 0, 141, 22, 15, 256, 256);
RenderSystem.defaultBlendFunc();

posX += width * 2;
} else {
Expand All @@ -368,7 +377,6 @@ public void onRender(ZRenderGuiOverlay.Crosshair.Pre event) {
if(alignHudToHotbar) {
RenderSystem.enableBlend();
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
if(enableGreenTint)
RenderSystem.setShaderColor(0.5F, 1.0F, 0.5F, 1.0F);
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Objects;
import java.util.UUID;

import com.mojang.blaze3d.platform.GlStateManager;
import org.lwjgl.opengl.GL11;
import org.violetmoon.quark.api.IRotationLockable;
import org.violetmoon.quark.base.Quark;
Expand All @@ -16,6 +17,7 @@
import org.violetmoon.zeta.client.event.load.ZKeyMapping;
import org.violetmoon.zeta.client.event.play.ZInput;
import org.violetmoon.zeta.client.event.play.ZRenderGuiOverlay;
import org.violetmoon.zeta.config.Config;
import org.violetmoon.zeta.event.bus.LoadEvent;
import org.violetmoon.zeta.event.bus.PlayEvent;
import org.violetmoon.zeta.event.load.ZConfigChanged;
Expand Down Expand Up @@ -59,6 +61,9 @@ public class LockRotationModule extends ZetaModule {

private static final HashMap<UUID, LockProfile> lockProfiles = new HashMap<>();

@Config(description = "When true, selector arrow will render in same style as crosshair")
public static boolean renderLikeCrossHair = true;

@LoadEvent
public final void configChanged(ZConfigChanged event) {
lockProfiles.clear();
Expand Down Expand Up @@ -254,9 +259,13 @@ public void onHUDRender(ZRenderGuiOverlay.Crosshair.Post event) {
GuiGraphics guiGraphics = event.getGuiGraphics();

RenderSystem.enableBlend();
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 0.5F);
if(renderLikeCrossHair) {
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ONE_MINUS_DST_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1);
}else{
RenderSystem.defaultBlendFunc();
RenderSystem.setShaderColor(1, 1, 1, 0.5f);
}

Window window = event.getWindow();
int x = window.getGuiScaledWidth() / 2 + 20;
Expand All @@ -266,8 +275,6 @@ public void onHUDRender(ZRenderGuiOverlay.Crosshair.Post event) {
if(clientProfile.half > -1)
guiGraphics.blit(ClientUtil.GENERAL_ICONS, x + 16, y, clientProfile.half * 16, 79, 16, 16, 256, 256);

RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);

}
}
}
Expand Down
Binary file modified src/main/resources/assets/quark/textures/gui/general_icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0701e12

Please sign in to comment.