Fix splash issues (#2200)

This commit is contained in:
Death Fuel authored and GitHub committed 2026-10-03 11:42:57 -07:00
1 parent c97fb7004f
commit 75a0278138
4 files changed
+46 -43

No files matched your search

@@ -15,7 +15,6 @@ 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,7 +27,6 @@ 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;
@@ -61,6 +59,8 @@ import static com.gtnewhorizons.angelica.client.font.ColorCodeUtils.FORMATTING_C
import static com.gtnewhorizons.angelica.client.font.ColorCodeUtils.GRADIENT_PAYLOAD;
import static com.gtnewhorizons.angelica.client.font.ColorCodeUtils.SECTION_X_LENGTH;
import static com.gtnewhorizons.angelica.client.font.ColorCodeUtils.SECTION_X_PAYLOAD;
import static com.gtnewhorizons.angelica.client.font.FontStrategist.INVALID_TEXTURE;
import static com.gtnewhorizons.angelica.client.font.FontStrategist.bindIntTexture;
/**
* A batching replacement for {@code FontRenderer}
@@ -403,18 +403,6 @@ 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);
}
@@ -718,7 +706,7 @@ public class BatchingFontRenderer {
try {
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0);
deferredSegments.get(0).owner.setupFontDrawState();
flushLastTexture = -1;
flushLastTexture = INVALID_TEXTURE;
resetFlushLightmap();
boolean curDepthTest = GLStateManager.getDepthTest().isEnabled();
boolean curDepthMask = GLStateManager.isEffectiveDepthMaskEnabled();
@@ -844,7 +832,7 @@ public class BatchingFontRenderer {
final int d = GLStateManager.pushState(StateSet.FONT);
try {
setupFontDrawState();
flushLastTexture = -1;
flushLastTexture = INVALID_TEXTURE;
resetFlushLightmap();
try {
for (int i = 0; i < segmentCount; i++) {
@@ -977,7 +965,7 @@ public class BatchingFontRenderer {
GLStateManager.glDisable(GL11.GL_TEXTURE_2D);
}
if (cmd.texture != 0) {
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, cmd.texture);
bindIntTexture(owner, cmd.texture);
}
flushLastTexture = cmd.texture;
}
@@ -1048,7 +1036,7 @@ public class BatchingFontRenderer {
private static void emitRangeThroughPipeline(BatchingFontRenderer owner, FontDrawCmd[] cmdsData, int from, int to,
int packedLight, float normalX, float normalY, float normalZ) {
final Tessellator tessellator = Tessellator.instance;
int lastTexture = -1;
int lastTexture = INVALID_TEXTURE;
boolean drawing = false;
try {
for (int i = from; i < to; i++) {
@@ -1062,7 +1050,7 @@ public class BatchingFontRenderer {
GLStateManager.disableTexture();
} else {
GLStateManager.enableTexture();
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, cmd.texture);
bindIntTexture(owner, cmd.texture);
}
lastTexture = cmd.texture;
}
@@ -1501,7 +1489,7 @@ public class BatchingFontRenderer {
final float shadowOffset = fontProvider.getShadowOffset();
final int shadowCopies = FontConfig.shadowCopies;
final int boldCopies = FontConfig.boldCopies;
final int texture = textureFor(fontProvider, chr);
final int texture = fontProvider.getTexture(chr);
// Wave: Y offset via sine wave
float renderY = heightNorth;
@@ -3,10 +3,6 @@ package com.gtnewhorizons.angelica.client.font;
import com.gtnewhorizons.angelica.config.FontConfig;
import it.unimi.dsi.fastutil.chars.Char2ShortOpenHashMap;
import jss.util.RandomXoshiro256StarStar;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
public final class FontProviderMC implements FontProvider {
@@ -114,14 +110,7 @@ public final class FontProviderMC implements FontProvider {
@Override
public int getTexture(char chr) {
final TextureManager tm = Minecraft.getMinecraft().getTextureManager();
ITextureObject tex = tm.getTexture(locationFontTexture);
if (tex == null) {
tex = new SimpleTexture(locationFontTexture);
tm.loadTexture(locationFontTexture, tex);
tex = tm.getTexture(locationFontTexture);
}
return tex.getGlTextureId();
return FontStrategist.getIntFromResourceLocation(locationFontTexture);
}
@Override
@@ -3,9 +3,6 @@ package com.gtnewhorizons.angelica.client.font;
import com.gtnewhorizons.angelica.config.FontConfig;
import jss.util.RandomXoshiro256StarStar;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
@@ -133,14 +130,7 @@ public final class FontProviderUnicode implements FontProvider, IResourceManager
public int getTexture(char chr) {
final int uniPage = chr / 256;
ResourceLocation rl = getUnicodePageLocation(uniPage);
final TextureManager tm = Minecraft.getMinecraft().getTextureManager();
ITextureObject tex = tm.getTexture(rl);
if (tex == null) {
tex = new SimpleTexture(rl);
tm.loadTexture(rl, tex);
tex = tm.getTexture(rl);
}
return tex.getGlTextureId();
return FontStrategist.getIntFromResourceLocation(rl);
}
@Override
@@ -2,13 +2,17 @@ package com.gtnewhorizons.angelica.client.font;
import com.google.common.collect.HashMultiset;
import com.gtnewhorizons.angelica.config.FontConfig;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.mixins.interfaces.FontRendererAccessor;
import cpw.mods.fml.client.SplashProgress;
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.ResourceLocation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.opengl.GL11;
import java.awt.Font;
import java.awt.FontFormatException;
@@ -19,9 +23,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@@ -196,4 +202,34 @@ public class FontStrategist {
return active;
}
/*
* We want to refer to either a texture or a resource location using a single integer. Int space allocation:
* Integer.MIN_VALUE - reserved invalid texture
* (Integer.MIN_VALUE, -1] - ResourceLocations, values -1, -2, -3 map to indices 0, 1, 2 etc. in the below structures
* 0 - untextured (underline, strikethrough...)
* [1, Integer.MAX_VALUE] - regular OpenGL texture IDs
*/
static final int INVALID_TEXTURE = Integer.MIN_VALUE;
private static int remap(int n) { return -1 - n; } // involution
private static final List<ResourceLocation> intToResourceLocation = new ArrayList<>();
private static final Map<ResourceLocation, Integer> resourceLocationToInt = new HashMap<>();
static int getIntFromResourceLocation(ResourceLocation rl) {
Integer i = resourceLocationToInt.get(rl);
if (i != null) { return i; }
int idx = remap(intToResourceLocation.size());
resourceLocationToInt.put(rl, idx);
intToResourceLocation.add(rl);
return idx;
}
static void bindIntTexture(BatchingFontRenderer owner, int texture) {
if (texture > 0) {
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, texture);
} else if (texture < 0) {
((FontRendererAccessor) owner.underlying).angelica$bindTexture(intToResourceLocation.get(remap(texture)));
}
}
}