mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 07:11:31 +01:00
font optimization
This commit is contained in:
parent
cba8279c5d
commit
4dddc10f64
@ -4,8 +4,11 @@
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="delegatedBuild" value="true" />
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="1.8" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
@ -1,7 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="zulu-1.8" project-jdk-type="JavaSDK">
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
@ -6,10 +6,12 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiScreenServerList;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.mixin.accessors.GuiMultiplayerAccessor;
|
||||
import net.silentclient.client.mixin.wrappers.ServerDataWrapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class GuiMultiplayerInGame extends GuiMultiplayer {
|
||||
|
||||
@ -25,7 +27,15 @@ public class GuiMultiplayerInGame extends GuiMultiplayer {
|
||||
|
||||
if(button.id == 4) {
|
||||
((GuiMultiplayerAccessor) this).silent$setDirectConnect(true);
|
||||
((GuiMultiplayerAccessor) this).silent$setSelectedServer(new ServerDataWrapper(new ServerData(I18n.format("selectServer.defaultName"), "", false)));
|
||||
try {
|
||||
Class<?> clazz = this.getClass();
|
||||
Object cc = clazz.newInstance();
|
||||
Field f1 = cc.getClass().getSuperclass().getDeclaredField("selectedServer");
|
||||
f1.setAccessible(true);
|
||||
f1.set(cc, null);
|
||||
} catch (Exception err) {
|
||||
Client.logger.catching(err);
|
||||
}
|
||||
this.mc.displayGuiScreen(new GuiScreenServerList(this, ((GuiMultiplayerAccessor) this).silent$getSelectedServer().getServerData()));
|
||||
}
|
||||
|
||||
@ -43,7 +53,15 @@ public class GuiMultiplayerInGame extends GuiMultiplayer {
|
||||
this.mc.theWorld.sendQuittingDisconnectingPacket();
|
||||
this.mc.loadWorld(null);
|
||||
this.mc.displayGuiScreen(null);
|
||||
((GuiMultiplayerAccessor) this).silent$setParentScreen(null);
|
||||
try {
|
||||
Class<?> clazz = this.getClass();
|
||||
Object cc = clazz.newInstance();
|
||||
Field f1 = cc.getClass().getSuperclass().getDeclaredField("parentScreen");
|
||||
f1.setAccessible(true);
|
||||
f1.set(cc, null);
|
||||
} catch (Exception err) {
|
||||
Client.logger.catching(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,7 @@ package net.silentclient.client.mixin;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.silentclient.client.Client;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.*;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
|
@ -1,23 +0,0 @@
|
||||
package net.silentclient.client.mixin.accessors;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(GlStateManager.class)
|
||||
public interface GlStateManagerAccessor {
|
||||
@Accessor
|
||||
static GlStateManager.Color getColorState() {
|
||||
throw new UnsupportedOperationException("Mixin failed to inject!");
|
||||
}
|
||||
|
||||
@Accessor
|
||||
static GlStateManager.TextureState[] getTextureState() {
|
||||
throw new UnsupportedOperationException("Mixin failed to inject!");
|
||||
}
|
||||
|
||||
@Accessor
|
||||
static int getActiveTextureUnit() {
|
||||
throw new UnsupportedOperationException("Mixin failed to inject!");
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ public abstract class FontRendererMixin implements FontRendererExt {
|
||||
}
|
||||
|
||||
@Inject(method = "renderStringAtPos", at = @At("HEAD"), cancellable = true)
|
||||
private void silent$useOptimizedRendering(String text, boolean shadow, CallbackInfo ci) {
|
||||
private void silent$useOptimizedRendering(String text, boolean shadow, CallbackInfo ci) throws NoSuchFieldException, IllegalAccessException {
|
||||
if (this.silent$fontRendererHook.renderStringAtPos(text, shadow)) {
|
||||
ci.cancel();
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.hooks.OptiFineHook;
|
||||
import net.silentclient.client.mixin.accessors.FontRendererAccessor;
|
||||
import net.silentclient.client.mixin.accessors.GlStateManagerAccessor;
|
||||
import net.silentclient.client.mixin.ducks.FontRendererExt;
|
||||
import net.silentclient.client.mixin.optifine.OptiFineFontRendererHandler;
|
||||
import net.silentclient.client.mods.settings.FPSBoostMod;
|
||||
@ -24,6 +23,7 @@ import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
public final class FontRendererHook {
|
||||
@ -131,7 +131,7 @@ public final class FontRendererHook {
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unused"})
|
||||
public boolean renderStringAtPos(String text, boolean shadow) {
|
||||
public boolean renderStringAtPos(String text, boolean shadow) throws NoSuchFieldException, IllegalAccessException {
|
||||
if (Minecraft.getMinecraft().getTextureManager() == null || !FPSBoostMod.basicEnabled()) {
|
||||
this.deleteTextureId();
|
||||
return false;
|
||||
@ -159,9 +159,14 @@ public final class FontRendererHook {
|
||||
|
||||
GlStateManager.bindTexture(glTextureId);
|
||||
GlStateManager.translate(posX, posY, 0F);
|
||||
Field field = GlStateManager.class.getDeclaredField("textureState");
|
||||
field.setAccessible(true);
|
||||
|
||||
final GlStateManager.TextureState[] textureStates = GlStateManagerAccessor.getTextureState();
|
||||
final GlStateManager.TextureState textureState = textureStates[GlStateManagerAccessor.getActiveTextureUnit()];
|
||||
Field field2 = GlStateManager.class.getDeclaredField("activeTextureUnit");
|
||||
field2.setAccessible(true);
|
||||
|
||||
final GlStateManager.TextureState[] textureStates = (GlStateManager.TextureState[]) field.get(new GlStateManager());
|
||||
final GlStateManager.TextureState textureState = textureStates[(int) field2.get(new GlStateManager())];
|
||||
|
||||
final StringHash hash = new StringHash(text, red, green, blue, alpha, shadow);
|
||||
final CachedString cachedString = FPSBoostMod.advancedEnabled() ? this.enhancedFontRenderer.get(hash) : null;
|
||||
@ -173,9 +178,11 @@ public final class FontRendererHook {
|
||||
// Call so states in game know the texture was changed.
|
||||
// Otherwise, the game won't know the active texture was changed on the GPU
|
||||
textureState.textureName = glTextureId;
|
||||
Field colorStateField = GlStateManager.class.getDeclaredField("colorState");
|
||||
colorStateField.setAccessible(true);
|
||||
|
||||
// Save thing as texture, it updated in GL, so we need to update the MC cache of that value
|
||||
GlStateManager.Color colorState = GlStateManagerAccessor.getColorState();
|
||||
GlStateManager.Color colorState = (GlStateManager.Color) colorStateField.get(new GlStateManager());
|
||||
colorState.red = cachedString.getLastRed();
|
||||
colorState.green = cachedString.getLastGreen();
|
||||
colorState.blue = cachedString.getLastBlue();
|
||||
|
@ -111,7 +111,6 @@
|
||||
"mixins.ScreenShotHelperMixin",
|
||||
"mixins.RenderTNTPrimedMixin",
|
||||
"mixins.GuiDisconnectedMixin",
|
||||
"accessors.GlStateManagerAccessor",
|
||||
"accessors.optifine.CustomColorsAccessor",
|
||||
"accessors.optifine.ConfigAccessor"
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user