11package me .cominixo .betterf3 .mixin ;
22
3+ import java .util .Collection ;
4+ import java .util .List ;
35import me .cominixo .betterf3 .config .GeneralOptions ;
46import net .minecraft .Util ;
57import net .minecraft .client .Minecraft ;
68import net .minecraft .client .gui .GuiGraphics ;
79import net .minecraft .client .gui .components .DebugScreenOverlay ;
10+ import net .minecraft .client .gui .components .debug .DebugEntryNoop ;
11+ import net .minecraft .client .gui .components .debug .DebugScreenEntries ;
12+ import net .minecraft .client .gui .components .debug .DebugScreenEntryList ;
13+ import net .minecraft .resources .ResourceLocation ;
814import org .spongepowered .asm .mixin .Final ;
915import org .spongepowered .asm .mixin .Mixin ;
1016import org .spongepowered .asm .mixin .Shadow ;
17+ import org .spongepowered .asm .mixin .Unique ;
1118import org .spongepowered .asm .mixin .injection .At ;
1219import org .spongepowered .asm .mixin .injection .Inject ;
20+ import org .spongepowered .asm .mixin .injection .Redirect ;
1321import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
1422
1523import static me .cominixo .betterf3 .utils .Utils .START_X_POS ;
@@ -29,6 +37,12 @@ public abstract class DebugMixin {
2937 @ Final
3038 @ Shadow private Minecraft minecraft ;
3139
40+ @ Unique
41+ private static final ResourceLocation BETTERF3_RESOURCE = DebugScreenEntries .register ("betterf3" , new DebugEntryNoop ());
42+
43+ @ Unique
44+ private static final List <ResourceLocation > BETTERF3_LIST = List .of (BETTERF3_RESOURCE );
45+
3246 /**
3347 * Ensures that the TPS graph works.
3448 *
@@ -43,6 +57,22 @@ public void renderBefore(final GuiGraphics context, final CallbackInfo ci) {
4357 context .pose ().pushMatrix ();
4458 }
4559
60+ @ Redirect (method = "render" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/gui/components/debug/DebugScreenEntryList;getCurrentlyEnabled()Ljava/util/Collection;" ))
61+ private Collection <ResourceLocation > currentlyEnabled (final DebugScreenEntryList instance ) {
62+ if (!GeneralOptions .disableMod && this .minecraft .debugEntries .isF3Visible ()) {
63+ return BETTERF3_LIST ;
64+ }
65+ return instance .getCurrentlyEnabled ();
66+ }
67+
68+ @ Redirect (method = "render" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/gui/components/debug/DebugScreenEntryList;isF3Visible()Z" ))
69+ private boolean isF3Visible (final DebugScreenEntryList instance ) {
70+ if (!GeneralOptions .disableMod && this .minecraft .debugEntries .isF3Visible ()) {
71+ return false ;
72+ }
73+ return instance .isF3Visible ();
74+ }
75+
4676 /**
4777 * Modifies the font scale.
4878 *
@@ -63,7 +93,7 @@ public void renderFontScaleBefore(final GuiGraphics context, final CallbackInfo
6393 * @param ci Callback info
6494 */
6595 @ Inject (method = "render" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/util/profiling/ProfilerFiller;push(Ljava/lang/String;)V" ))
66- public void renderAnimation (final GuiGraphics context , final CallbackInfo ci ) {
96+ public synchronized void renderAnimation (final GuiGraphics context , final CallbackInfo ci ) {
6797
6898 if (GeneralOptions .disableMod ) {
6999 return ;
0 commit comments