Skip to content

Commit a0fd566

Browse files
committed
fix crosshair blending
1 parent 19cad42 commit a0fd566

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CrosshairHud.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.axolotlclient.modules.hud.gui.hud;
22

3+
import com.mojang.blaze3d.platform.GlStateManager;
34
import com.mojang.blaze3d.systems.RenderSystem;
45
import io.github.axolotlclient.config.Color;
56
import io.github.axolotlclient.config.options.BooleanOption;
@@ -18,7 +19,6 @@
1819
import net.minecraft.client.render.Tessellator;
1920
import net.minecraft.client.render.VertexFormats;
2021
import net.minecraft.client.util.math.MatrixStack;
21-
import net.minecraft.client.util.math.Vector3f;
2222
import net.minecraft.entity.LivingEntity;
2323
import net.minecraft.util.Identifier;
2424
import net.minecraft.util.hit.BlockHitResult;
@@ -73,32 +73,36 @@ public void render(MatrixStack matrices) {
7373
DrawPosition pos = new DrawPosition(MinecraftClient.getInstance().getWindow().getScaledWidth()/2 - width/2, MinecraftClient.getInstance().getWindow().getScaledHeight()/2 - height/2);
7474
Color color = getColor();
7575
if (Objects.equals(type.get(), CrosshairOption.DOT.toString())) {
76+
RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.ONE_MINUS_DST_COLOR, GlStateManager.DstFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
7677
fillRect(matrices, new Rectangle(pos.x + (width / 2) - 2, pos.y + (height / 2) - 2, 3, 3), color);
78+
RenderSystem.defaultBlendFunc();
7779
} else if (Objects.equals(type.get(), CrosshairOption.CROSS.toString())) {
80+
RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.ONE_MINUS_DST_COLOR, GlStateManager.DstFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
7881
fillRect(matrices, new Rectangle(pos.x + (width / 2) - 6, pos.y + (height / 2) - 1, 6, 1), color);
7982
fillRect(matrices, new Rectangle(pos.x + (width / 2), pos.y + (height / 2) - 1, 5, 1), color);
8083
fillRect(matrices, new Rectangle(pos.x + (width / 2) - 1, pos.y + (height / 2) - 6, 1, 6), color);
8184
fillRect(matrices, new Rectangle(pos.x + (width / 2) - 1, pos.y + (height / 2), 1, 5), color);
82-
} /*else if (Objects.equals(type.get(), CrosshairOption.DIRECTION.toString())) {
85+
RenderSystem.defaultBlendFunc();
86+
} else if (Objects.equals(type.get(), CrosshairOption.DIRECTION.toString())) {
87+
RenderSystem.pushMatrix();
88+
RenderSystem.translatef((float)(MinecraftClient.getInstance().getWindow().getScaledWidth() / 2), (float)(MinecraftClient.getInstance().getWindow().getScaledHeight() / 2), (float)this.getZOffset());
8389
Camera camera = this.client.gameRenderer.getCamera();
84-
MatrixStack matrixStack = new MatrixStack();
85-
matrixStack.push();
86-
matrixStack.translate(pos.x + (width/2F), pos.y + (height / 2F), 0);
87-
matrixStack.multiply(Vector3f.NEGATIVE_X.getDegreesQuaternion(camera.getPitch()));
88-
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(camera.getYaw()));
89-
matrixStack.scale(-getScale(), -getScale(), getScale());
90-
//RenderSystem.applyModelViewMatrix();
90+
RenderSystem.rotatef(camera.getPitch(), -1.0F, 0.0F, 0.0F);
91+
RenderSystem.rotatef(camera.getYaw(), 0.0F, 1.0F, 0.0F);
92+
RenderSystem.scalef(-1.0F, -1.0F, -1.0F);
9193
RenderSystem.renderCrosshair(10);
92-
matrixStack.pop();
93-
//RenderSystem.applyModelViewMatrix();
94-
}*/ else if (Objects.equals(type.get(), CrosshairOption.TEXTURE.toString())) {
94+
RenderSystem.popMatrix();
95+
} else if (Objects.equals(type.get(), CrosshairOption.TEXTURE.toString())) {
96+
RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.ONE_MINUS_DST_COLOR, GlStateManager.DstFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
97+
9598
MinecraftClient.getInstance().getTextureManager().bindTexture(DrawableHelper.GUI_ICONS_TEXTURE);
9699

97100
// Draw crosshair
98101
RenderSystem.color4f((float) color.getRed() / 255, (float) color.getGreen() / 255, (float) color.getBlue() / 255, (float) color.getAlpha() / 255);
99102
client.inGameHud.drawTexture(matrices, (int) (((client.getWindow().getScaledWidth() / getScale()) - 15) / 2), (int) (((client.getWindow().getScaledHeight() / getScale()) - 15) / 2), 0, 0, 15, 15);
100103
RenderSystem.color4f(1, 1, 1, 1);
101104

105+
RenderSystem.defaultBlendFunc();
102106
// Draw attack indicator
103107
if (this.client.options.attackIndicator == AttackIndicator.CROSSHAIR) {
104108
float progress = this.client.player.getAttackCooldownProgress(0.0F);
@@ -215,10 +219,10 @@ public void addConfigOptions(List<OptionBase<?>> options) {
215219
}
216220

217221
public enum CrosshairOption{
222+
TEXTURE,
218223
CROSS,
219224
DOT,
220-
TEXTURE,
221-
//DIRECTION
225+
DIRECTION
222226
}
223227

224228
}

0 commit comments

Comments
 (0)