Skip to content

Commit ad47ed7

Browse files
committed
everything
closes #94 closes #117 closes #121 closes #127 closes #110 closes #107 closes #103 closes #125 closes #135 closes #130 closes #129
1 parent de282c2 commit ad47ed7

36 files changed

Lines changed: 2348 additions & 432 deletions

src/main/java/org/polyfrost/evergreenhud/mixins/client/Mixin_InGameHud_SmuggleDrawContext.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//import net.minecraft.client.gui.GuiGraphics;
1010
//? if >= 26
1111
import net.minecraft.client.gui.GuiGraphicsExtractor;
12+
import org.polyfrost.evergreenhud.client.hooks.HudOffscreen;
1213
import org.polyfrost.evergreenhud.client.hooks.SmuggledHudDrawContext;
1314
import org.spongepowered.asm.mixin.Mixin;
1415
import org.spongepowered.asm.mixin.injection.At;
@@ -36,8 +37,9 @@ public class Mixin_InGameHud_SmuggleDrawContext {
3637
DeltaTracker deltaTracker,
3738
CallbackInfo ci
3839
) {
39-
SmuggledHudDrawContext.setSmuggledHudDrawContext(graphics);
4040
SmuggledHudDrawContext.setSmuggledHudPartialTick(deltaTracker.getGameTimeDeltaPartialTick(false));
41+
// offscreen pass must run inside the vanilla HUD render the only phase where a nested GUI render is valid
42+
HudOffscreen.render();
4143
}
4244

4345
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package org.polyfrost.evergreenhud.mixins.client;
2+
3+
//? if >= 1.21.10
4+
import org.polyfrost.evergreenhud.client.hooks.PlayerPreviewOffscreen;
5+
//? if >= 26.1 && < 26.2 {
6+
/*import com.mojang.blaze3d.pipeline.RenderTarget;
7+
import net.minecraft.client.Minecraft;
8+
*///? }
9+
import org.spongepowered.asm.mixin.Mixin;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
import org.spongepowered.asm.mixin.injection.Inject;
12+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
13+
14+
// the offscreen player pass must be recorded while the frame command encoder is still open so the
15+
// hook sits at the last point of the frame each version offers
16+
//? if >= 26.2 {
17+
@Mixin(value = net.minecraft.client.Minecraft.class, priority = 1500)
18+
//? } else if >= 26.1 {
19+
/*@Mixin(RenderTarget.class)
20+
*///? } else if >= 1.21.10 {
21+
/*@Mixin(targets = "org.polyfrost.oneconfig.internal.ui.compose.SkiaCtx", remap = false)
22+
*///? } else {
23+
/*@Mixin(net.minecraft.client.Minecraft.class)
24+
*///? }
25+
public class Mixin_PlayerPreviewPresent {
26+
27+
//? if >= 26.2 {
28+
@Inject(
29+
method = "renderFrame",
30+
at = @At(
31+
value = "INVOKE",
32+
target = "Lcom/mojang/blaze3d/systems/GpuSurface;blitFromTexture(Lcom/mojang/blaze3d/systems/CommandEncoder;Lcom/mojang/blaze3d/textures/GpuTextureView;)V"
33+
)
34+
)
35+
private void evergreenhud$renderPlayerPreview(CallbackInfo ci) {
36+
PlayerPreviewOffscreen.render();
37+
}
38+
//? } else if >= 26.1 {
39+
/*@Inject(method = "blitToScreen", at = @At("HEAD"))
40+
private void evergreenhud$renderPlayerPreview(CallbackInfo ci) {
41+
RenderTarget self = (RenderTarget) (Object) this;
42+
Minecraft client = Minecraft.getInstance();
43+
if (client == null || self != client.getMainRenderTarget()) return;
44+
PlayerPreviewOffscreen.render();
45+
}
46+
*///? } else if >= 1.21.10 {
47+
/*@Inject(method = "draw", at = @At("TAIL"), remap = false)
48+
private void evergreenhud$renderPlayerPreview(CallbackInfo ci) {
49+
PlayerPreviewOffscreen.render();
50+
}
51+
*///? }
52+
53+
}

