a little 🧌ing

This commit is contained in:
0x3C50 2022-04-29 23:41:56 +02:00
parent b26818608b
commit c7499dc878
16 changed files with 251 additions and 203 deletions

View file

@ -42,7 +42,6 @@ public class Find extends Command {
public Find() {
super("Find", "Nocom 2 (requires creative)", "find", "findPlayer");
System.out.println("instanced");
Events.registerEventHandlerClass(this);
}

View file

@ -16,6 +16,7 @@ import net.shadow.client.helper.ShadowAPIWrapper;
import net.shadow.client.helper.event.EventType;
import net.shadow.client.helper.event.Events;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.nio.charset.StandardCharsets;
@ -45,13 +46,13 @@ public class OnlineAPI extends Command {
String session = FileUtils.readFileToString(SESSION_KEY_FILE, StandardCharsets.UTF_8);
if (!session.isEmpty()) {
if (ShadowAPIWrapper.loginWithKey(session)) {
System.out.println("recovered previous session from backup file");
ShadowMain.log(Level.INFO, "recovered previous session from backup file");
} else {
System.out.println("server said no to session recovery, moving on");
ShadowMain.log(Level.INFO, "server said no to session recovery, moving on");
}
}
} catch (Exception e) {
System.out.println("failed to recover session :(");
ShadowMain.log(Level.ERROR, "failed to recover session :(");
e.printStackTrace();
}
}

View file

@ -0,0 +1,113 @@
/*
* Copyright (c) Shadow client, 0x150, Saturn5VFive 2022. All rights reserved.
*/
package net.shadow.client.feature.gui.notifications.hudNotif;
import com.mojang.blaze3d.systems.RenderSystem;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Quaternion;
import net.shadow.client.helper.GameTexture;
import net.shadow.client.helper.Texture;
import net.shadow.client.helper.font.FontRenderers;
import net.shadow.client.helper.font.adapter.FontAdapter;
import net.shadow.client.helper.render.ClipStack;
import net.shadow.client.helper.render.Rectangle;
import net.shadow.client.helper.render.Renderer;
import java.awt.Color;
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public class HudNotification {
final String content;
final long duration;
final Type type;
long creation = System.currentTimeMillis();
double texDim = 16;
double pad = 2;
long fadeTime = 1200;
public static HudNotification create(String content, long duration, Type type) {
HudNotification n = new HudNotification(content, duration, type);
HudNotificationRenderer.instance.addNotification(n);
return n;
}
public long getRemainingLifeTime() {
return Math.max(0, (creation + duration) - System.currentTimeMillis());
}
public boolean isDead() {
return getRemainingLifeTime() == 0;
}
public double getHeight() {
return pad + Math.max(FontRenderers.getRenderer().getFontHeight(), texDim) + pad;
}
public double easeInOutBack(double x) {
double c1 = 1.70158;
double c2 = c1 * 1.525;
return x < 0.5
? (Math.pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2)) / 2
: (Math.pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2;
}
double getAnimProg() {
long remainingLife = getRemainingLifeTime();
long timeExpired = duration - remainingLife;
double animAccordingToTime = (double) Math.min(timeExpired, fadeTime) / fadeTime;
double animAccordingToRemaining = (double) Math.min(remainingLife, fadeTime) / fadeTime;
return Math.min(animAccordingToRemaining, animAccordingToTime) * 1.1;
}
public void render(MatrixStack stack, double x, double y) {
FontAdapter fa = FontRenderers.getRenderer();
double anim = getAnimProg();
double moveAnim = easeInOutBack(MathHelper.clamp(anim, 0, 0.5) * 2);
double expandAnim = easeInOutBack(MathHelper.clamp(anim, 0.1, 1.1) - .1);
double notifWidthWithText = Math.max(pad + fa.getStringWidth(content) + pad + texDim + pad, 100);
double notifWidthWithoutText = pad + texDim + pad;
double notifWidth = MathHelper.lerp(Math.max(expandAnim, 0), notifWidthWithoutText, notifWidthWithText);
double notifHeight = getHeight();
double rootX = x - notifWidth;
double rootY = MathHelper.lerp(moveAnim, -notifHeight, y);
Renderer.R2D.renderRoundedQuadWithShadow(stack, new Color(10, 10, 20), rootX, rootY, rootX + notifWidth, rootY + notifHeight, 3, 20);
RenderSystem.setShaderTexture(0, type.i);
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
stack.push();
stack.translate(rootX + notifWidth - pad - texDim + texDim / 2d, rootY + pad + texDim / 2d, 0);
stack.multiply(new Quaternion(0f, 0f, (float) (expandAnim * 360f), true));
Renderer.R2D.renderTexture(stack, -texDim / 2d, -texDim / 2d, texDim, texDim, 0, 0, texDim, texDim, texDim, texDim);
stack.pop();
ClipStack.globalInstance.addWindow(stack, new Rectangle(rootX + pad, rootY, rootX + notifWidth - pad - texDim - pad, rootY + notifHeight));
fa.drawString(stack, content, rootX + pad, rootY + notifHeight / 2d - fa.getFontHeight() / 2d, 0xFFFFFF);
ClipStack.globalInstance.popWindow();
}
public enum Type {
SUCCESS(GameTexture.NOTIF_SUCCESS.getWhere(), new Color(58, 223, 118)), INFO(GameTexture.NOTIF_INFO.getWhere(), new Color(39, 186, 253)),
WARNING(GameTexture.NOTIF_WARNING.getWhere(), new Color(255, 189, 17)), ERROR(GameTexture.NOTIF_ERROR.getWhere(), new Color(254, 92, 92));
final Color c;
final Texture i;
Type(Texture icon, Color color) {
this.i = icon;
this.c = color;
}
public Texture getI() {
return i;
}
public Color getC() {
return c;
}
}
}

