Font Texture Crash Fix on Splash Screen (#2169)

This commit is contained in:
KAMKEEL authored and GitHub committed 2026-09-29 19:18:16 -07:00
1 parent 9705722469
commit fa71eda3db
3 files changed
+24 -1

No files matched your search

@@ -16,6 +16,7 @@ import com.gtnewhorizons.angelica.glsm.hooks.GLSMConfig;
import com.gtnewhorizons.angelica.glsm.streaming.PersistentStreamingBuffer;
import com.gtnewhorizons.angelica.glsm.streaming.StreamingUploader;
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
import com.gtnewhorizons.angelica.mixins.interfaces.FontRendererAccessor;
import com.gtnewhorizons.angelica.rendering.tesr.BatchDrawDefaults;
import com.gtnewhorizons.angelica.rendering.tesr.ModelPartBatcher;
import com.gtnewhorizons.angelica.rendering.tesr.TesrBatchRenderer;
@@ -28,6 +29,7 @@ import net.coderbot.iris.layer.GbufferPrograms;
import net.coderbot.iris.pipeline.DeferredWorldRenderingPipeline;
import net.coderbot.iris.pipeline.PipelineManager;
import net.coderbot.iris.uniforms.CapturedRenderingState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.MathHelper;
@@ -401,6 +403,18 @@ public class BatchingFontRenderer {
private static final int LAYER_BACKGROUND = -1;
private static final int LAYER_DEFAULT = 0;
/**
* FML's splash font renderer draws before the texture manager exists and binds its own
* font texture, so let it bind and read the id back.
*/
private int textureFor(FontProvider fontProvider, char chr) {
if (fontProvider instanceof FontProviderCustom || Minecraft.getMinecraft().getTextureManager() != null) {
return fontProvider.getTexture(chr);
}
((FontRendererAccessor) underlying).angelica$bindTexture(locationFontTexture);
return GLStateManager.getBoundTextureForServerState();
}
private void pushDrawCmd(int startIdx, int idxCount, int texture, boolean isUnicode) {
pushDrawCmd(startIdx, idxCount, texture, isUnicode, LAYER_DEFAULT);
}
@@ -1456,7 +1470,7 @@ public class BatchingFontRenderer {
final float shadowOffset = fontProvider.getShadowOffset();
final int shadowCopies = FontConfig.shadowCopies;
final int boldCopies = FontConfig.boldCopies;
final int texture = fontProvider.getTexture(chr);
final int texture = textureFor(fontProvider, chr);
// Wave: Y offset via sine wave
float renderY = heightNorth;
@@ -1,10 +1,13 @@
package com.gtnewhorizons.angelica.mixins.interfaces;
import com.gtnewhorizons.angelica.client.font.BatchingFontRenderer;
import net.minecraft.util.ResourceLocation;
public interface FontRendererAccessor {
int angelica$drawStringBatched(String text, int x, int y, int argb, boolean dropShadow);
BatchingFontRenderer angelica$getBatcher();
void angelica$bindTexture(ResourceLocation location);
}
@@ -111,6 +111,9 @@ public abstract class MixinFontRenderer implements FontRendererAccessor, IFontPa
@Shadow
protected abstract String bidiReorder(String p_147647_1_);
@Shadow(remap = false)
protected abstract void bindTexture(ResourceLocation location);
@Unique
public BatchingFontRenderer angelica$batcher;
@@ -188,6 +191,9 @@ public abstract class MixinFontRenderer implements FontRendererAccessor, IFontPa
return angelica$batcher;
}
@Override
public void angelica$bindTexture(ResourceLocation location) { this.bindTexture(location); }
@Inject(method = "getCharWidth", at = @At("HEAD"), cancellable = true)
public void getCharWidth(char c, CallbackInfoReturnable<Integer> cir) {
cir.setReturnValue((int) angelica$getBatcher().getCharWidthFine(c));