src/main/kotlin/org/polyfrost/evergreenhud/client/EvergreenHudClient.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket
99
import net.minecraft.world.entity.Entity
1010
import org.polyfrost.evergreenhud.client.config.GlobalConfig
1111
import org.polyfrost.evergreenhud.client.hooks.EnderChestTracker
12+
import org.polyfrost.evergreenhud.client.hooks.HudOffscreen
1213
import org.polyfrost.evergreenhud.client.hud.*
1314
import org.polyfrost.evergreenhud.client.hud.battery.BatteryHud
1415
import org.polyfrost.evergreenhud.client.utils.battery.Battery
@@ -20,6 +21,7 @@ import org.polyfrost.evergreenhud.client.hud.mouse.MouseStrokesHud
2021
import org.polyfrost.evergreenhud.client.hud.potion.PotionEffectsHud
2122
import org.polyfrost.evergreenhud.client.hud.shape.ShapeHud
2223
import org.polyfrost.evergreenhud.client.utils.FrameTimeHelper
24+
import org.polyfrost.evergreenhud.client.utils.shaders.ShaderMod
2325
import org.polyfrost.evergreenhud.client.utils.SaturationTracker
2426
import org.polyfrost.evergreenhud.client.utils.uniqueEntityId
2527
import org.polyfrost.oneconfig.api.event.v1.EventManager
@@ -37,6 +39,7 @@ import java.util.concurrent.ConcurrentLinkedQueue
3739
object EvergreenHudClient : ClientModInitializer {
3840
override fun onInitializeClient() {
3941
FrameTimeHelper.initialize()
42+
HudOffscreen.initialize()
4043
EnderChestTracker.initialize()
4144
SaturationTracker.initialize()
4245
GlobalConfig.preload()
@@ -46,10 +49,10 @@ object EvergreenHudClient : ClientModInitializer {
4649
BiomeHud(), BlockAboveHud(),
4750
ClockHud(), DigitalClockHud(), ComboHud(), CpsHud(),
4851
DayHud(), DirectionHud(), EntityCounterHud(), FacingHud(), FpsHud(),
49-
InGameTimeHud(), InventoryHud(),
52+
InGameTimeHud(), InventoryHud(), ItemCounterHud(),
5053
KeystrokesHud(),
5154
LoreHud(), MemoryHud(), MouseStrokesHud(),
52-
PingHud(), PlaceCountHud(), PlayerPreviewHud(),
55+
PingHud(), PlaceCountHud(), PlayerHeadHud(), PlayerPreviewHud(),
5356
PlayTimeHud(), PositionHud(), PotionEffectsHud(), ReachHud(),
5457
ResourcePackHud(), SaturationHud(), ServerAddressHud(),
5558
ShapeHud(), SpeedHud(), TpsHud(), WeatherHud(),
@@ -58,6 +61,7 @@ object EvergreenHudClient : ClientModInitializer {
5861
huds.forEach(::register)
5962

6063
registerIfSupported(Battery.isSupported(), ::BatteryHud)
64+
registerIfSupported(ShaderMod.isSupported(), ::ShaderHud)
6165

6266
BlockChangeEvent()
6367
BlockPositionChangedEvent()

src/main/kotlin/org/polyfrost/evergreenhud/client/config/GlobalConfig.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package org.polyfrost.evergreenhud.client.config
22

33
import androidx.compose.runtime.snapshots.Snapshot
44
import org.polyfrost.compose.render.PolyColor
5-
import org.polyfrost.evergreenhud.client.hud.HudBackground
65
import org.polyfrost.evergreenhud.client.hud.clock.ClockHud
76
import org.polyfrost.evergreenhud.client.utils.copy
87
import org.polyfrost.oneconfig.api.config.v1.Config
@@ -104,17 +103,20 @@ object GlobalConfig : Config(
104103
"textBold" to { h -> h.textBold = textBold },
105104
"textItalic" to { h -> h.textItalic = textItalic },
106105
"textUnderline" to { h -> h.textUnderline = textUnderline },
106+
// HUDs without a background of their own control their own colors
107107
"showBackground" to { h ->
108-
h.showBackground = showBackground
109-
if (h is HudBackground) h.background = showBackground
108+
if (h.hasBackground()) {
109+
h.showBackground = showBackground
110+
}
110111
},
111112
"bgColor" to { h ->
112-
h.bgColor = bgColor.rawArgb
113-
h.bgChroma = bgColor.chroma
114-
h.bgChromaSpeed = bgColor.chromaSpeed
115-
if (h is HudBackground) h.backgroundColor = bgColor.copy()
113+
if (h.hasBackground()) {
114+
h.bgColor = bgColor.rawArgb
115+
h.bgChroma = bgColor.chroma
116+
h.bgChromaSpeed = bgColor.chromaSpeed
117+
}
116118
},
117-
"bgRadius" to { h -> h.bgRadius = bgRadius },
119+
"bgRadius" to { h -> if (h.hasBackground()) h.bgRadius = bgRadius },
118120
"showShadow" to { h -> h.showShadow = showShadow },
119121
"shadowColor" to { h ->
120122
h.shadowColor = shadowColor.rawArgb

0 commit comments

Comments
 (0)