-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
4 changed files
with
40 additions
and
0 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
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
35 changes: 35 additions & 0 deletions
35
src/client/java/autumnvn/autumn/mixin/client/PlayerListHudMixin.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package autumnvn.autumn.mixin.client; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import autumnvn.autumn.AutumnClient; | ||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.client.gui.hud.PlayerListHud; | ||
import net.minecraft.client.network.PlayerListEntry; | ||
|
||
@Mixin(PlayerListHud.class) | ||
public class PlayerListHudMixin { | ||
|
||
// PingNumber | ||
@Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) | ||
private void renderLatencyIcon(DrawContext context, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { | ||
if (AutumnClient.options.pingNumber.getValue()) { | ||
int ping = entry.getLatency(); | ||
context.drawTextWithShadow(AutumnClient.client.textRenderer, ping + "ms", x + width - AutumnClient.client.textRenderer.getWidth(ping + "ms"), y, | ||
ping > 1000 ? 0xaa0000 | ||
: ping > 600 ? 0xff5555 | ||
: ping > 300 ? 0xffaa00 | ||
: ping > 150 ? 0xffff55 | ||
: 0x55ff55); | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@ModifyVariable(method = "render", at = @At(value = "STORE"), ordinal = 7) | ||
private int q(int original) { | ||
return AutumnClient.options.pingNumber.getValue() ? original + AutumnClient.client.textRenderer.getWidth("9999ms") : original; | ||
} | ||
} |
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