-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
60 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 31 additions & 12 deletions
43
src/client/java/com/github/outsiderh/doabarrelrollwithhud/renderer/AttitudeIndicator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,59 @@ | ||
package com.github.outsiderh.doabarrelrollwithhud.renderer; | ||
|
||
import static com.github.outsiderh.doabarrelrollwithhud.DoABarrelRollWithHud.fc; | ||
|
||
import com.github.outsiderh.doabarrelrollwithhud.utils.Vector2Int; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
|
||
public class AttitudeIndicator extends Renderer { | ||
private final int groundColor = 0xFFB87325; | ||
private final int skyColor = 0xFF47A6CC; | ||
@Override | ||
public void render(MinecraftClient client, MatrixStack mat) { | ||
int halfSize = (hudEnd.x - hudBegin.x) / 4; | ||
Vector2Int aiBegin = hudCenter.copy().subAndGet(halfSize); | ||
Vector2Int aiEnd = hudCenter.copy().addAndGet(halfSize); | ||
int horizonLength = (int)((float)(aiEnd.x - aiBegin.x) * 0.75f); | ||
float horizonGap = (float)(Math.sqrt((double)(halfSize * halfSize)) / 3f); | ||
enableScissor(aiBegin.x, aiBegin.y, aiEnd.x, aiEnd.y); | ||
mat.push(); | ||
rotate(mat, -fc.roll); | ||
float pitch = -fc.pitch; | ||
float mod = pitch % 10f; | ||
for (int n = (int)(pitch - (pitch < 0 ? mod + 10f : mod)), p = hudCenter.y + (int)((pitch < 0 ? 10f + mod : mod) * 5), c = 0; c < 3; n -= 10, p += 50, ++c) { | ||
drawHorizontalLine(mat, hudCenter.x - 75, hudCenter.x + 75, p, color); | ||
for (int n = (int)(pitch - (pitch < 0 ? mod + 10f : mod)), p = hudCenter.y + (int)((pitch < 0 ? 10f + mod : mod) * (horizonGap / 10f)), c = 0; c < 3; n -= 10, p += horizonGap, ++c) { | ||
int numToShow = Math.abs(n); | ||
if (numToShow > 90) { | ||
numToShow = 180 - numToShow; | ||
} | ||
drawText(client.textRenderer, mat, String.valueOf(numToShow), color, new Vector2Int(hudCenter.x - 75, p), TextAlign.Right); | ||
drawText(client.textRenderer, mat, String.valueOf(numToShow), color, new Vector2Int(hudCenter.x + 75, p), TextAlign.Left); | ||
int length = horizonLength / (numToShow == 0 ? 2 : 4); | ||
int posL = hudCenter.x - length; | ||
int posR = hudCenter.x + length; | ||
int color = n < 0 ? groundColor : n > 0 ? skyColor : Renderer.color; | ||
drawHorizontalLine(mat, posL, posR, p, color); | ||
drawVerticalLine(mat, posL, p, p + 3, color); | ||
drawVerticalLine(mat, posR, p, p + 3, color); | ||
drawText(client.textRenderer, mat, String.valueOf(numToShow), color, new Vector2Int(posL, p), TextAlign.Right); | ||
drawText(client.textRenderer, mat, String.valueOf(numToShow), color, new Vector2Int(posR + 2, p), TextAlign.Left); | ||
} | ||
for (int n = (int)(pitch + (pitch < 0 ? -mod : 10f - mod)), p = hudCenter.y - (int)((pitch < 0 ? -mod : 10 - mod) * 5), c = 0; c < 3; n += 10, p -= 50, ++c) { | ||
drawHorizontalLine(mat, hudCenter.x - 75, hudCenter.x + 75, p, color); | ||
for (int n = (int)(pitch + (pitch < 0 ? -mod : 10f - mod)), p = hudCenter.y - (int)((pitch < 0 ? -mod : 10 - mod) * (horizonGap / 10)), c = 0; c < 3; n += 10, p -= horizonGap, ++c) { | ||
int numToShow = Math.abs(n); | ||
if (numToShow > 90) { | ||
numToShow = 180 - numToShow; | ||
} | ||
drawText(client.textRenderer, mat, String.valueOf(numToShow), color, new Vector2Int(hudCenter.x - 75, p), TextAlign.Right); | ||
drawText(client.textRenderer, mat, String.valueOf(numToShow), color, new Vector2Int(hudCenter.x + 75, p), TextAlign.Left); | ||
int length = horizonLength / (numToShow == 0 ? 2 : 4); | ||
int posL = hudCenter.x - length; | ||
int posR = hudCenter.x + length; | ||
int color = n < 0 ? groundColor : n > 0 ? skyColor : Renderer.color; | ||
drawHorizontalLine(mat, posL, posR, p, color); | ||
drawVerticalLine(mat, posL, p, p + 3, color); | ||
drawVerticalLine(mat, posR, p, p + 3, color); | ||
drawText(client.textRenderer, mat, String.valueOf(numToShow), color, new Vector2Int(posL, p), TextAlign.Right); | ||
drawText(client.textRenderer, mat, String.valueOf(numToShow), color, new Vector2Int(posR + 2, p), TextAlign.Left); | ||
} | ||
mat.pop(); | ||
disableScissor(); | ||
drawDot(mat, color, hudCenter); | ||
drawHorizontalLine(mat, hudCenter.x - 1, hudCenter.x - 9, hudCenter.y, color); | ||
drawHorizontalLine(mat, hudCenter.x + 1, hudCenter.x + 9, hudCenter.y, color); | ||
drawHorizontalLine(mat, hudCenter.x - 2, hudCenter.x - 4, hudCenter.y, color); | ||
drawHorizontalLine(mat, hudCenter.x + 2, hudCenter.x + 4, hudCenter.y, color); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
src/client/java/com/github/outsiderh/doabarrelrollwithhud/renderer/YawIndicator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
package com.github.outsiderh.doabarrelrollwithhud.renderer; | ||
|
||
import static com.github.outsiderh.doabarrelrollwithhud.DoABarrelRollWithHud.fc; | ||
|
||
import com.github.outsiderh.doabarrelrollwithhud.utils.Vector2Int; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
|
||
public class YawIndicator extends Renderer { | ||
@Override | ||
public void render(MinecraftClient client, MatrixStack mat) { | ||
|
||
int leftEdge = hudCenter.x - 100; | ||
int rightEdge = hudCenter.x + 100; | ||
drawHorizontalLine(mat, leftEdge, rightEdge, hudBegin.y, color); | ||
drawText(client.textRenderer, mat, String.format("%.0f", fc.yaw), color, new Vector2Int(hudCenter.x, hudBegin.y), TextAlign.Down); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/main/resources/assets/doabarrelrollwithhud/lang/zh_cn.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"text.autoconfig": "z" | ||
"text.autoconfig.doabarrelrollwithhud.title": "设置", | ||
"text.autoconfig.doabarrelrollwithhud.option.speedUnit": "速度单位" | ||
} |