Skip to content

Commit ad9bf7d

Browse files
committed
Compass improvement
1 parent d1eb684 commit ad9bf7d

File tree

3 files changed

+48
-6
lines changed

3 files changed

+48
-6
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ All credit for the original client goes to Wurst-Imperium and its contributors.
6464
### Waypoints
6565
- Create and save waypoints, with optional automatic death waypoints for all players.
6666
- Manager UI (`.waypoints` or apostrophe key).
67-
- Compass overlay: Show a bar at the top of the screen that shows the waypoint icons, when you're looking at it then it will display its name (Adjustable Position/Transparency and Render Distance)
67+
- Compass overlay: Show a bar at the top of the screen that shows the waypoint icons in your field of view
68+
- Shows names of waypoints you're facing
69+
- Adjustable position and transparency
70+
- Moves out of the way of boss/town bars
71+
- Optional display of player co-ordinates
72+
- Shows death position
6873
- Coordinates overlay: Show your direction and current XYZ position above the compass overlay
6974
- Preset icons
7075
- Features: name, co-ordinates, dimension, icon, visibility, lines, color, copy button, opposite co-ordinates (nether), death pruning.

src/main/java/net/wurstclient/hacks/WaypointsHack.java

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
import net.minecraft.client.font.TextRenderer;
2121
import net.minecraft.client.gui.DrawContext;
22+
import net.minecraft.client.gui.hud.BossBarHud;
23+
import net.minecraft.client.gui.hud.ClientBossBar;
2224
import net.minecraft.client.network.ServerInfo;
2325
import net.minecraft.client.render.VertexConsumerProvider;
2426
import net.minecraft.client.util.math.MatrixStack;
@@ -89,9 +91,9 @@ public final class WaypointsHack extends Hack
8991
ValueDisplay.INTEGER.withLabel(DISTANCE_SLIDER_INFINITE, "Infinite"));
9092
private final SliderSetting compassBackgroundOpacity = new SliderSetting(
9193
"Compass background opacity", 50, 0, 100, 1, ValueDisplay.INTEGER);
92-
// Opacity slider for compass icons and distance/name text (0-100%)
94+
// Opacity slider for compass text (0-100%)
9395
private final SliderSetting compassOpacity = new SliderSetting(
94-
"Compass opacity", 100, 0, 100, 1, ValueDisplay.INTEGER);
96+
"Compass text opacity", 100, 0, 100, 1, ValueDisplay.INTEGER);
9597
private final SliderSetting beaconRenderDistance = new SliderSetting(
9698
"Beacon render distance", 1000, 0, DISTANCE_SLIDER_INFINITE, 1,
9799
ValueDisplay.INTEGER.withLabel(DISTANCE_SLIDER_INFINITE, "Infinite"));
@@ -116,11 +118,11 @@ public WaypointsHack()
116118
addSetting(fadeDistance);
117119
addSetting(compassMode);
118120
addSetting(compassIconRange);
121+
addSetting(beaconRenderDistance);
119122
addSetting(compassXPercent);
120123
addSetting(compassYPercent);
121124
addSetting(showPlayerCoordsAboveCompass);
122125
addSetting(compassOpacity);
123-
addSetting(beaconRenderDistance);
124126
addSetting(compassBackgroundOpacity);
125127
addSetting(maxDeathPositions);
126128
addSetting(chatOnDeath);
@@ -680,7 +682,9 @@ public void onRenderGUI(DrawContext context, float partialTicks)
680682
// Position from settings (percent of screen)
681683
int centerX =
682684
(int)Math.round(sw * (compassXPercent.getValue() / 100.0));
683-
int barY = (int)Math.round(sh * (compassYPercent.getValue() / 100.0));
685+
int baseBarY =
686+
(int)Math.round(sh * (compassYPercent.getValue() / 100.0));
687+
int barY = adjustCompassYForOverlays(context, baseBarY);
684688
int barH = 12; // thinner
685689
int pad = 6;
686690
int halfWidth = Math.min(120, Math.max(60, sw / 4)); // shorter
@@ -826,6 +830,38 @@ public void onRenderGUI(DrawContext context, float partialTicks)
826830
}
827831
}
828832

833+
private int adjustCompassYForOverlays(DrawContext context, int baseY)
834+
{
835+
int adjusted = baseY;
836+
int bossBarBottom = getBossBarBottom(context);
837+
if(bossBarBottom > 0)
838+
{
839+
int margin = showPlayerCoordsAboveCompass.isChecked() ? 10 : 2;
840+
adjusted = Math.max(adjusted, bossBarBottom + margin);
841+
}
842+
return adjusted;
843+
}
844+
845+
private int getBossBarBottom(DrawContext context)
846+
{
847+
if(MC.inGameHud == null)
848+
return 0;
849+
BossBarHud bossBarHud = MC.inGameHud.getBossBarHud();
850+
if(bossBarHud == null || bossBarHud.bossBars.isEmpty())
851+
return 0;
852+
int screenHeight = context.getScaledWindowHeight();
853+
int maxY = screenHeight / 3;
854+
// Vanilla boss bars start at y=12 and advance by 19px per entry.
855+
int y = 12;
856+
for(ClientBossBar bar : bossBarHud.bossBars.values())
857+
{
858+
if(y >= maxY)
859+
return maxY;
860+
y += 10; //default 19px height, but use 10px as it looks better (at least for me)
861+
}
862+
return Math.min(y, maxY);
863+
}
864+
829865
private static String cardinalFromYaw(double yaw)
830866
{
831867
// Normalize yaw to [0,360)

src/main/resources/wurst.accesswidener

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ accessible field net/minecraft/client/toast/ToastManager toastQueue Ljava/util/D
3535
accessible field net/minecraft/entity/Entity movementMultiplier Lnet/minecraft/util/math/Vec3d;
3636
accessible field net/minecraft/entity/LivingEntity equipment Lnet/minecraft/entity/EntityEquipment;
3737
accessible field net/minecraft/entity/LivingEntity jumping Z
38-
accessible field net/minecraft/network/packet/s2c/play/ChunkDeltaUpdateS2CPacket sectionPos Lnet/minecraft/util/math/ChunkSectionPos;
38+
accessible field net/minecraft/network/packet/s2c/play/ChunkDeltaUpdateS2CPacket sectionPos Lnet/minecraft/util/math/ChunkSectionPos;
39+
accessible field net/minecraft/client/gui/hud/BossBarHud bossBars Ljava/util/Map;

0 commit comments

Comments
 (0)