Fix debug overlay text not rendering.

This commit is contained in:
LexManos committed 2023-09-11 11:36:45 -07:00
1 parent 52eca96fdc
commit 9291b865c7
8 files changed
+126 -103

No files matched your search

+14 -5
View File
@@ -165,9 +165,9 @@ subprojects {
tasks.withType(Javadoc).configureEach {
options.tags = [
'apiNote:a:<em>API Note:</em>',
'implSpec:a:<em>Implementation Requirements:</em>',
'implNote:a:<em>Implementation Note:</em>'
'apiNote:a:<em>API Note:</em>',
'implSpec:a:<em>Implementation Requirements:</em>',
'implNote:a:<em>Implementation Note:</em>'
]
options.addStringOption('Xdoclint:all,-missing', '-public')
}
@@ -267,6 +267,11 @@ project(':clean') {
}
}
}
eclipse.classpath.file.whenMerged {
// Disable optional warnings on the minecraft decompiled source code. It just muddies the warning window and hides warnings in our own codebase
def src = entries.find { it.path == 'src/main/java' }
src.entryAttributes['ignore_optional_problems'] = 'true'
}
}
def sharedDeps = {
@@ -602,8 +607,12 @@ project(':forge') {
}
}
}
//Eclipse adds the sourcesets twice, once where we tell it to, once in the projects folder. No idea why. So delete them
eclipse.classpath.file.whenMerged { cls -> cls.entries.removeIf { e -> e instanceof SourceFolder && e.path.startsWith('src/') && !e.path.startsWith('src/main/') } }
eclipse.classpath.file.whenMerged {
// Disable optional warnings on the minecraft decompiled source code. It just muddies the warning window and hides warnings in our own codebase
def src = entries.find { it.path == 'src/main/java' }
src.entryAttributes['ignore_optional_problems'] = 'true'
}
ext {
SPEC_VERSION = gradleutils.gitInfo.tag
@@ -1,5 +1,14 @@
--- a/net/minecraft/client/gui/Gui.java
+++ b/net/minecraft/client/gui/Gui.java
@@ -130,7 +_,7 @@
public float f_92980_ = 1.0F;
protected int f_92993_;
protected ItemStack f_92994_ = ItemStack.f_41583_;
- protected final DebugScreenOverlay f_291320_;
+ protected DebugScreenOverlay f_291320_;
protected final SubtitleOverlay f_92996_;
protected final SpectatorGui f_92997_;
protected final PlayerTabOverlay f_92998_;
@@ -453,6 +_,8 @@
for(MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) {
@@ -13,6 +13,75 @@
private final SampleLogger f_291039_ = new SampleLogger();
private final SampleLogger f_291524_ = new SampleLogger();
private final SampleLogger f_290653_ = new SampleLogger();
@@ -120,14 +_,18 @@
this.f_94035_ = null;
}
- public void m_94056_(GuiGraphics p_281427_) {
- this.f_94030_.m_91307_().m_6180_("debug");
+ protected void update() {
Entity entity = this.f_94030_.m_91288_();
this.f_94032_ = entity.m_19907_(20.0D, 0.0F, false);
this.f_94033_ = entity.m_19907_(20.0D, 0.0F, true);
- p_281427_.m_286007_(() -> {
- this.m_280186_(p_281427_);
- this.m_280532_(p_281427_);
+ }
+
+ protected void drawText(GuiGraphics p_281427_) {
+ this.m_280186_(p_281427_);
+ this.m_280532_(p_281427_);
+ }
+
+ protected void drawFPSCharts(GuiGraphics p_281427_) {
if (this.f_290551_) {
int i = p_281427_.m_280182_();
int j = i / 2;
@@ -137,7 +_,9 @@
this.f_291179_.m_293623_(p_281427_, i - k, k);
}
}
+ }
+ protected void drawNetworkCharts(GuiGraphics p_281427_) {
if (this.f_291005_) {
int l = p_281427_.m_280182_();
int i1 = l / 2;
@@ -148,17 +_,32 @@
int j1 = this.f_291349_.m_295014_(i1);
this.f_291349_.m_293623_(p_281427_, l - j1, j1);
}
+ }
+
+ public void m_94056_(GuiGraphics p_281427_) {
+ this.f_94030_.m_91307_().m_6180_("debug");
+ this.update();
+ p_281427_.m_286007_(() -> {
+ this.drawText(p_281427_);
+ this.drawFPSCharts(p_281427_);
+ this.drawNetworkCharts(p_281427_);
});
this.f_94030_.m_91307_().m_7238_();
}
- protected void m_280186_(GuiGraphics p_281525_) {
- List<String> list = this.m_94075_();
+ protected List<String> getOverlayHelp() {
+ List<String> list = Lists.newArrayList();
list.add("");
boolean flag = this.f_94030_.m_91092_() != null;
list.add("Debug charts: [F3+1] Profiler " + (this.f_291871_ ? "visible" : "hidden") + "; [F3+2] " + (flag ? "FPS + TPS " : "FPS ") + (this.f_290551_ ? "visible" : "hidden") + "; [F3+3] " + (!this.f_94030_.m_91090_() ? "Bandwidth + Ping" : "Ping") + (this.f_291005_ ? " visible" : " hidden"));
list.add("For help: press F3 + Q");
+ return list;
+ }
+
+ protected void m_280186_(GuiGraphics p_281525_) {
+ List<String> list = this.m_94075_();
+ list.addAll(this.getOverlayHelp());
this.m_286013_(p_281525_, list, true);
}
@@ -430,6 +_,7 @@
list.add("");
list.add(ChatFormatting.UNDERLINE + "Targeted Entity");
@@ -64,22 +64,6 @@
Class<? extends SocketChannel> oclass;
EventLoopGroup eventloopgroup;
if (Epoll.isAvailable() && p_290035_) {
@@ -465,7 +_,14 @@
PacketFlow packetflow = p_265104_.m_178539_();
AttributeKey<ConnectionProtocol.CodecData<?>> attributekey = m_295397_(p_265104_);
AttributeKey<ConnectionProtocol.CodecData<?>> attributekey1 = m_295397_(packetflow);
- p_265436_.addLast("splitter", new Varint21FrameDecoder(p_299297_)).addLast("decoder", new PacketDecoder(attributekey)).addLast("prepender", new Varint21LengthFieldPrepender()).addLast("encoder", new PacketEncoder(attributekey1)).addLast("unbundler", new PacketBundleUnpacker(attributekey1)).addLast("bundler", new PacketBundlePacker(attributekey));
+ p_265436_
+ .addLast("splitter", new Varint21FrameDecoder(p_299297_))
+ .addLast("decoder", new PacketDecoder(attributekey))
+ .addLast("prepender", new Varint21LengthFieldPrepender())
+ .addLast("encoder", new PacketEncoder(attributekey1))
+ .addLast("unbundler", new PacketBundleUnpacker(attributekey1))
+ .addLast("bundler", new PacketBundlePacker(attributekey)
+ );
}
public void m_295611_(ChannelPipeline p_300754_) {
@@ -485,6 +_,7 @@
public static Connection m_129493_(SocketAddress p_129494_) {
@@ -9,7 +9,6 @@ import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.DebugScreenOverlay;
@@ -61,13 +60,9 @@ public class ForgeGui extends Gui {
public int leftHeight = 39;
public int rightHeight = 39;
private Font font = null;
private final ForgeDebugScreenOverlay debugOverlay;
public ForgeGui(Minecraft mc) {
super(mc, mc.getItemRenderer());
debugOverlay = new ForgeDebugScreenOverlay(mc);
this.debugOverlay = new OverlayAccess(mc);
}
public Minecraft getMinecraft() {
@@ -101,8 +96,6 @@ public class ForgeGui extends Gui {
if (MinecraftForge.EVENT_BUS.post(new RenderGuiEvent.Pre(minecraft.getWindow(), guiGraphics, partialTick)))
return;
font = minecraft.font;
this.random.setSeed(tickCount * 312871L);
GuiOverlayManager.getOverlays().forEach(entry -> {
@@ -361,47 +354,28 @@ public class ForgeGui extends Gui {
listR.add(I18n.get("demo.remainingTime", StringUtil.formatTickDuration((int) (120500L - time))));
}
if (debugOverlay.showDebugScreen()) {
debugOverlay.update();
listL.addAll(debugOverlay.getLeft());
listR.addAll(debugOverlay.getRight());
var forgeOverlay = (OverlayAccess)debugOverlay;
if (forgeOverlay.showDebugScreen()) {
forgeOverlay.update();
listL.addAll(forgeOverlay.getGameInformation());
listL.addAll(forgeOverlay.getOverlayHelp());
listR.addAll(forgeOverlay.getSystemInformation());
}
var event = new CustomizeGuiOverlayEvent.DebugText(minecraft.getWindow(), guiGraphics, minecraft.getFrameTime(), listL, listR);
MinecraftForge.EVENT_BUS.post(event);
int top = 2;
for (String msg : listL) {
if (msg != null && !msg.isEmpty()) {
guiGraphics.fill(1, top - 1, 2 + font.width(msg) + 1, top + font.lineHeight - 1, -1873784752);
guiGraphics.drawString(font, msg, 2, top, 14737632, false);
}
top += font.lineHeight;
}
top = 2;
for (String msg : listR) {
if (msg != null && !msg.isEmpty()) {
int w = font.width(msg);
int left = width - 2 - w;
guiGraphics.fill(left - 1, top - 1, left + w + 1, top + font.lineHeight - 1, -1873784752);
guiGraphics.drawString(font, msg, left, top, 14737632, false);
}
top += font.lineHeight;
}
forgeOverlay.renderLines(guiGraphics, listL, true);
forgeOverlay.renderLines(guiGraphics, listR, false);
minecraft.getProfiler().pop();
}
protected void renderFPSGraph(GuiGraphics guiGraphics) {
if (debugOverlay.showDebugScreen())
this.debugOverlay.render(guiGraphics);
((OverlayAccess)this.debugOverlay).drawFPSCharts(guiGraphics);
}
@Override
public void clearCache() {
super.clearCache();
this.debugOverlay.clearChunkCache();
protected void renderNetworkGraph(GuiGraphics guiGraphics) {
if (debugOverlay.showDebugScreen())
((OverlayAccess)this.debugOverlay).drawNetworkCharts(guiGraphics);
}
protected void renderRecordOverlay(int width, int height, float partialTick, GuiGraphics guiGraphics) {
@@ -421,9 +395,9 @@ public class ForgeGui extends Gui {
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
int color = (animateOverlayMessageColor ? Mth.hsvToRgb(hue / 50.0F, 0.7F, 0.6F) & WHITE : WHITE);
int messageWidth = font.width(overlayMessageString);
drawBackdrop(guiGraphics, font, -4, messageWidth, 16777215 | (opacity << 24));
guiGraphics.drawString(font, overlayMessageString.getVisualOrderText(), -messageWidth / 2, -4, color | (opacity << 24));
int messageWidth = getFont().width(overlayMessageString);
drawBackdrop(guiGraphics, getFont(), -4, messageWidth, 16777215 | (opacity << 24));
guiGraphics.drawString(getFont(), overlayMessageString.getVisualOrderText(), -messageWidth / 2, -4, color | (opacity << 24));
RenderSystem.disableBlend();
guiGraphics.pose().popPose();
}
@@ -454,12 +428,12 @@ public class ForgeGui extends Gui {
guiGraphics.pose().pushPose();
guiGraphics.pose().scale(4.0F, 4.0F, 4.0F);
int l = opacity << 24 & -16777216;
guiGraphics.drawString(this.font, this.title.getVisualOrderText(), -this.getFont().width(this.title) / 2, -10, 16777215 | l, true);
guiGraphics.drawString(this.getFont(), this.title.getVisualOrderText(), -this.getFont().width(this.title) / 2, -10, 16777215 | l, true);
guiGraphics.pose().popPose();
if (this.subtitle != null) {
guiGraphics.pose().pushPose();
guiGraphics.pose().scale(2.0F, 2.0F, 2.0F);
guiGraphics.drawString(this.font, this.subtitle.getVisualOrderText(), -this.getFont().width(this.subtitle) / 2, 5, 16777215 | l, true);
guiGraphics.drawString(this.getFont(), this.subtitle.getVisualOrderText(), -this.getFont().width(this.subtitle) / 2, 5, 16777215 | l, true);
guiGraphics.pose().popPose();
}
RenderSystem.disableBlend();
@@ -546,41 +520,15 @@ public class ForgeGui extends Gui {
MinecraftForge.EVENT_BUS.post(new RenderGuiOverlayEvent.Post(minecraft.getWindow(), guiGraphics, minecraft.getFrameTime(), overlay));
}
private static class ForgeDebugScreenOverlay extends DebugScreenOverlay {
private final Minecraft mc;
private ForgeDebugScreenOverlay(Minecraft mc) {
super(mc);
this.mc = mc;
}
public void update() {
Entity entity = this.mc.getCameraEntity();
this.block = entity.pick(rayTraceDistance, 0.0F, false);
this.liquid = entity.pick(rayTraceDistance, 0.0F, true);
}
@Override
protected void drawGameInformation(GuiGraphics guiGraphics) {
// Replicate the depth test state "leak" caused by the text that is rendered here in vanilla
// being flushed when the graphs start drawing (PR #9539)
RenderSystem.disableDepthTest();
}
@Override
protected void drawSystemInformation(GuiGraphics guiGraphics) {}
private List<String> getLeft() {
List<String> ret = this.getGameInformation();
ret.add("");
boolean flag = this.mc.getSingleplayerServer() != null;
ret.add("Debug: Pie [shift]: " + (this.renderProfilerChart ? "visible" : "hidden") + (flag ? " FPS + TPS" : " FPS") + " [alt]: " + (this.renderFpsCharts ? "visible" : "hidden"));
ret.add("For help: press F3 + Q");
return ret;
}
private List<String> getRight() {
return this.getSystemInformation();
}
// An access to protected methods in this class.
private static class OverlayAccess extends DebugScreenOverlay {
private OverlayAccess(Minecraft mc) { super(mc); }
@Override protected void drawFPSCharts(GuiGraphics gfx) { super.drawFPSCharts(gfx); }
@Override protected void drawNetworkCharts(GuiGraphics gfx) { super.drawNetworkCharts(gfx); }
@Override protected void update() { super.update(); }
@Override protected List<String> getOverlayHelp() { return super.getOverlayHelp(); }
@Override protected List<String> getGameInformation() { return super.getGameInformation(); }
@Override protected List<String> getSystemInformation(){ return super.getSystemInformation(); }
@Override protected void renderLines(GuiGraphics gfx, List<String> lines, boolean leftAlign) { super.renderLines(gfx, lines, leftAlign); }
}
}
@@ -14,7 +14,6 @@ import net.minecraftforge.client.event.RegisterGuiOverlaysEvent;
* @see RegisterGuiOverlaysEvent
*/
@FunctionalInterface
public interface IGuiOverlay
{
public interface IGuiOverlay {
void render(ForgeGui gui, GuiGraphics guiGraphics, float partialTick, int screenWidth, int screenHeight);
}
@@ -164,6 +164,10 @@ public enum VanillaGuiOverlay {
gui.renderFPSGraph(guiGraphics);
}),
NETWORK_GRAPH("network_graph", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
gui.renderNetworkGraph(guiGraphics);
}),
RECORD_OVERLAY("record_overlay", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
if (!gui.getMinecraft().options.hideGui)
gui.renderRecordOverlay(screenWidth, screenHeight, partialTick, guiGraphics);
@@ -98,6 +98,7 @@ protected net.minecraft.client.gui.components.AbstractSliderButton m_293290_()Ln
protected net.minecraft.client.gui.components.AbstractSliderButton m_293389_()Lnet/minecraft/resources/ResourceLocation; # getSprite
protected net.minecraft.client.gui.components.DebugScreenOverlay f_94032_ # block
protected net.minecraft.client.gui.components.DebugScreenOverlay f_94033_ # liquid
protected net.minecraft.client.gui.components.DebugScreenOverlay m_286013_(Lnet/minecraft/client/gui/GuiGraphics;Ljava/util/List;Z)V # renderLines
public net.minecraft.client.gui.screens.MenuScreens m_96206_(Lnet/minecraft/world/inventory/MenuType;Lnet/minecraft/client/gui/screens/MenuScreens$ScreenConstructor;)V # register
public net.minecraft.client.gui.screens.MenuScreens$ScreenConstructor
public net.minecraft.client.gui.screens.Screen f_169369_ # renderables