diff --git a/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java b/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java index 8ba2013..7ad00a4 100644 --- a/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java +++ b/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java @@ -1,12 +1,15 @@ package net.silentclient.client.cosmetics.gui; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; import net.silentclient.client.Client; import net.silentclient.client.cosmetics.Outfits; import net.silentclient.client.gui.SilentScreen; +import net.silentclient.client.gui.animation.SimpleAnimation; import net.silentclient.client.gui.elements.IconButton; import net.silentclient.client.gui.font.SilentFontRenderer; import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; @@ -15,12 +18,17 @@ import net.silentclient.client.gui.util.RenderUtil; import net.silentclient.client.utils.MenuBlurUtils; import net.silentclient.client.utils.types.PlayerResponse; import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; import java.awt.*; import java.io.IOException; public class OutfitsGui extends SilentScreen { private final GuiScreen parentScreen; + private SimpleAnimation scrollAnimation = new SimpleAnimation(0.0F); + private float scrollY = 0; + private int outfitIndex = 0; public OutfitsGui(GuiScreen parentScreen) { this.parentScreen = parentScreen; @@ -30,6 +38,7 @@ public class OutfitsGui extends SilentScreen { @Override public void initGui() { super.initGui(); + this.scrollY = 0; if(mc.thePlayer == null) { Client.backgroundPanorama.updateWidthHeight(this.width, this.height); } else { @@ -58,27 +67,35 @@ public class OutfitsGui extends SilentScreen { RenderUtil.drawRoundedRect(x, y, width, height, 4, Theme.backgroundColor().getRGB()); Client.getInstance().getSilentFontRenderer().drawString(x + 3, y + 3, "Outfits", 14, SilentFontRenderer.FontType.TITLE); super.drawScreen(mouseX, mouseY, partialTicks); + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + ScaledResolution r = new ScaledResolution(Minecraft.getMinecraft()); + int s = r.getScaleFactor(); + int listHeight = height - 20; + int translatedY = r.getScaledHeight() - 20 - 20 - listHeight; + GL11.glScissor(0 * s, translatedY * s, this.width * s, listHeight * s); int outfitX = x + 3; - int outfitY = y + 20; + float outfitY = (int) (y + 20 - scrollAnimation.getValue()); int outfitIndex = 0; boolean isCreateHovered = MouseUtils.isInside(mouseX, mouseY, outfitX, outfitY, 80, 80); if(isCreateHovered) { RenderUtil.drawRoundedRect(outfitX, outfitY, 80, 80, 3, new Color(255, 255, 255, 30).getRGB()); } RenderUtil.drawRoundedOutline(outfitX, outfitY, 80, 80, 3, 1, Theme.borderColor().getRGB()); - Client.getInstance().getSilentFontRenderer().drawCenteredString("Create New Outfit", outfitX + 40, outfitY + 40 - 6, 12, SilentFontRenderer.FontType.TITLE); + Client.getInstance().getSilentFontRenderer().drawCenteredString("Create New Outfit", outfitX + 40, (int) (outfitY + 40 - 6), 12, SilentFontRenderer.FontType.TITLE); outfitX += 83; outfitIndex += 1; + this.outfitIndex = 1; for(Outfits.Outfit outfit : Outfits.getOutfits()) { boolean isHovered = MouseUtils.isInside(mouseX, mouseY, outfitX, outfitY, 80, 80) && !MouseUtils.isInside(mouseX, mouseY, outfitX + 80 - 3 - 10, outfitY + 3, 10, 10); if(isHovered) { RenderUtil.drawRoundedRect(outfitX, outfitY, 80, 80, 3, new Color(255, 255, 255, 30).getRGB()); } RenderUtil.drawRoundedOutline(outfitX, outfitY, 80, 80, 3, 1, Theme.borderColor().getRGB()); - Client.getInstance().getSilentFontRenderer().drawString(outfit.name, outfitX + 3, outfitY + 3, 12, SilentFontRenderer.FontType.TITLE, 64); + Client.getInstance().getSilentFontRenderer().drawString(outfit.name, outfitX + 3, (int) (outfitY + 3), 12, SilentFontRenderer.FontType.TITLE, 64); RenderUtil.drawImage(new ResourceLocation("silentclient/icons/trash-icon.png"), outfitX + 80 - 3 - 10, outfitY + 3, 10, 10); - int cosmeticY = outfitY + 18; + int cosmeticY = (int) (outfitY + 18); if(outfit.selected_cape != 0 && Client.getInstance().getCosmetics().getMyCapes().stream().filter((c) -> c.id == outfit.selected_cape).findFirst().isPresent()) { PlayerResponse.Account.Cosmetics.CosmeticItem item = Client.getInstance().getCosmetics().getMyCapes().stream().filter((c) -> c.id == outfit.selected_cape).findFirst().get(); @@ -134,15 +151,47 @@ public class OutfitsGui extends SilentScreen { Client.getInstance().getSilentFontRenderer().drawString(item.name, outfitX + 3, cosmeticY, 10, SilentFontRenderer.FontType.TITLE, 75); } - + this.outfitIndex += 1; outfitIndex += 1; if(outfitIndex == 3) { outfitIndex = 0; + outfitX = x + 3; outfitY += 85; } else { outfitX += 83; } } + + GL11.glDisable(GL11.GL_SCISSOR_TEST); + GL11.glPopMatrix(); + + scrollAnimation.setAnimation(scrollY, 12); + } + + @Override + public void handleMouseInput() throws IOException { + super.handleMouseInput(); + int dw = Mouse.getEventDWheel(); + double newScrollY = this.scrollY; + int height = 200; + if(dw != 0) { + if (dw > 0) { + dw = -1; + } else { + dw = 1; + } + float amountScrolled = (float) (dw * 10); + if (newScrollY + amountScrolled > 0) + newScrollY += amountScrolled; + else + newScrollY = 0; + if((newScrollY < (this.outfitIndex * 26) && (this.outfitIndex * 26) > height - 20) || amountScrolled < 0) { + this.scrollY = (float) newScrollY; + if(this.scrollY < 0) { + this.scrollY = 0; + } + } + } } @Override @@ -161,7 +210,7 @@ public class OutfitsGui extends SilentScreen { int x = this.width / 2 - 125; int y = this.height / 2 - 100; int outfitX = x + 3; - int outfitY = y + 20; + float outfitY = (int) (y + 20 - scrollAnimation.getValue()); int outfitIndex = 0; if(MouseUtils.isInside(mouseX, mouseY, outfitX, outfitY, 80, 80)) { mc.displayGuiScreen(new NewOutfitModal(this)); @@ -186,6 +235,7 @@ public class OutfitsGui extends SilentScreen { outfitIndex += 1; if(outfitIndex == 3) { outfitIndex = 0; + outfitX = x + 3; outfitY += 85; } else { outfitX += 83; diff --git a/src/main/java/net/silentclient/client/gui/GuiMultiplayerInGame.java b/src/main/java/net/silentclient/client/gui/GuiMultiplayerInGame.java index 81e0478..ffcb6c3 100644 --- a/src/main/java/net/silentclient/client/gui/GuiMultiplayerInGame.java +++ b/src/main/java/net/silentclient/client/gui/GuiMultiplayerInGame.java @@ -6,12 +6,9 @@ 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.utils.ClientUtils; +import net.silentclient.client.mixin.ducks.GuiMultiplayerExt; import java.io.IOException; -import java.lang.reflect.Field; public class GuiMultiplayerInGame extends GuiMultiplayer { @@ -26,17 +23,9 @@ public class GuiMultiplayerInGame extends GuiMultiplayer { } if(button.id == 4) { - ((GuiMultiplayerAccessor) this).silent$setDirectConnect(true); - try { - Class clazz = this.getClass(); - Object cc = clazz.newInstance(); - Field f1 = cc.getClass().getSuperclass().getDeclaredField(ClientUtils.isDevelopment() ? "selectedServer" : "z"); - f1.setAccessible(true); - f1.set(cc, new ServerData(I18n.format("selectServer.defaultName"), "", false)); - this.mc.displayGuiScreen(new GuiScreenServerList(this, (ServerData) f1.get(cc))); - } catch (Exception err) { - Client.logger.catching(err); - } + ((GuiMultiplayerExt) this).silent$setDirectConnect(true); + ((GuiMultiplayerExt) this).silent$setSelectedServer(new ServerData(I18n.format("selectServer.defaultName"), "", false)); + this.mc.displayGuiScreen(new GuiScreenServerList(this, new ServerData(I18n.format("selectServer.defaultName"), "", false))); } super.actionPerformed(button); @@ -53,15 +42,7 @@ public class GuiMultiplayerInGame extends GuiMultiplayer { this.mc.theWorld.sendQuittingDisconnectingPacket(); this.mc.loadWorld(null); this.mc.displayGuiScreen(null); - try { - Class clazz = this.getClass(); - Object cc = clazz.newInstance(); - Field f1 = cc.getClass().getSuperclass().getDeclaredField(ClientUtils.isDevelopment() ? "parentScreen" : "g"); - f1.setAccessible(true); - f1.set(cc, null); - } catch (Exception err) { - Client.logger.catching(err); - } + ((GuiMultiplayerExt) this).silent$setParentScreen(null); } } diff --git a/src/main/java/net/silentclient/client/mixin/SilentClientTransformer.java b/src/main/java/net/silentclient/client/mixin/SilentClientTransformer.java index 3362497..22179c7 100644 --- a/src/main/java/net/silentclient/client/mixin/SilentClientTransformer.java +++ b/src/main/java/net/silentclient/client/mixin/SilentClientTransformer.java @@ -2,7 +2,10 @@ package net.silentclient.client.mixin; import net.minecraft.launchwrapper.IClassTransformer; import net.silentclient.client.Client; -import org.objectweb.asm.*; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.MethodVisitor; import java.lang.reflect.Modifier; @@ -27,6 +30,10 @@ public class SilentClientTransformer implements IClassTransformer { return bytes; } + public static String getClassName(final Class clazz) { + return clazz.getName().replace(".", "/"); + } + public class AccessTransformerVisitor extends ClassVisitor { public AccessTransformerVisitor(int api, ClassVisitor cv) { diff --git a/src/main/java/net/silentclient/client/mixin/accessors/AbstractClientPlayerAccessor.java b/src/main/java/net/silentclient/client/mixin/accessors/AbstractClientPlayerAccessor.java deleted file mode 100644 index fed1cb9..0000000 --- a/src/main/java/net/silentclient/client/mixin/accessors/AbstractClientPlayerAccessor.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.silentclient.client.mixin.accessors; - -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.network.NetworkPlayerInfo; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(AbstractClientPlayer.class) -public interface AbstractClientPlayerAccessor { - @Accessor - NetworkPlayerInfo getPlayerInfo(); -} diff --git a/src/main/java/net/silentclient/client/mixin/accessors/GuiMultiplayerAccessor.java b/src/main/java/net/silentclient/client/mixin/accessors/GuiMultiplayerAccessor.java deleted file mode 100644 index 5d1577c..0000000 --- a/src/main/java/net/silentclient/client/mixin/accessors/GuiMultiplayerAccessor.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.silentclient.client.mixin.accessors; - -import net.minecraft.client.multiplayer.ServerData; -import net.silentclient.client.mixin.wrappers.GuiScreenWrapper; -import net.silentclient.client.mixin.wrappers.ServerDataWrapper; - -public interface GuiMultiplayerAccessor { - void silent$setParentScreen(GuiScreenWrapper a); - void silent$setDirectConnect(boolean a); - void silent$setSelectedServer(ServerDataWrapper a); - ServerDataWrapper silent$getSelectedServer(); -} diff --git a/src/main/java/net/silentclient/client/mixin/accessors/NetworkPlayerInfoAccessor.java b/src/main/java/net/silentclient/client/mixin/accessors/NetworkPlayerInfoAccessor.java index 888ca85..78d9117 100644 --- a/src/main/java/net/silentclient/client/mixin/accessors/NetworkPlayerInfoAccessor.java +++ b/src/main/java/net/silentclient/client/mixin/accessors/NetworkPlayerInfoAccessor.java @@ -2,9 +2,9 @@ package net.silentclient.client.mixin.accessors; import net.minecraft.client.network.NetworkPlayerInfo; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(NetworkPlayerInfo.class) public interface NetworkPlayerInfoAccessor { - @Accessor("skinType") String silent$getSkinType(); + @Invoker("loadPlayerTextures") void silent$loadPlayerTextures(); } diff --git a/src/main/java/net/silentclient/client/mixin/ducks/AbstractClientPlayerExt.java b/src/main/java/net/silentclient/client/mixin/ducks/AbstractClientPlayerExt.java index 7391d5c..591256c 100644 --- a/src/main/java/net/silentclient/client/mixin/ducks/AbstractClientPlayerExt.java +++ b/src/main/java/net/silentclient/client/mixin/ducks/AbstractClientPlayerExt.java @@ -1,6 +1,5 @@ package net.silentclient.client.mixin.ducks; -import net.minecraft.util.ResourceLocation; import net.silentclient.client.cosmetics.*; import net.silentclient.client.cosmetics.dynamiccurved.DynamicCape; import net.silentclient.client.utils.types.PlayerResponse; @@ -35,4 +34,5 @@ public interface AbstractClientPlayerExt { AnimatedResourceLocation silent$getCape(); String silent$getNameClear(); void silent$setNameClear(String a); + Object silent$getPlayerInfo(); } diff --git a/src/main/java/net/silentclient/client/mixin/ducks/GuiMultiplayerExt.java b/src/main/java/net/silentclient/client/mixin/ducks/GuiMultiplayerExt.java new file mode 100644 index 0000000..21ed9a1 --- /dev/null +++ b/src/main/java/net/silentclient/client/mixin/ducks/GuiMultiplayerExt.java @@ -0,0 +1,8 @@ +package net.silentclient.client.mixin.ducks; + +public interface GuiMultiplayerExt { + void silent$setParentScreen(Object a); + void silent$setDirectConnect(boolean a); + void silent$setSelectedServer(Object a); + Object silent$getSelectedServer(); +} diff --git a/src/main/java/net/silentclient/client/mixin/ducks/NetworkPlayerInfoExt.java b/src/main/java/net/silentclient/client/mixin/ducks/NetworkPlayerInfoExt.java new file mode 100644 index 0000000..bcb1369 --- /dev/null +++ b/src/main/java/net/silentclient/client/mixin/ducks/NetworkPlayerInfoExt.java @@ -0,0 +1,6 @@ +package net.silentclient.client.mixin.ducks; + +public interface NetworkPlayerInfoExt { + String silent$getSkinType(); + Object silent$getLocationSkin(); +} diff --git a/src/main/java/net/silentclient/client/mixin/mixins/AbstractClientPlayerMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/AbstractClientPlayerMixin.java index c78c4b2..5358059 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/AbstractClientPlayerMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/AbstractClientPlayerMixin.java @@ -3,6 +3,7 @@ package net.silentclient.client.mixin.mixins; import com.mojang.authlib.GameProfile; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StringUtils; @@ -20,6 +21,7 @@ import net.silentclient.client.utils.Players; import net.silentclient.client.utils.SCTextureManager; import net.silentclient.client.utils.types.PlayerResponse; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -30,6 +32,7 @@ import java.util.Random; @Mixin(AbstractClientPlayer.class) public abstract class AbstractClientPlayerMixin implements AbstractClientPlayerExt { + @Shadow private NetworkPlayerInfo playerInfo; @Unique private AnimatedResourceLocation silent$cape; @Unique private AnimatedResourceLocation silent$bandana; @Unique private HatData silent$hat; @@ -276,4 +279,9 @@ public abstract class AbstractClientPlayerMixin implements AbstractClientPlayerE public void silent$setPlayerIcon(StaticResourceLocation a) { this.silent$playerIcon = a; } + + @Override + public Object silent$getPlayerInfo() { + return this.playerInfo; + } } diff --git a/src/main/java/net/silentclient/client/mixin/mixins/EntityRendererMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/EntityRendererMixin.java index 35875a1..33330c6 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/EntityRendererMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/EntityRendererMixin.java @@ -5,6 +5,8 @@ import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.GuiIngame; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.client.renderer.culling.ICamera; import net.minecraft.client.shader.ShaderGroup; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -21,6 +23,7 @@ import net.silentclient.client.mixin.ducks.EntityRendererExt; import net.silentclient.client.mods.render.AnimationsMod; import net.silentclient.client.mods.render.NewMotionBlurMod; import net.silentclient.client.mods.settings.RenderMod; +import net.silentclient.client.utils.CloudRenderer; import net.silentclient.client.utils.HUDCaching; import net.silentclient.client.utils.culling.EntityCulling; import net.silentclient.client.utils.shader.MotionBlurUtils; @@ -272,4 +275,10 @@ public abstract class EntityRendererMixin implements EntityRendererExt { private void silent$disablePolygonOffset(CallbackInfo ci) { GlStateManager.disablePolygonOffset(); } + + @Redirect(method = "renderWorldPass", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/culling/ICamera;setPosition(DDD)V")) + public void initFrustum(ICamera instance, double v1, double v2, double v3) { + CloudRenderer.setFrustum((Frustum) instance); + instance.setPosition(v1, v2, v3); + } } diff --git a/src/main/java/net/silentclient/client/mixin/mixins/GuiMultiplayerMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/GuiMultiplayerMixin.java index 996bae8..9ea9d62 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/GuiMultiplayerMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/GuiMultiplayerMixin.java @@ -4,15 +4,13 @@ import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.multiplayer.ServerData; import net.silentclient.client.gui.minecraft.GuiConnecting; -import net.silentclient.client.mixin.accessors.GuiMultiplayerAccessor; -import net.silentclient.client.mixin.wrappers.GuiScreenWrapper; -import net.silentclient.client.mixin.wrappers.ServerDataWrapper; +import net.silentclient.client.mixin.ducks.GuiMultiplayerExt; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; @Mixin(GuiMultiplayer.class) -public abstract class GuiMultiplayerMixin extends GuiScreen implements GuiMultiplayerAccessor { +public abstract class GuiMultiplayerMixin extends GuiScreen implements GuiMultiplayerExt { @Shadow private GuiScreen parentScreen; @Shadow private boolean directConnect; @@ -28,12 +26,12 @@ public abstract class GuiMultiplayerMixin extends GuiScreen implements GuiMultip } @Override - public void silent$setParentScreen(GuiScreenWrapper a) { + public void silent$setParentScreen(Object a) { if(a == null) { this.parentScreen = null; return; } - this.parentScreen = a.getScreen(); + this.parentScreen = (GuiScreen) a; } @Override @@ -42,16 +40,16 @@ public abstract class GuiMultiplayerMixin extends GuiScreen implements GuiMultip } @Override - public ServerDataWrapper silent$getSelectedServer() { - return new ServerDataWrapper(selectedServer); + public Object silent$getSelectedServer() { + return selectedServer; } @Override - public void silent$setSelectedServer(ServerDataWrapper a) { + public void silent$setSelectedServer(Object a) { if(a == null) { this.selectedServer = null; return; } - this.selectedServer = a.getServerData(); + this.selectedServer = (ServerData) a; } } diff --git a/src/main/java/net/silentclient/client/mixin/mixins/NetworkPlayerInfoMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/NetworkPlayerInfoMixin.java index 55b9686..835ac1c 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/NetworkPlayerInfoMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/NetworkPlayerInfoMixin.java @@ -1,31 +1,138 @@ package net.silentclient.client.mixin.mixins; +import com.google.common.base.Objects; import com.mojang.authlib.GameProfile; import net.minecraft.client.Minecraft; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.resources.DefaultPlayerSkin; +import net.minecraft.util.ResourceLocation; import net.silentclient.client.Client; -import net.silentclient.client.mixin.accessors.AbstractClientPlayerAccessor; +import net.silentclient.client.admin.AdminRender; import net.silentclient.client.mixin.accessors.NetworkPlayerInfoAccessor; +import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt; +import net.silentclient.client.mixin.ducks.NetworkPlayerInfoExt; import net.silentclient.client.mods.player.NickHiderMod; import net.silentclient.client.mods.render.AnimationsMod; +import net.silentclient.client.utils.NetworkPlayerInfoOptimization; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(NetworkPlayerInfo.class) -public abstract class NetworkPlayerInfoMixin { +public abstract class NetworkPlayerInfoMixin implements NetworkPlayerInfoExt { + @Shadow public abstract GameProfile getGameProfile(); + @Shadow @Final private GameProfile gameProfile; @Shadow private String skinType; - @Shadow public abstract GameProfile getGameProfile(); + @Shadow private ResourceLocation locationSkin; - @Inject(method = "getSkinType", at = @At("HEAD")) + @Shadow protected abstract void loadPlayerTextures(); + + @Inject(method = "loadPlayerTextures", at = @At("HEAD"), cancellable = true) + public void optimizationOfLoadingTexturesStart(CallbackInfo ci) { + if(NetworkPlayerInfoOptimization.isLoadingSkin) { + ci.cancel(); + return; + } + NetworkPlayerInfoOptimization.isLoadingSkin = true; + } + + @Inject(method = "loadPlayerTextures", at = @At("HEAD")) + public void optimizationOfLoadingTexturesEnd(CallbackInfo ci) { + (new Thread(() -> { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + + } + NetworkPlayerInfoOptimization.isLoadingSkin = false; + })).start(); + } + + @Inject(method = "getLocationSkin", at = @At("HEAD"), cancellable = true) + public void customSkinLocation(CallbackInfoReturnable cir) { + if(Minecraft.getMinecraft().currentScreen instanceof AdminRender) { + cir.setReturnValue(new ResourceLocation("textures/entity/steve.png")); + cir.cancel(); + return; + } + if(Client.getInstance().getModInstances().getNickHiderMod().isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(NickHiderMod.class, "Hide Skins").getValBoolean()) { + if(Client.getInstance().getSettingsManager().getSettingByClass(NickHiderMod.class, "Use Own Skin For All").getValBoolean()) { + if(((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getPlayerInfo() != null) { + if (((NetworkPlayerInfoExt) ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getPlayerInfo()).silent$getLocationSkin() == null) + { + ((NetworkPlayerInfoAccessor) ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getPlayerInfo()).silent$loadPlayerTextures(); + } + cir.setReturnValue((ResourceLocation) Objects.firstNonNull(((NetworkPlayerInfoExt) ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getPlayerInfo()).silent$getLocationSkin(), DefaultPlayerSkin.getDefaultSkin(this.gameProfile.getId()))); + cir.cancel(); + return; + } else { + cir.setReturnValue(DefaultPlayerSkin.getDefaultSkin(Minecraft.getMinecraft().thePlayer.getGameProfile().getId())); + cir.cancel(); + return; + } + } + + if(this.gameProfile.getId().equals(Minecraft.getMinecraft().thePlayer.getGameProfile().getId()) && Client.getInstance().getSettingsManager().getSettingByClass(NickHiderMod.class, "Use Real Skin For Self").getValBoolean()) { + if (this.locationSkin == null) + { + this.loadPlayerTextures(); + } + cir.setReturnValue((ResourceLocation)Objects.firstNonNull(this.locationSkin, DefaultPlayerSkin.getDefaultSkin(this.gameProfile.getId()))); + cir.cancel(); + return; + } + + cir.setReturnValue(DefaultPlayerSkin.getDefaultSkin(this.gameProfile.getId())); + cir.cancel(); + } + } + + @Inject(method = "getSkinType", at = @At("HEAD"), cancellable = true) public void customSkinType(CallbackInfoReturnable cir) { + if(Client.getInstance().getModInstances().getModByClass(AnimationsMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(AnimationsMod.class, "1.7 Skins").getValBoolean()) { + cir.setReturnValue("default"); + cir.cancel(); + return; + } + if(Client.getInstance().getModInstances().getNickHiderMod().isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(NickHiderMod.class, "Hide Skins").getValBoolean() && !Client.getInstance().getSettingsManager().getSettingByClass(NickHiderMod.class, "Use Real Skin For Self").getValBoolean()) { + if(Client.getInstance().getSettingsManager().getSettingByClass(NickHiderMod.class, "Use Own Skin For All").getValBoolean()) { + if(((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getPlayerInfo() != null) { + cir.setReturnValue(((NetworkPlayerInfoExt) ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getPlayerInfo()).silent$getSkinType() == null ? DefaultPlayerSkin.getSkinType(this.gameProfile.getId()) : ((NetworkPlayerInfoExt) ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getPlayerInfo()).silent$getSkinType()); + cir.cancel(); + return; + } else { + cir.setReturnValue(DefaultPlayerSkin.getSkinType(Minecraft.getMinecraft().thePlayer.getGameProfile().getId())); + cir.cancel(); + return; + } + } + if(this.gameProfile.getId().equals(Minecraft.getMinecraft().thePlayer.getGameProfile().getId()) && Client.getInstance().getSettingsManager().getSettingByClass(NickHiderMod.class, "Use Real Skin For Self").getValBoolean()) { + cir.setReturnValue(this.skinType == null ? DefaultPlayerSkin.getSkinType(this.gameProfile.getId()) : this.skinType); + cir.cancel(); + return; + } + + cir.setReturnValue(DefaultPlayerSkin.getSkinType(this.gameProfile.getId())); + cir.cancel(); + return; + } + } + + @Override + public String silent$getSkinType() { + return skinType; + } + + @Override + public Object silent$getLocationSkin() { + return locationSkin; } } diff --git a/src/main/java/net/silentclient/client/mixin/mixins/RenderGlobalMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/RenderGlobalMixin.java index 617c359..65c3878 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/RenderGlobalMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/RenderGlobalMixin.java @@ -1,23 +1,36 @@ package net.silentclient.client.mixin.mixins; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.renderer.RenderGlobal; -import net.minecraft.client.renderer.chunk.VisGraph; import net.minecraft.client.renderer.culling.ICamera; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.ResourceLocation; import net.silentclient.client.event.impl.RenderTickEvent; -import net.silentclient.client.mixin.ducks.VisGraphExt; import net.silentclient.client.mods.render.BlockOverlayMod; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(RenderGlobal.class) -public class RenderGlobalMixin { +public abstract class RenderGlobalMixin { + @Shadow @Final private Minecraft mc; + + @Shadow @Final private TextureManager renderEngine; + + @Shadow @Final private static ResourceLocation locationCloudsPng; + + @Shadow private WorldClient theWorld; + + @Shadow private int cloudTickCounter; + @Inject(method = "renderEntities", at = @At("HEAD")) public void tickEvent(Entity renderViewEntity, ICamera camera, float partialTicks, CallbackInfo ci) { new RenderTickEvent().call(); @@ -32,10 +45,4 @@ public class RenderGlobalMixin { { BlockOverlayMod.drawSelectionBox(player, movingObjectPositionIn, p_72731_3_, partialTicks); } - - @ModifyVariable(method = "getVisibleFacings", name = "visgraph", at = @At(value = "STORE", ordinal = 0)) - private VisGraph silent$setLimitScan(VisGraph visgraph) { - ((VisGraphExt) visgraph).silent$setLimitScan(true); - return visgraph; - } } diff --git a/src/main/java/net/silentclient/client/utils/CloudRenderer.java b/src/main/java/net/silentclient/client/utils/CloudRenderer.java new file mode 100644 index 0000000..4c68919 --- /dev/null +++ b/src/main/java/net/silentclient/client/utils/CloudRenderer.java @@ -0,0 +1,97 @@ +package net.silentclient.client.utils; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.silentclient.client.mods.settings.FPSBoostMod; + +public class CloudRenderer +{ + private static Frustum frustum; + + public static void setFrustum(final Frustum frustum) { + CloudRenderer.frustum = frustum; + } + + public static void renderFastClouds(final WorldRenderer bfd, final float n, final float n2, final float n3, final float n4, final float n5, final float n6) { + final double s = Minecraft.getMinecraft().getRenderViewEntity().posX; + final double t = Minecraft.getMinecraft().getRenderViewEntity().posY; + final double u = Minecraft.getMinecraft().getRenderViewEntity().posZ; + final boolean booleanValue = FPSBoostMod.basicEnabled(); + for (int i = -256; i < 256; i += 32) { + for (int j = -256; j < 256; j += 32) { + if (CloudRenderer.frustum.isBoxInFrustum(i + s, n + t - 2.0, j + u, i + 32 + s, n + t, j + 32 + u) || !booleanValue) { + bfd.pos((double)(i + 0), (double)n, (double)(j + 32)).tex((double)((i + 0) * 4.8828125E-4f + n2), (double)((j + 32) * 4.8828125E-4f + n3)).color(n4, n5, n6, 0.8f).endVertex(); + bfd.pos((double)(i + 32), (double)n, (double)(j + 32)).tex((double)((i + 32) * 4.8828125E-4f + n2), (double)((j + 32) * 4.8828125E-4f + n3)).color(n4, n5, n6, 0.8f).endVertex(); + bfd.pos((double)(i + 32), (double)n, (double)(j + 0)).tex((double)((i + 32) * 4.8828125E-4f + n2), (double)((j + 0) * 4.8828125E-4f + n3)).color(n4, n5, n6, 0.8f).endVertex(); + bfd.pos((double)(i + 0), (double)n, (double)(j + 0)).tex((double)((i + 0) * 4.8828125E-4f + n2), (double)((j + 0) * 4.8828125E-4f + n3)).color(n4, n5, n6, 0.8f).endVertex(); + } + } + } + } + + public static void renderFancyClouds(final WorldRenderer bfd, final Tessellator bfx, final float n, final float n2, final float n3, final float n4, final float n5, final float n6, final float n7, final float n8, final float n9, final float n10, final float n11, final float n12, final float n13, final float n14, final float n15, final float n16, final float n17) { + bfd.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL); + final double s = Minecraft.getMinecraft().getRenderViewEntity().posX; + final double t = Minecraft.getMinecraft().getRenderViewEntity().posY; + final double u = Minecraft.getMinecraft().getRenderViewEntity().posZ; + final boolean booleanValue = FPSBoostMod.basicEnabled(); + for (int i = -3; i <= 4; ++i) { + for (int j = -3; j <= 4; ++j) { + final float n18 = (float)(i * 8); + final float n19 = (float)(j * 8); + final float n20 = n18 - n16; + final float n21 = n19 - n17; + if (CloudRenderer.frustum.isBoxInFrustum(n20 * 12.0 + s, n + t, n21 * 12.0 + u, (n20 + 9.0f) * 12.0 + s, n + 4.0f + t, (n21 + 9.0f) * 12.0 + u) || !booleanValue) { + if (n > -5.0f) { + bfd.pos((double)(n20 + 0.0f), (double)(n + 0.0f), (double)(n21 + 8.0f)).tex((double)((n18 + 0.0f) * 0.00390625f + n2), (double)((n19 + 8.0f) * 0.00390625f + n3)).color(n7, n8, n9, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex(); + bfd.pos((double)(n20 + 8.0f), (double)(n + 0.0f), (double)(n21 + 8.0f)).tex((double)((n18 + 8.0f) * 0.00390625f + n2), (double)((n19 + 8.0f) * 0.00390625f + n3)).color(n7, n8, n9, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex(); + bfd.pos((double)(n20 + 8.0f), (double)(n + 0.0f), (double)(n21 + 0.0f)).tex((double)((n18 + 8.0f) * 0.00390625f + n2), (double)((n19 + 0.0f) * 0.00390625f + n3)).color(n7, n8, n9, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex(); + bfd.pos((double)(n20 + 0.0f), (double)(n + 0.0f), (double)(n21 + 0.0f)).tex((double)((n18 + 0.0f) * 0.00390625f + n2), (double)((n19 + 0.0f) * 0.00390625f + n3)).color(n7, n8, n9, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex(); + } + if (n <= 5.0f) { + bfd.pos((double)(n20 + 0.0f), (double)(n + 4.0f - 9.765625E-4f), (double)(n21 + 8.0f)).tex((double)((n18 + 0.0f) * 0.00390625f + n2), (double)((n19 + 8.0f) * 0.00390625f + n3)).color(n4, n5, n6, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex(); + bfd.pos((double)(n20 + 8.0f), (double)(n + 4.0f - 9.765625E-4f), (double)(n21 + 8.0f)).tex((double)((n18 + 8.0f) * 0.00390625f + n2), (double)((n19 + 8.0f) * 0.00390625f + n3)).color(n4, n5, n6, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex(); + bfd.pos((double)(n20 + 8.0f), (double)(n + 4.0f - 9.765625E-4f), (double)(n21 + 0.0f)).tex((double)((n18 + 8.0f) * 0.00390625f + n2), (double)((n19 + 0.0f) * 0.00390625f + n3)).color(n4, n5, n6, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex(); + bfd.pos((double)(n20 + 0.0f), (double)(n + 4.0f - 9.765625E-4f), (double)(n21 + 0.0f)).tex((double)((n18 + 0.0f) * 0.00390625f + n2), (double)((n19 + 0.0f) * 0.00390625f + n3)).color(n4, n5, n6, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex(); + } + if (i > -1) { + for (int k = 0; k < 8; ++k) { + bfd.pos((double)(n20 + k + 0.0f), (double)(n + 0.0f), (double)(n21 + 8.0f)).tex((double)((n18 + k + 0.5f) * 0.00390625f + n2), (double)((n19 + 8.0f) * 0.00390625f + n3)).color(n13, n14, n15, 0.8f).normal(-1.0f, 0.0f, 0.0f).endVertex(); + bfd.pos((double)(n20 + k + 0.0f), (double)(n + 4.0f), (double)(n21 + 8.0f)).tex((double)((n18 + k + 0.5f) * 0.00390625f + n2), (double)((n19 + 8.0f) * 0.00390625f + n3)).color(n13, n14, n15, 0.8f).normal(-1.0f, 0.0f, 0.0f).endVertex(); + bfd.pos((double)(n20 + k + 0.0f), (double)(n + 4.0f), (double)(n21 + 0.0f)).tex((double)((n18 + k + 0.5f) * 0.00390625f + n2), (double)((n19 + 0.0f) * 0.00390625f + n3)).color(n13, n14, n15, 0.8f).normal(-1.0f, 0.0f, 0.0f).endVertex(); + bfd.pos((double)(n20 + k + 0.0f), (double)(n + 0.0f), (double)(n21 + 0.0f)).tex((double)((n18 + k + 0.5f) * 0.00390625f + n2), (double)((n19 + 0.0f) * 0.00390625f + n3)).color(n13, n14, n15, 0.8f).normal(-1.0f, 0.0f, 0.0f).endVertex(); + } + } + if (i <= 1) { + for (int l = 0; l < 8; ++l) { + bfd.pos((double)(n20 + l + 1.0f - 9.765625E-4f), (double)(n + 0.0f), (double)(n21 + 8.0f)).tex((double)((n18 + l + 0.5f) * 0.00390625f + n2), (double)((n19 + 8.0f) * 0.00390625f + n3)).color(n13, n14, n15, 0.8f).normal(1.0f, 0.0f, 0.0f).endVertex(); + bfd.pos((double)(n20 + l + 1.0f - 9.765625E-4f), (double)(n + 4.0f), (double)(n21 + 8.0f)).tex((double)((n18 + l + 0.5f) * 0.00390625f + n2), (double)((n19 + 8.0f) * 0.00390625f + n3)).color(n13, n14, n15, 0.8f).normal(1.0f, 0.0f, 0.0f).endVertex(); + bfd.pos((double)(n20 + l + 1.0f - 9.765625E-4f), (double)(n + 4.0f), (double)(n21 + 0.0f)).tex((double)((n18 + l + 0.5f) * 0.00390625f + n2), (double)((n19 + 0.0f) * 0.00390625f + n3)).color(n13, n14, n15, 0.8f).normal(1.0f, 0.0f, 0.0f).endVertex(); + bfd.pos((double)(n20 + l + 1.0f - 9.765625E-4f), (double)(n + 0.0f), (double)(n21 + 0.0f)).tex((double)((n18 + l + 0.5f) * 0.00390625f + n2), (double)((n19 + 0.0f) * 0.00390625f + n3)).color(n13, n14, n15, 0.8f).normal(1.0f, 0.0f, 0.0f).endVertex(); + } + } + if (j > -1) { + for (int n22 = 0; n22 < 8; ++n22) { + bfd.pos((double)(n20 + 0.0f), (double)(n + 4.0f), (double)(n21 + n22 + 0.0f)).tex((double)((n18 + 0.0f) * 0.00390625f + n2), (double)((n19 + n22 + 0.5f) * 0.00390625f + n3)).color(n10, n11, n12, 0.8f).normal(0.0f, 0.0f, -1.0f).endVertex(); + bfd.pos((double)(n20 + 8.0f), (double)(n + 4.0f), (double)(n21 + n22 + 0.0f)).tex((double)((n18 + 8.0f) * 0.00390625f + n2), (double)((n19 + n22 + 0.5f) * 0.00390625f + n3)).color(n10, n11, n12, 0.8f).normal(0.0f, 0.0f, -1.0f).endVertex(); + bfd.pos((double)(n20 + 8.0f), (double)(n + 0.0f), (double)(n21 + n22 + 0.0f)).tex((double)((n18 + 8.0f) * 0.00390625f + n2), (double)((n19 + n22 + 0.5f) * 0.00390625f + n3)).color(n10, n11, n12, 0.8f).normal(0.0f, 0.0f, -1.0f).endVertex(); + bfd.pos((double)(n20 + 0.0f), (double)(n + 0.0f), (double)(n21 + n22 + 0.0f)).tex((double)((n18 + 0.0f) * 0.00390625f + n2), (double)((n19 + n22 + 0.5f) * 0.00390625f + n3)).color(n10, n11, n12, 0.8f).normal(0.0f, 0.0f, -1.0f).endVertex(); + } + } + if (j <= 1) { + for (int n23 = 0; n23 < 8; ++n23) { + bfd.pos((double)(n20 + 0.0f), (double)(n + 4.0f), (double)(n21 + n23 + 1.0f - 9.765625E-4f)).tex((double)((n18 + 0.0f) * 0.00390625f + n2), (double)((n19 + n23 + 0.5f) * 0.00390625f + n3)).color(n10, n11, n12, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex(); + bfd.pos((double)(n20 + 8.0f), (double)(n + 4.0f), (double)(n21 + n23 + 1.0f - 9.765625E-4f)).tex((double)((n18 + 8.0f) * 0.00390625f + n2), (double)((n19 + n23 + 0.5f) * 0.00390625f + n3)).color(n10, n11, n12, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex(); + bfd.pos((double)(n20 + 8.0f), (double)(n + 0.0f), (double)(n21 + n23 + 1.0f - 9.765625E-4f)).tex((double)((n18 + 8.0f) * 0.00390625f + n2), (double)((n19 + n23 + 0.5f) * 0.00390625f + n3)).color(n10, n11, n12, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex(); + bfd.pos((double)(n20 + 0.0f), (double)(n + 0.0f), (double)(n21 + n23 + 1.0f - 9.765625E-4f)).tex((double)((n18 + 0.0f) * 0.00390625f + n2), (double)((n19 + n23 + 0.5f) * 0.00390625f + n3)).color(n10, n11, n12, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex(); + } + } + } + } + } + bfx.draw(); + } +} diff --git a/src/main/java/net/silentclient/client/utils/NetworkPlayerInfoOptimization.java b/src/main/java/net/silentclient/client/utils/NetworkPlayerInfoOptimization.java new file mode 100644 index 0000000..bd25fc7 --- /dev/null +++ b/src/main/java/net/silentclient/client/utils/NetworkPlayerInfoOptimization.java @@ -0,0 +1,5 @@ +package net.silentclient.client.utils; + +public class NetworkPlayerInfoOptimization { + public static boolean isLoadingSkin = false; +} diff --git a/src/main/resources/mixins.SilentClient.json b/src/main/resources/mixins.SilentClient.json index 561bbfa..a230184 100644 --- a/src/main/resources/mixins.SilentClient.json +++ b/src/main/resources/mixins.SilentClient.json @@ -112,6 +112,8 @@ "mixins.RenderTNTPrimedMixin", "mixins.GuiDisconnectedMixin", "accessors.optifine.CustomColorsAccessor", - "accessors.optifine.ConfigAccessor" + "accessors.optifine.ConfigAccessor", + "mixins.NetworkPlayerInfoMixin", + "accessors.NetworkPlayerInfoAccessor" ] } \ No newline at end of file