|
1 | 1 | package io.github.axolotlclient.modules.hud.gui.hud; |
2 | 2 |
|
| 3 | +import com.mojang.blaze3d.platform.GlStateManager; |
3 | 4 | import com.mojang.blaze3d.systems.RenderSystem; |
4 | 5 | import io.github.axolotlclient.config.Color; |
5 | 6 | import io.github.axolotlclient.config.options.BooleanOption; |
|
18 | 19 | import net.minecraft.client.render.Tessellator; |
19 | 20 | import net.minecraft.client.render.VertexFormats; |
20 | 21 | import net.minecraft.client.util.math.MatrixStack; |
21 | | -import net.minecraft.client.util.math.Vector3f; |
22 | 22 | import net.minecraft.entity.LivingEntity; |
23 | 23 | import net.minecraft.util.Identifier; |
24 | 24 | import net.minecraft.util.hit.BlockHitResult; |
@@ -73,32 +73,36 @@ public void render(MatrixStack matrices) { |
73 | 73 | DrawPosition pos = new DrawPosition(MinecraftClient.getInstance().getWindow().getScaledWidth()/2 - width/2, MinecraftClient.getInstance().getWindow().getScaledHeight()/2 - height/2); |
74 | 74 | Color color = getColor(); |
75 | 75 | 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); |
76 | 77 | fillRect(matrices, new Rectangle(pos.x + (width / 2) - 2, pos.y + (height / 2) - 2, 3, 3), color); |
| 78 | + RenderSystem.defaultBlendFunc(); |
77 | 79 | } 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); |
78 | 81 | fillRect(matrices, new Rectangle(pos.x + (width / 2) - 6, pos.y + (height / 2) - 1, 6, 1), color); |
79 | 82 | fillRect(matrices, new Rectangle(pos.x + (width / 2), pos.y + (height / 2) - 1, 5, 1), color); |
80 | 83 | fillRect(matrices, new Rectangle(pos.x + (width / 2) - 1, pos.y + (height / 2) - 6, 1, 6), color); |
81 | 84 | 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()); |
83 | 89 | 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); |
91 | 93 | 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 | + |
95 | 98 | MinecraftClient.getInstance().getTextureManager().bindTexture(DrawableHelper.GUI_ICONS_TEXTURE); |
96 | 99 |
|
97 | 100 | // Draw crosshair |
98 | 101 | RenderSystem.color4f((float) color.getRed() / 255, (float) color.getGreen() / 255, (float) color.getBlue() / 255, (float) color.getAlpha() / 255); |
99 | 102 | client.inGameHud.drawTexture(matrices, (int) (((client.getWindow().getScaledWidth() / getScale()) - 15) / 2), (int) (((client.getWindow().getScaledHeight() / getScale()) - 15) / 2), 0, 0, 15, 15); |
100 | 103 | RenderSystem.color4f(1, 1, 1, 1); |
101 | 104 |
|
| 105 | + RenderSystem.defaultBlendFunc(); |
102 | 106 | // Draw attack indicator |
103 | 107 | if (this.client.options.attackIndicator == AttackIndicator.CROSSHAIR) { |
104 | 108 | float progress = this.client.player.getAttackCooldownProgress(0.0F); |
@@ -215,10 +219,10 @@ public void addConfigOptions(List<OptionBase<?>> options) { |
215 | 219 | } |
216 | 220 |
|
217 | 221 | public enum CrosshairOption{ |
| 222 | + TEXTURE, |
218 | 223 | CROSS, |
219 | 224 | DOT, |
220 | | - TEXTURE, |
221 | | - //DIRECTION |
| 225 | + DIRECTION |
222 | 226 | } |
223 | 227 |
|
224 | 228 | } |
0 commit comments