This commit is contained in:
kirillsaint 2023-06-29 14:47:54 +06:00
parent a6b499c605
commit ba183b0935
15 changed files with 169 additions and 92 deletions

View File

@ -1,14 +1,8 @@
package net.silentclient.client.gui; package net.silentclient.client.gui;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiMultiplayer;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiScreenServerList; import net.silentclient.client.gui.minecraft.GuiMainMenu;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.resources.I18n;
import net.silentclient.client.mixin.accessors.GuiMultiplayerAccessor;
public class GuiMultiplayerInGame extends GuiMultiplayer { public class GuiMultiplayerInGame extends GuiMultiplayer {
@ -16,34 +10,18 @@ public class GuiMultiplayerInGame extends GuiMultiplayer {
super(parentScreen); super(parentScreen);
} }
@Override
protected void actionPerformed(GuiButton button) throws IOException {
if(button.id == 1) {
disconnect();
}
if(button.id == 4) {
((GuiMultiplayerAccessor) this).setDirectConnect(true);
((GuiMultiplayerAccessor) this).setSelectedServer(new ServerData(I18n.format("selectServer.defaultName", new Object[0]), "", false));
this.mc.displayGuiScreen(new GuiScreenServerList(this, ((GuiMultiplayerAccessor) this).getSelectedServer()));
}
super.actionPerformed(button);
}
@Override @Override
public void connectToSelected() { public void connectToSelected() {
disconnect(); this.performDisconnection();
super.connectToSelected(); super.connectToSelected();
} }
private void disconnect() { public void performDisconnection() {
if(this.mc.theWorld != null) { if (this.mc.theWorld != null) {
this.mc.theWorld.sendQuittingDisconnectingPacket(); this.mc.theWorld.sendQuittingDisconnectingPacket();
this.mc.loadWorld(null); this.mc.loadWorld(null);
this.mc.displayGuiScreen(null); this.mc.displayGuiScreen(null);
((GuiMultiplayerAccessor) this).setParentScreen(null); // ((GuiMultiplayerAccessor) this).setParentScreen(new GuiMultiplayer(new GuiMainMenu()));
} }
} }

View File

@ -323,7 +323,7 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback
GlStateManager.scale(f, f, f); GlStateManager.scale(f, f, f);
// this.drawCenteredString(this.fontRendererObj, this.splashText, 0, -8, -256); // this.drawCenteredString(this.fontRendererObj, this.splashText, 0, -8, -256);
GlStateManager.popMatrix(); GlStateManager.popMatrix();
String s = "Silent Client 1.8.8"; String s = "Silent Client 1.8.9";
if (this.mc.isDemo()) if (this.mc.isDemo())
{ {

View File

@ -26,15 +26,10 @@ public class SilentClientTweaker implements ITweaker {
catch(ClassNotFoundException e) { catch(ClassNotFoundException e) {
Client.logger.info("Optifine not found!"); Client.logger.info("Optifine not found!");
} }
// Add the launch arguments to our launchArgs array
this.launchArgs.addAll(args); this.launchArgs.addAll(args);
// Constants
final String VERSION = "--version"; final String VERSION = "--version";
final String ASSET_DIR = "--assetDir";
final String GAME_DIR = "--gameDir";
// Check if version is passed as a launch argument, if not add it
if (!args.contains(VERSION) && profile != null) if (!args.contains(VERSION) && profile != null)
{ {
launchArgs.add(VERSION); launchArgs.add(VERSION);

View File

@ -2,14 +2,10 @@ package net.silentclient.client.mixin.accessors;
import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiMultiplayer;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.multiplayer.ServerData;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(GuiMultiplayer.class) @Mixin(GuiMultiplayer.class)
public interface GuiMultiplayerAccessor { public interface GuiMultiplayerAccessor {
@Accessor void setSelectedServer(ServerData a);
@Accessor ServerData getSelectedServer();
@Accessor void setParentScreen(GuiScreen a); @Accessor void setParentScreen(GuiScreen a);
@Accessor void setDirectConnect(boolean a);
} }

View File

@ -0,0 +1,7 @@
package net.silentclient.client.mixin.ducks;
import net.silentclient.client.cosmetics.StaticResourceLocation;
public interface EntityRendererExt {
void silent$loadShader(StaticResourceLocation location);
}

View File

@ -5,9 +5,11 @@ import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils; import net.minecraft.util.StringUtils;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.silentclient.client.Client;
import net.silentclient.client.cosmetics.*; import net.silentclient.client.cosmetics.*;
import net.silentclient.client.cosmetics.dynamiccurved.DynamicCape; import net.silentclient.client.cosmetics.dynamiccurved.DynamicCape;
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt; import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
import net.silentclient.client.mods.settings.CosmeticsMod;
import net.silentclient.client.utils.Players; import net.silentclient.client.utils.Players;
import net.silentclient.client.utils.types.PlayerResponse; import net.silentclient.client.utils.types.PlayerResponse;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@ -53,6 +55,9 @@ public abstract class AbstractClientPlayerMixin implements AbstractClientPlayerE
@Override @Override
public String silent$getCapeType() { public String silent$getCapeType() {
if(!Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Capes").getValBoolean()) {
return null;
}
return silent$capeType; return silent$capeType;
} }

View File

@ -2,6 +2,8 @@ package net.silentclient.client.mixin.mixins;
import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.silentclient.client.cosmetics.StaticResourceLocation;
import net.silentclient.client.mixin.ducks.EntityRendererExt;
import net.silentclient.client.utils.culling.EntityCulling; import net.silentclient.client.utils.culling.EntityCulling;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@ -11,9 +13,13 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(EntityRenderer.class) @Mixin(EntityRenderer.class)
public abstract class EntityRendererMixin { public abstract class EntityRendererMixin implements EntityRendererExt {
@Shadow @Shadow protected abstract void loadShader(ResourceLocation resourceLocationIn);
abstract void loadShader(ResourceLocation shader);
@Override
public void silent$loadShader(StaticResourceLocation location) {
this.loadShader(location.getLocation());
}
@Inject(method = "renderWorldPass", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;renderEntities(Lnet/minecraft/entity/Entity;Lnet/minecraft/client/renderer/culling/ICamera;F)V")) @Inject(method = "renderWorldPass", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;renderEntities(Lnet/minecraft/entity/Entity;Lnet/minecraft/client/renderer/culling/ICamera;F)V"))
private void shouldPerformCulling(CallbackInfo ci) { private void shouldPerformCulling(CallbackInfo ci) {

View File

@ -0,0 +1,32 @@
package net.silentclient.client.mixin.mixins;
import net.minecraft.client.gui.achievement.GuiAchievement;
import net.minecraft.client.renderer.GlStateManager;
import net.silentclient.client.Client;
import net.silentclient.client.mods.settings.RenderMod;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(GuiAchievement.class)
public class GuiAchievementMixin {
@Inject(method = "updateAchievementWindow", at = @At("HEAD"))
public void removeAchievements(CallbackInfo ci) {
if(Client.getInstance().getSettingsManager().getSettingByClass(RenderMod.class, "Disable Achievements").getValBoolean()) {
ci.cancel();
}
}
@Inject(method = "updateAchievementWindow", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/achievement/GuiAchievement;updateAchievementWindowScale()V"))
public void fixAchievement1(CallbackInfo ci) {
GlStateManager.enableBlend();
GlStateManager.enableAlpha();
}
@Inject(method = "updateAchievementWindow", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;enableDepth()V"))
public void fixAchievement2(CallbackInfo ci) {
GlStateManager.disableBlend();
GlStateManager.disableAlpha();
}
}

View File

@ -0,0 +1,19 @@
package net.silentclient.client.mixin.mixins;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.entity.layers.LayerCape;
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LayerCape.class)
public abstract class LayerCapeMixin {
@Inject(method = "doRenderLayer(Lnet/minecraft/client/entity/AbstractClientPlayer;FFFFFFF)V", at = @At("HEAD"))
public void cancelCapeRenderer(AbstractClientPlayer entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale, CallbackInfo ci) {
if(((AbstractClientPlayerExt) entitylivingbaseIn).silent$getCape() != null) {
ci.cancel();
}
}
}

View File

@ -1,18 +1,22 @@
package net.silentclient.client.utils; package net.silentclient.client.utils;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client; import net.silentclient.client.Client;
import net.silentclient.client.cosmetics.StaticResourceLocation;
import net.silentclient.client.mixin.ducks.EntityRendererExt;
import net.silentclient.client.mods.settings.GeneralMod; import net.silentclient.client.mods.settings.GeneralMod;
public class MenuBlurUtils { public class MenuBlurUtils {
public static void loadBlur() { public static void loadBlur() {
if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean()) { if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean()) {
// ((EntityRendererMixin) Minecraft.getMinecraft().entityRenderer).loadShader(new ResourceLocation("shaders/post/menu_blur.json")); ((EntityRendererExt) Minecraft.getMinecraft().entityRenderer).silent$loadShader(new StaticResourceLocation("shaders/post/menu_blur.json"));
} }
} }
public static void unloadBlur() { public static void unloadBlur() {
if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean()) { if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean()) {
// ((EntityRendererAccessor) Minecraft.getMinecraft().entityRenderer).loadShader(new ResourceLocation("shaders/post/menu_blur.json")); Minecraft.getMinecraft().entityRenderer.loadEntityShader(null);
} }
} }
} }

View File

@ -1,48 +0,0 @@
package net.silentclient.client.utils;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import sun.misc.Unsafe;
@Deprecated
public final class UnsafeAccess {
static final String ANDROID = "THE_ONE";
static final String OPEN_JDK = "theUnsafe";
public static final Unsafe UNSAFE;
static {
try {
UNSAFE = load("theUnsafe", "THE_ONE");
} catch (Exception e) {
throw new Error("Failed to load sun.misc.Unsafe", e);
}
}
public static long objectFieldOffset(Class<?> clazz, String fieldName) {
try {
return UNSAFE.objectFieldOffset(clazz.getDeclaredField(fieldName));
} catch (NoSuchFieldException|SecurityException e) {
throw new Error(e);
}
}
static Unsafe load(String openJdk, String android) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
Field field;
try {
field = Unsafe.class.getDeclaredField(openJdk);
} catch (NoSuchFieldException noSuchFieldException) {
try {
field = Unsafe.class.getDeclaredField(android);
} catch (NoSuchFieldException noSuchFieldException1) {
Constructor<Unsafe> unsafeConstructor = Unsafe.class.getDeclaredConstructor(new Class[0]);
unsafeConstructor.setAccessible(true);
return unsafeConstructor.newInstance(new Object[0]);
}
}
field.setAccessible(true);
return (Unsafe)field.get(null);
}
}

View File

@ -0,0 +1,37 @@
{
"targets": [
"swap"
],
"passes": [
{
"name": "menu_blur",
"intarget": "minecraft:main",
"outtarget": "swap",
"uniforms": [
{
"name": "BlurDir",
"values": [ 1.0, 0.0 ]
},
{
"name": "Radius",
"values": [ 20.0 ]
}
]
},
{
"name": "menu_blur",
"intarget": "swap",
"outtarget": "minecraft:main",
"uniforms": [
{
"name": "BlurDir",
"values": [ 0.0, 1.0 ]
},
{
"name": "Radius",
"values": [ 20.0 ]
}
]
}
]
}

View File

@ -0,0 +1,23 @@
#version 120
uniform sampler2D DiffuseSampler;
varying vec2 texCoord;
varying vec2 oneTexel;
uniform vec2 InSize;
uniform vec2 BlurDir;
uniform float Radius;
void main() {
vec4 blurred = vec4(0.0);
float totalStrength = 0.0;
for(float r = -Radius; r <= Radius; r += 1.0) {
vec4 tex = texture2D(DiffuseSampler, texCoord + oneTexel * r * BlurDir);
float strength = 1.0 - abs(r / Radius);
totalStrength = totalStrength + strength;
blurred = blurred + tex * strength;
}
gl_FragColor = vec4(blurred.rgb / totalStrength, 1.0);
}

View File

@ -0,0 +1,21 @@
{
"blend": {
"func": "add",
"srcrgb": "one",
"dstrgb": "zero"
},
"vertex": "sobel",
"fragment": "menu_blur",
"attributes": [ "Position" ],
"samplers": [
{ "name": "DiffuseSampler" }
],
"uniforms": [
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
{ "name": "BlurDir", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
{ "name": "Radius", "type": "float", "count": 1, "values": [ 5.0 ] }
]
}

View File

@ -2,12 +2,12 @@
"required": true, "required": true,
"compatibilityLevel": "JAVA_8", "compatibilityLevel": "JAVA_8",
"verbose": true, "verbose": true,
"minVersion": "0.6",
"package": "net.silentclient.client.mixin", "package": "net.silentclient.client.mixin",
"refmap": "mixins.SilentClient.refmap.json", "refmap": "mixins.SilentClient.refmap.json",
"mixins": [ "mixins": [
"mixins.MinecraftMixin", "mixins.MinecraftMixin",
"mixins.AbstractClientPlayerMixin", "mixins.AbstractClientPlayerMixin",
"accessors.GuiMultiplayerAccessor",
"accessors.GuiChatAccessor", "accessors.GuiChatAccessor",
"accessors.GuiAccessor", "accessors.GuiAccessor",
"accessors.RenderItemAccessor", "accessors.RenderItemAccessor",
@ -21,6 +21,8 @@
"mixins.EffectRendererMixin", "mixins.EffectRendererMixin",
"accessors.RenderManagerAccessor", "accessors.RenderManagerAccessor",
"mixins.RenderPlayerMixin", "mixins.RenderPlayerMixin",
"mixins.GuiInGameMixin" "mixins.GuiInGameMixin",
"mixins.LayerCapeMixin",
"mixins.GuiAchievementMixin"
] ]
} }