View file

@ -0,0 +1,36 @@
/*
* Copyright (c) Shadow client, 0x150, Saturn5VFive 2022. All rights reserved.
*/
package net.shadow.client.feature.gui.notifications.hudNotif;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.MathHelper;
import net.shadow.client.ShadowMain;
import net.shadow.client.helper.render.MSAAFramebuffer;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class HudNotificationRenderer {
public static final HudNotificationRenderer instance = new HudNotificationRenderer();
List<HudNotification> notifs = new CopyOnWriteArrayList<>();
void addNotification(HudNotification notif) {
this.notifs.add(notif);
}
public void render(MatrixStack stack) {
notifs.removeIf(HudNotification::isDead);
double x = ShadowMain.client.getWindow().getScaledWidth() - 5;
final double[] y = {5};
MSAAFramebuffer.use(MSAAFramebuffer.MAX_SAMPLES, () -> {
for (HudNotification notif : notifs) {
notif.render(stack, x, y[0]);
double moveAnim = MathHelper.clamp(notif.easeInOutBack(MathHelper.clamp(notif.getAnimProg(), 0, 0.5) * 2), 0, 1);
y[0] += (notif.getHeight() + 5) * moveAnim;
}
});
}
}

View file

@ -15,14 +15,13 @@ import me.x150.authlib.login.mojang.profile.MinecraftProfile;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.NativeImageBackedTexture;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.client.util.Session;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.MathHelper;
import net.shadow.client.ShadowMain;
import net.shadow.client.feature.gui.FastTickable;
import net.shadow.client.feature.gui.notifications.hudNotif.HudNotification;
import net.shadow.client.feature.gui.widget.RoundButton;
import net.shadow.client.feature.gui.widget.RoundTextFieldWidget;
import net.shadow.client.helper.Texture;
@ -30,6 +29,7 @@ import net.shadow.client.helper.font.FontRenderers;
import net.shadow.client.helper.font.adapter.FontAdapter;
import net.shadow.client.helper.render.ClipStack;
import net.shadow.client.helper.render.MSAAFramebuffer;
import net.shadow.client.helper.render.PlayerHeadResolver;
import net.shadow.client.helper.render.Rectangle;
import net.shadow.client.helper.render.Renderer;
import net.shadow.client.helper.util.Transitions;
@ -37,19 +37,11 @@ import net.shadow.client.mixin.IMinecraftClientAccessor;
import net.shadow.client.mixin.SessionAccessor;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.Level;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL40C;
import javax.imageio.ImageIO;
import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
@ -89,7 +81,7 @@ public class AltManagerScreen extends ClientScreen implements FastTickable {
double scroll = 0;
double scrollSmooth = 0;
Texture currentAccountTexture = new Texture("dynamic/currentaccount");
boolean currentAccountTextureLoaded = false;
boolean currentAccountTextureLoaded = true;
private AltManagerScreen() {
super(MSAAFramebuffer.MAX_SAMPLES);
@ -233,32 +225,7 @@ public class AltManagerScreen extends ClientScreen implements FastTickable {
void updateCurrentAccount() {
UUID uid = ShadowMain.client.getSession().getProfile().getId();
if (texCache.containsKey(uid)) {
this.currentAccountTexture = texCache.get(uid);
currentAccountTextureLoaded = true;
return;
}
HttpRequest hr = HttpRequest.newBuilder().uri(URI.create("https://crafatar.com/avatars/" + uid + "?overlay")).header("User-Agent", "why").build();
downloader.sendAsync(hr, HttpResponse.BodyHandlers.ofByteArray()).thenAccept(httpResponse -> {
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ImageIO.write(ImageIO.read(new ByteArrayInputStream(httpResponse.body())), "png", stream);
byte[] bytes = stream.toByteArray();
ByteBuffer data = BufferUtils.createByteBuffer(bytes.length).put(bytes);
data.flip();
NativeImage img = NativeImage.read(data);
NativeImageBackedTexture texture = new NativeImageBackedTexture(img);
ShadowMain.client.execute(() -> {
ShadowMain.client.getTextureManager().registerTexture(currentAccountTexture, texture);
currentAccountTextureLoaded = true;
});
} catch (Exception e) {
e.printStackTrace();
}
});
this.currentAccountTexture = PlayerHeadResolver.resolve(uid);
}
void login() {
@ -270,11 +237,14 @@ public class AltManagerScreen extends ClientScreen implements FastTickable {
this.selectedAlt.login();
isLoggingIn.set(false);
if (!this.selectedAlt.storage.valid) {
HudNotification.create("Failed to log in", 5000, HudNotification.Type.ERROR);
return;
}
Session newSession = new Session(selectedAlt.storage.cachedName, selectedAlt.storage.cachedUuid.toString(), selectedAlt.storage.accessToken, Optional.empty(), Optional.empty(), Session.AccountType.MOJANG);
((IMinecraftClientAccessor) ShadowMain.client).setSession(newSession);
HudNotification.create("Logged into account " + newSession.getUsername(), 5000, HudNotification.Type.INFO);
updateCurrentAccount();
}).start();
}
@ -916,28 +886,7 @@ public class AltManagerScreen extends ClientScreen implements FastTickable {
}
void downloadTexture() {
HttpRequest hr = HttpRequest.newBuilder().uri(URI.create("https://crafatar.com/avatars/" + this.storage.cachedUuid + "?overlay")).header("User-Agent", "why").build();
downloader.sendAsync(hr, HttpResponse.BodyHandlers.ofByteArray()).thenAccept(httpResponse -> {
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ImageIO.write(ImageIO.read(new ByteArrayInputStream(httpResponse.body())), "png", stream);
byte[] bytes = stream.toByteArray();
ByteBuffer data = BufferUtils.createByteBuffer(bytes.length).put(bytes);
data.flip();
NativeImage img = NativeImage.read(data);
NativeImageBackedTexture texture = new NativeImageBackedTexture(img);
ShadowMain.client.execute(() -> {
this.tex = new Texture(("dynamic/tex_" + this.storage.cachedUuid.hashCode() + "_" + (Math.random() + "").split("\\.")[1]).toLowerCase());
ShadowMain.client.getTextureManager().registerTexture(this.tex, texture);
texCache.put(this.storage.cachedUuid, this.tex);
texLoaded = true;
});
} catch (Exception e) {
e.printStackTrace();
}
});
this.tex = PlayerHeadResolver.resolve(this.storage.cachedUuid);
}
public double getHeight() {
@ -1025,11 +974,7 @@ public class AltManagerScreen extends ClientScreen implements FastTickable {
RenderSystem.blendFunc(GL40C.GL_DST_ALPHA, GL40C.GL_ONE_MINUS_DST_ALPHA);
RenderSystem.setShaderTexture(0, tex);
if (texLoaded) {
Renderer.R2D.renderTexture(stack, originX + padding, originY + padding, texWidth, texHeight, 0, 0, 64, 64, 64, 64);
} else {
Renderer.R2D.renderTexture(stack, originX + padding, originY + padding, texWidth, texHeight, 8, 8, 8, 8, 64, 64); // default skin
}
Renderer.R2D.renderTexture(stack, originX + padding, originY + padding, texWidth, texHeight, 0, 0, 64, 64, 64, 64);
String mail;
if (this.storage.type != AddScreenOverlay.AccountType.CRACKED) {
mail = this.storage.email;

View file

@ -12,8 +12,6 @@ import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.screen.world.SelectWorldScreen;
import net.minecraft.client.realms.gui.screen.RealmsMainScreen;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.NativeImageBackedTexture;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.client.util.math.MatrixStack;
import net.shadow.client.ShadowMain;
@ -24,21 +22,14 @@ import net.shadow.client.helper.Texture;
import net.shadow.client.helper.font.FontRenderers;
import net.shadow.client.helper.font.adapter.FontAdapter;
import net.shadow.client.helper.render.MSAAFramebuffer;
import net.shadow.client.helper.render.PlayerHeadResolver;
import net.shadow.client.helper.render.Renderer;
import org.apache.commons.io.IOUtils;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL40C;
import javax.imageio.ImageIO;
import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.AbstractMap;
@ -108,7 +99,10 @@ public class HomeScreen extends ClientScreen {
buttonsMap.add(new AbstractMap.SimpleEntry<>("Singleplayer", () -> ShadowMain.client.setScreen(new SelectWorldScreen(this))));
buttonsMap.add(new AbstractMap.SimpleEntry<>("Multiplayer", () -> ShadowMain.client.setScreen(new MultiplayerScreen(this))));
buttonsMap.add(new AbstractMap.SimpleEntry<>("Realms", () -> ShadowMain.client.setScreen(new RealmsMainScreen(this))));
buttonsMap.add(new AbstractMap.SimpleEntry<>("Alts", () -> ShadowMain.client.setScreen(AltManagerScreen.instance())));
buttonsMap.add(new AbstractMap.SimpleEntry<>("Alts", () -> {
ShadowMain.client.setScreen(AltManagerScreen.instance());
// Notification.create(RandomStringUtils.randomPrint(20), RandomUtils.nextLong(4000, 7000), Notification.Type.INFO);
}));
buttonsMap.add(new AbstractMap.SimpleEntry<>("Settings", () -> ShadowMain.client.setScreen(new OptionsScreen(this, ShadowMain.client.options))));
buttonsMap.add(new AbstractMap.SimpleEntry<>("Quit", ShadowMain.client::scheduleStop));
// buttonsMap.add(new AbstractMap.SimpleEntry<>("reinit", this::init));
@ -155,30 +149,9 @@ public class HomeScreen extends ClientScreen {
return;
}
previousChecked = uid;
HttpRequest hr = HttpRequest.newBuilder().uri(URI.create("https://crafatar.com/avatars/" + uid + "?overlay")).header("User-Agent", "why").timeout(Duration.ofSeconds(5)).build();
downloader.sendAsync(hr, HttpResponse.BodyHandlers.ofByteArray()).thenAccept(httpResponse -> {
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ImageIO.write(ImageIO.read(new ByteArrayInputStream(httpResponse.body())), "png", stream);
byte[] bytes = stream.toByteArray();
ByteBuffer data = BufferUtils.createByteBuffer(bytes.length).put(bytes);
data.flip();
NativeImage img = NativeImage.read(data);
// System.out.println(img);
NativeImageBackedTexture texture = new NativeImageBackedTexture(img);
ShadowMain.client.execute(() -> {
ShadowMain.client.getTextureManager().registerTexture(currentAccountTexture, texture);
currentAccountTextureLoaded = true;
callback.run();
});
} catch (Exception e) {
e.printStackTrace();
callback.run();
}
});
PlayerHeadResolver.resolve(uid, this.currentAccountTexture);
currentAccountTextureLoaded = true;
callback.run();
}
@Override

View file

@ -13,6 +13,7 @@ import net.minecraft.client.gui.Selectable;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.util.math.MatrixStack;
import net.shadow.client.feature.gui.FastTickable;
import net.shadow.client.feature.gui.notifications.hudNotif.HudNotification;
import net.shadow.client.feature.gui.widget.RoundButton;
import net.shadow.client.feature.gui.widget.RoundTextFieldWidget;
import net.shadow.client.helper.IRCWebSocket;
@ -57,6 +58,7 @@ public class OnlineServicesDashboardScreen extends ClientScreen implements FastT
if (ShadowAPIWrapper.getAuthKey() != null) {
logs.clear();
logsSocket = new SimpleWebsocket(URI.create(ShadowAPIWrapper.BASE_WS + "/admin/logs"), Map.of("Authorization", ShadowAPIWrapper.getAuthKey()), () -> {
HudNotification.create("Websocket disconnected, reconnecting in 3 seconds", 3000, HudNotification.Type.INFO);
reconnectTime = System.currentTimeMillis() + Duration.ofSeconds(3).toMillis();
logs.clear();
}, this::socketMessageRecieved);
@ -152,6 +154,7 @@ public class OnlineServicesDashboardScreen extends ClientScreen implements FastT
BiConsumer<String, String> r;
RoundTextFieldWidget user, pass;
RoundButton reg;
public RegisterAccountViewer(double x, double y, double width, double height, BiConsumer<String, String> onReg) {
super("", "", x, y, width, height, () -> {
});

View file

@ -79,7 +79,6 @@ public class LoominaCrash extends Module {
void simplePacketMove(int slotId) {
//System.out.println(client.player.currentScreenHandler.getSlot(slotId).getStack().getName().getString());
ScreenHandler screenHandler = client.player.currentScreenHandler;
Int2ObjectOpenHashMap<ItemStack> int2ObjectMap = new Int2ObjectOpenHashMap<>();
int2ObjectMap.put(slotId, client.player.currentScreenHandler.getSlot(slotId).getStack().copy());

View file

@ -16,7 +16,7 @@ import net.shadow.client.helper.event.events.PacketEvent;
public class Equipper extends Module {
public Equipper() {
super("Equipper", "equips anything as armor", ModuleType.EXPLOIT);
super("Equipper", "Equips anything as armor", ModuleType.EXPLOIT);
}
@EventListener(type = EventType.PACKET_SEND)

View file

@ -20,6 +20,7 @@ import net.shadow.client.feature.module.ModuleType;
import net.shadow.client.helper.Texture;
import net.shadow.client.helper.font.FontRenderers;
import net.shadow.client.helper.manager.AttackManager;
import net.shadow.client.helper.render.PlayerHeadResolver;
import net.shadow.client.helper.render.Renderer;
import net.shadow.client.helper.util.Transitions;
import net.shadow.client.helper.util.Utils;
@ -150,7 +151,7 @@ public class TargetHud extends Module {
double textLeftAlign = 32 + 10;
Renderer.R2D.renderRoundedQuad(stack, new Color(20, 20, 20, 200), 0, 0, modalWidth, modalHeight, 5, 10);
Texture tex = new Texture(Utils.Textures.getSkinPreviewTexture(entity.getUuid()));
Texture tex = PlayerHeadResolver.resolve(entity.getUuid());
RenderSystem.setShaderTexture(0, tex);
RenderSystem.enableBlend();
@ -193,4 +194,3 @@ public class TargetHud extends Module {
}
}

View file

@ -46,7 +46,6 @@ public class ConfigContainer {
}
void write(String data) {
System.out.println("writing " + data);
try {
FileUtils.write(path, data, StandardCharsets.UTF_8);
} catch (Exception e) {

View file

@ -16,12 +16,6 @@ public class Cursor {
public static void setGlfwCursor(long cursor) {
if (currentCursor == cursor) return;
String cname = "(unknown)";
if (CLICK == cursor) cname = "CLICK";
if (STANDARD == cursor) cname = "STANDARD";
if (TEXT_EDIT == cursor) cname = "TEXT_EDIT";
if (HSLIDER == cursor) cname = "HSLIDER";
System.out.println("set cursor: 0x" + Long.toHexString(cursor).toUpperCase() + ": " + cname);
currentCursor = cursor;
GLFW.glfwSetCursor(ShadowMain.client.getWindow().getHandle(), cursor);
}

View file

@ -0,0 +1,69 @@
/*
* Copyright (c) Shadow client, 0x150, Saturn5VFive 2022. All rights reserved.
*/
package net.shadow.client.helper.render;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.NativeImageBackedTexture;
import net.shadow.client.ShadowMain;
import net.shadow.client.helper.Texture;
import org.lwjgl.BufferUtils;
import javax.imageio.ImageIO;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class PlayerHeadResolver {
static final NativeImageBackedTexture EMPTY = new NativeImageBackedTexture(1, 1, false);
static HttpClient client = HttpClient.newBuilder().followRedirects(HttpClient.Redirect.ALWAYS).build();
static Map<UUID, NativeImageBackedTexture> imageCache = new HashMap<>();
public static void resolve(UUID uuid, Texture texture) {
if (imageCache.containsKey(uuid)) {
ShadowMain.client.execute(() -> ShadowMain.client.getTextureManager().registerTexture(texture, imageCache.get(uuid)));
return;
}
imageCache.put(uuid, EMPTY);
ShadowMain.client.execute(() -> ShadowMain.client.getTextureManager().registerTexture(texture, EMPTY));
URI u = URI.create("https://mc-heads.net/avatar/" + uuid);
HttpRequest hr = HttpRequest.newBuilder().uri(u).header("user-agent", "shadow/1.0").build();
System.out.println("getting " + uuid.toString());
client.sendAsync(hr, HttpResponse.BodyHandlers.ofByteArray()).thenAccept(httpResponse -> {
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ImageIO.write(ImageIO.read(new ByteArrayInputStream(httpResponse.body())), "png", stream);
byte[] bytes = stream.toByteArray();
ByteBuffer data = BufferUtils.createByteBuffer(bytes.length).put(bytes);
data.flip();
NativeImage img = NativeImage.read(data);
NativeImageBackedTexture nib = new NativeImageBackedTexture(img);
ShadowMain.client.execute(() -> ShadowMain.client.getTextureManager().registerTexture(texture, nib));
imageCache.put(uuid, nib);
} catch (Exception e) {
e.printStackTrace();
}
}).exceptionally(throwable -> {
throwable.printStackTrace();
return null;
});
}
public static Texture resolve(UUID uuid) {
Texture tex = new Texture(String.format("skin_preview-%s", uuid.toString()));
resolve(uuid, tex);
return tex;
}
}

View file

@ -15,6 +15,7 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.RaycastContext;
import net.shadow.client.ShadowMain;
import net.shadow.client.feature.gui.DoesMSAA;
import net.shadow.client.feature.gui.notifications.hudNotif.HudNotificationRenderer;
import net.shadow.client.feature.gui.screen.ClientScreen;
import net.shadow.client.feature.module.Module;
import net.shadow.client.feature.module.ModuleRegistry;
@ -107,4 +108,9 @@ public class GameRendererMixin {
double zv = ModuleRegistry.getByClass(Zoom.class).getZoomValue(cir.getReturnValue());
cir.setReturnValue(zv);
}
@Inject(method = "render", at = @At("RETURN"))
void a(float tickDelta, long startTime, boolean tick, CallbackInfo ci) {
HudNotificationRenderer.instance.render(Renderer.R3D.getEmptyMatrixStack());
}
}

View file

@ -1,88 +0,0 @@
/*
* Copyright (c) Shadow client, 0x150, Saturn5VFive 2022. All rights reserved.
*/
package net.shadow.client.mixin;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import net.minecraft.client.texture.PlayerSkinProvider;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
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.LocalCapture;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Map;
@Mixin(PlayerSkinProvider.class)
public class PlayerSkinMixin {
private static JsonObject capes;
@Shadow
@Final
private MinecraftSessionService sessionService;
//I cant even launch mc with this! it doesnt work
// skill issue, i would say
@Inject(method = "method_4653", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/MinecraftClient;execute(Ljava/lang/Runnable;)V",
shift = At.Shift.BEFORE
), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
void real(GameProfile gameProfile, boolean bl, PlayerSkinProvider.SkinTextureAvailableCallback skinTextureAvailableCallback, CallbackInfo ci, Map<Type, MinecraftProfileTexture> map) {
addCape(gameProfile, map);
}
private void addCape(GameProfile profile,
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map) {
String name = profile.getName();
String uuid = profile.getId().toString();
try {
if (capes == null)
setupCapes();
if (capes.has(name)) {
String capeURL = capes.get(name).getAsString();
map.put(Type.CAPE, new MinecraftProfileTexture(capeURL, null));
} else if (capes.has(uuid)) {
String capeURL = capes.get(uuid).getAsString();
map.put(Type.CAPE, new MinecraftProfileTexture(capeURL, null));
}
} catch (Exception e) {
System.err.println("[Shadow] Failed to load cape for '" + name
+ "' (" + uuid + ")");
e.printStackTrace();
}
}
private void setupCapes() {
try {
URL url = new URL("https://moleapi.pythonanywhere.com/retrieve");
capes = JsonParser.parseReader(new InputStreamReader(url.openStream())).getAsJsonObject();
} catch (Exception e) {
System.err.println("[Shadow] Failed to load capes from API");
e.printStackTrace();
}
}
@Shadow
private Identifier loadSkin(MinecraftProfileTexture profileTexture,
Type type,
@Nullable PlayerSkinProvider.SkinTextureAvailableCallback callback) {
return null;
}
}

View file

@ -57,7 +57,6 @@
"PlayerEntityMixin",
"PlayerEntityRendererMixin",
"PlayerInteractEntityC2SPacketAccessor",
"PlayerSkinMixin",
"RebuildTaskMixin",
"ScreenMixin",
"SelectWorldScreenMixin",