fixed FontCache was not reloaded properly

This commit is contained in:
FlorianMichael 2023-04-28 16:16:22 +02:00
parent 43c1aff854
commit 5445ec5f59
2 changed files with 11 additions and 8 deletions

View File

@ -24,6 +24,7 @@ import de.florianmichael.viafabricplus.injection.access.IFontStorage;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.ExperimentalSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.Glyph;
@ -37,20 +38,22 @@ import java.util.function.Supplier;
public class FontCacheFix {
public final static boolean DASH_LOADER = FabricLoader.getInstance().isModLoaded("dashloader");
private static ComparableProtocolVersion protocolVersion;
public static void init() {
if (DASH_LOADER) return;
ChangeProtocolVersionCallback.EVENT.register(protocolVersion -> MinecraftClient.getInstance().fontManager.fontStorages.values().forEach(fontStorage -> {
RenderSystem.recordRenderCall(() -> {
((IFontStorage) fontStorage).viafabricplus_clearCaches();
});
}));
ChangeProtocolVersionCallback.EVENT.register(protocolVersion -> {
FontCacheFix.protocolVersion = protocolVersion;
MinecraftClient.getInstance().fontManager.fontStorages.values().forEach(fontStorage -> RenderSystem.recordRenderCall(() -> ((IFontStorage) fontStorage).viafabricplus_clearCaches()));
});
}
public static boolean shouldReplaceFontRenderer() {
if (ViaLoadingBase.getInstance() == null || DASH_LOADER) return false;
if (ViaLoadingBase.getInstance() == null || DASH_LOADER || protocolVersion == null) return false;
return ExperimentalSettings.INSTANCE.fixFontCache.getValue() && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_12_2);
return ExperimentalSettings.INSTANCE.fixFontCache.getValue() && protocolVersion.isOlderThanOrEqualTo(ProtocolVersion.v1_12_2);
}
public enum BuiltinEmptyGlyph1_12_2 implements Glyph {

View File

@ -113,7 +113,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(this.getX(), this.getY(), this.getZ(), this.onGround));
} else if (bl4) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(this.getYaw(), this.getPitch(), this.onGround));
} else if (this.lastOnGround != this.onGround || DebugSettings.INSTANCE.sendIdlePacket.getValue()) {
} else if ((this.lastOnGround != this.onGround && !DebugSettings.INSTANCE.sendIdlePacket.getValue()) || DebugSettings.INSTANCE.sendIdlePacket.getValue()) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(this.onGround));
} else {
SkipIdlePacketCallback.EVENT.invoker().onSkipIdlePacket();