Skip to content

Commit 4f237d3

Browse files
committed
feat(#173): Fix old f3 from showing and improve rendering
1 parent 7cbdb24 commit 4f237d3

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

common/src/main/java/me/cominixo/betterf3/mixin/DebugMixin.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
package me.cominixo.betterf3.mixin;
22

3+
import java.util.Collection;
4+
import java.util.List;
35
import me.cominixo.betterf3.config.GeneralOptions;
46
import net.minecraft.Util;
57
import net.minecraft.client.Minecraft;
68
import net.minecraft.client.gui.GuiGraphics;
79
import 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;
814
import org.spongepowered.asm.mixin.Final;
915
import org.spongepowered.asm.mixin.Mixin;
1016
import org.spongepowered.asm.mixin.Shadow;
17+
import org.spongepowered.asm.mixin.Unique;
1118
import org.spongepowered.asm.mixin.injection.At;
1219
import org.spongepowered.asm.mixin.injection.Inject;
20+
import org.spongepowered.asm.mixin.injection.Redirect;
1321
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1422

1523
import 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;

common/src/main/resources/betterf3.accesswidener

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ accessible field net/minecraft/client/renderer/LevelRenderer viewArea Lnet/minec
66
accessible field net/minecraft/client/gui/components/debug/DebugEntryHeightmap HEIGHTMAP_NAMES Ljava/util/Map;
77
accessible field net/minecraft/client/gui/components/DebugScreenOverlay renderFpsCharts Z
88
accessible field net/minecraft/client/gui/components/DebugScreenOverlay renderProfilerChart Z
9+
accessible method net/minecraft/client/gui/components/debug/DebugScreenEntries register (Ljava/lang/String;Lnet/minecraft/client/gui/components/debug/DebugScreenEntry;)Lnet/minecraft/resources/ResourceLocation;

0 commit comments

Comments
 (0)