smooth pogress screen and other shit

This commit is contained in:
0x151 2022-02-03 22:17:39 +01:00
parent 577ac7638a
commit 0b8f5e8326
19 changed files with 150 additions and 152 deletions

View file

@ -27,7 +27,7 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
// modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
// modImplementation ("net.fabricmc.fabric-api:fabric-resource-loader:0.1.0")
impl(name: "xauthlib-1.0.0")

View file

@ -6,6 +6,7 @@ import me.x150.sipprivate.feature.gui.notifications.NotificationRenderer;
import me.x150.sipprivate.feature.module.Module;
import me.x150.sipprivate.feature.module.ModuleRegistry;
import me.x150.sipprivate.helper.Rotations;
import me.x150.sipprivate.helper.Texture;
import me.x150.sipprivate.helper.event.EventType;
import me.x150.sipprivate.helper.event.Events;
import me.x150.sipprivate.helper.event.events.PostInitEvent;
@ -18,19 +19,11 @@ import me.x150.sipprivate.helper.util.Utils;
import net.fabricmc.api.ModInitializer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Element;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
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.util.ArrayList;
import java.util.List;
@ -42,13 +35,14 @@ public class CoffeeClientMain implements ModInitializer {
public static final Logger LOGGER = LogManager.getLogger();
public static final MinecraftClient client = MinecraftClient.getInstance();
public static final File BASE = new File(MinecraftClient.getInstance().runDirectory, "sip");
public static final List<ResourceEntry> resources = List.of(
new ResourceEntry(new Identifier("coffeeclient", "background.jpg"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/background.jpg"),
new ResourceEntry(new Identifier("coffeeclient", "notification/error.png"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/error.png"),
new ResourceEntry(new Identifier("coffeeclient", "notification/info.png"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/info.png"),
new ResourceEntry(new Identifier("coffeeclient", "notification/success.png"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/success.png"),
new ResourceEntry(new Identifier("coffeeclient", "notification/warning.png"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/warning.png")
);
// public static final List<ResourceEntry> resources = List.of(
// new ResourceEntry(new Texture("background.jpg"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/background.jpg"),
// new ResourceEntry(new Texture("notif/error.png"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/error.png"),
// new ResourceEntry(new Texture("notif/info.png"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/info.png"),
// new ResourceEntry(new Texture("notif/success.png"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/success.png"),
// new ResourceEntry(new Texture("notif/warning.png"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/warning.png")
// );
public static final List<ResourceEntry> resources = new ArrayList<>();
public static long lastScreenChange = System.currentTimeMillis();
public static CoffeeClientMain INSTANCE;
public static Thread MODULE_FTTICKER;
@ -59,29 +53,21 @@ public class CoffeeClientMain implements ModInitializer {
LOGGER.log(level, "[" + MOD_NAME + "] " + message);
}
public void downloadAndRegisterTextures() {
HttpClient downloader = HttpClient.newHttpClient();
for (ResourceEntry resource : resources) {
log(Level.INFO, "Downloading " + resource.url);
try {
HttpRequest hrq = HttpRequest.newBuilder()
.uri(URI.create(resource.url))
.build();
HttpResponse<byte[]> b = downloader.send(hrq, HttpResponse.BodyHandlers.ofByteArray());
BufferedImage bi = ImageIO.read(new ByteArrayInputStream(b.body()));
Utils.registerBufferedImageTexture(resource.tex, bi);
log(Level.INFO, "Downloaded " + resource.url);
} catch (Exception ignored) {
log(Level.ERROR, "Failed to download " + resource.url);
}
}
public static void registerTexture(ResourceEntry entry) {
resources.add(entry);
}
@Override
public void onInitialize() {
INSTANCE = this;
log(Level.INFO, "Initializing");
registerTexture(new ResourceEntry(new Texture("background.jpg"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/background.jpg"));
registerTexture(new ResourceEntry(new Texture("notif/error.png"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/error.png"));
registerTexture(new ResourceEntry(new Texture("notif/info.png"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/info.png"));
registerTexture(new ResourceEntry(new Texture("notif/success.png"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/success.png"));
registerTexture(new ResourceEntry(new Texture("notif/warning.png"), "https://gitlab.com/0x151/coffee-fs/-/raw/main/warning.png"));
Runtime.getRuntime().addShutdownHook(new Thread(ConfigManager::saveState));
if (BASE.exists() && !BASE.isDirectory()) {
BASE.delete();
@ -175,7 +161,7 @@ public class CoffeeClientMain implements ModInitializer {
Events.fireEvent(EventType.POST_INIT, new PostInitEvent());
}
public record ResourceEntry(Identifier tex, String url) {
public record ResourceEntry(Texture tex, String url) {
}
}

View file

@ -3,8 +3,8 @@ package me.x150.sipprivate.feature.command.impl;
import me.x150.sipprivate.feature.command.Command;
import me.x150.sipprivate.feature.module.ModuleRegistry;
import me.x150.sipprivate.feature.module.impl.exploit.SkinChangeExploit;
import me.x150.sipprivate.helper.Texture;
import me.x150.sipprivate.helper.util.Utils;
import net.minecraft.util.Identifier;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
@ -57,7 +57,7 @@ public class SkinExploit extends Command {
if (bi == null) {
throw new IllegalStateException("Invalid image data");
}
Identifier e = new Identifier("atomic", "fakeskintex");
Texture e = new Texture("fakeskintex");
Utils.registerBufferedImageTexture(e, bi);
ModuleRegistry.getByClass(SkinChangeExploit.class).skinId = e;
success("Set skin texture! Enable the module to change everyone's skin");

View file

@ -3,12 +3,12 @@ package me.x150.sipprivate.feature.command.impl;
import com.google.gson.Gson;
import me.x150.sipprivate.CoffeeClientMain;
import me.x150.sipprivate.feature.command.Command;
import me.x150.sipprivate.helper.Texture;
import me.x150.sipprivate.helper.event.EventType;
import me.x150.sipprivate.helper.event.Events;
import me.x150.sipprivate.helper.util.Utils;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.NativeImageBackedTexture;
import net.minecraft.util.Identifier;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.Level;
import org.lwjgl.BufferUtils;
@ -236,7 +236,7 @@ public class Taco extends Command {
public static class Frame {
static long frameCounter = 0;
NativeImageBackedTexture tex;
Identifier i;
Texture i;
public Frame(BufferedImage image) {
try {
@ -248,7 +248,8 @@ public class Taco extends Command {
data.flip();
tex = new NativeImageBackedTexture(NativeImage.read(data));
i = new Identifier("atomic", "tacoframe_" + frameCounter);
// i = new Identifier("atomic", "tacoframe_" + frameCounter);
i = new Texture("taco/frame_" + frameCounter);
frameCounter++;
CoffeeClientMain.client.execute(() -> CoffeeClientMain.client.getTextureManager().registerTexture(i, tex));
} catch (Exception e) {
@ -257,7 +258,7 @@ public class Taco extends Command {
}
}
public Identifier getI() {
public Texture getI() {
return i;
}

View file

@ -2,11 +2,11 @@ package me.x150.sipprivate.feature.gui.hud.element;
import com.mojang.blaze3d.systems.RenderSystem;
import me.x150.sipprivate.CoffeeClientMain;
import me.x150.sipprivate.helper.Texture;
import me.x150.sipprivate.helper.font.FontRenderers;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
public class Taco extends HudElement {
public Taco() {
@ -23,7 +23,7 @@ public class Taco extends HudElement {
FontRenderers.getMono().drawString(stack, "Nothing to taco", 0, 0, 0xFFFFFF);
return;
}
Identifier current = frame.getI();
Texture current = frame.getI();
RenderSystem.disableBlend();
RenderSystem.setShaderTexture(0, current);

View file

@ -5,8 +5,8 @@
package me.x150.sipprivate.feature.gui.notifications;
import me.x150.sipprivate.helper.Texture;
import me.x150.sipprivate.helper.font.FontRenderers;
import net.minecraft.util.Identifier;
import java.awt.*;
import java.util.ArrayList;
@ -80,19 +80,19 @@ public class Notification {
}
public enum Type {
SUCCESS(new Identifier("coffeeclient", "notification/success.png"), new Color(58, 223, 118)),
INFO(new Identifier("coffeeclient", "notification/info.png"), new Color(39, 186, 253)),
WARNING(new Identifier("coffeeclient", "notification/warning.png"), new Color(255, 189, 17)),
ERROR(new Identifier("coffeeclient", "notification/error.png"), new Color(254, 92, 92));
SUCCESS(new Texture("notif/success.png"), new Color(58, 223, 118)),
INFO(new Texture("notif/info.png"), new Color(39, 186, 253)),
WARNING(new Texture("notif/warning.png"), new Color(255, 189, 17)),
ERROR(new Texture("notif/error.png"), new Color(254, 92, 92));
Color c;
Identifier i;
Texture i;
Type(Identifier icon, Color color) {
Type(Texture icon, Color color) {
this.i = icon;
this.c = color;
}
public Identifier getI() {
public Texture getI() {
return i;
}

View file

@ -12,6 +12,7 @@ import me.x150.sipprivate.CoffeeClientMain;
import me.x150.sipprivate.feature.gui.FastTickable;
import me.x150.sipprivate.feature.gui.widget.RoundButton;
import me.x150.sipprivate.feature.gui.widget.RoundTextFieldWidget;
import me.x150.sipprivate.helper.Texture;
import me.x150.sipprivate.helper.font.FontRenderers;
import me.x150.sipprivate.helper.font.adapter.FontAdapter;
import me.x150.sipprivate.helper.font.adapter.impl.ClientFontRenderer;
@ -28,7 +29,6 @@ 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.Identifier;
import net.minecraft.util.math.MathHelper;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.Level;
@ -52,7 +52,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
public class AltManagerScreen extends ClientScreen implements FastTickable {
public static final Map<UUID, Identifier> texCache = new HashMap<>();
public static final Map<UUID, Texture> texCache = new HashMap<>();
static final File ALTS_FILE = new File(CoffeeClientMain.BASE, "alts.sip");
static final String TOP_NOTE = """
// DO NOT SHARE THIS FILE
@ -77,7 +77,7 @@ public class AltManagerScreen extends ClientScreen implements FastTickable {
boolean censorEmail = true;
double scroll = 0;
double scrollSmooth = 0;
Identifier currentAccountTexture = new Identifier("coffee", "tex_currentaccount");
Texture currentAccountTexture = new Texture("dynamic/currentaccount");
boolean currentAccountTextureLoaded = false;
private AltManagerScreen() {
@ -723,7 +723,7 @@ public class AltManagerScreen extends ClientScreen implements FastTickable {
public class AltContainer {
final AltStorage storage;
Identifier tex;
Texture tex;
boolean texLoaded = false;
float animProgress = 0;
boolean isHovered = false;
@ -732,7 +732,7 @@ public class AltManagerScreen extends ClientScreen implements FastTickable {
public AltContainer(double x, double y, double width, AltStorage inner) {
this.storage = inner;
this.tex = DefaultSkinHelper.getTexture(inner.cachedUuid);
this.tex = new Texture(DefaultSkinHelper.getTexture(inner.cachedUuid));
this.x = x;
this.y = y;
this.width = width;
@ -758,7 +758,7 @@ public class AltManagerScreen extends ClientScreen implements FastTickable {
NativeImageBackedTexture texture = new NativeImageBackedTexture(img);
CoffeeClientMain.client.execute(() -> {
this.tex = new Identifier("coffee", ("tex_" + this.storage.cachedUuid.hashCode() + "_" + (Math.random() + "").split("\\.")[1]).toLowerCase());
this.tex = new Texture(("dynamic/tex_" + this.storage.cachedUuid.hashCode() + "_" + (Math.random() + "").split("\\.")[1]).toLowerCase());
CoffeeClientMain.client.getTextureManager().registerTexture(this.tex, texture);
texCache.put(this.storage.cachedUuid, this.tex);
texLoaded = true;

View file

@ -4,6 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import me.x150.sipprivate.CoffeeClientMain;
import me.x150.sipprivate.feature.gui.FastTickable;
import me.x150.sipprivate.feature.gui.widget.RoundButton;
import me.x150.sipprivate.helper.Texture;
import me.x150.sipprivate.helper.font.FontRenderers;
import me.x150.sipprivate.helper.font.adapter.impl.ClientFontRenderer;
import me.x150.sipprivate.helper.render.MSAAFramebuffer;
@ -18,7 +19,6 @@ 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.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import org.apache.commons.io.IOUtils;
import org.lwjgl.BufferUtils;
@ -40,7 +40,7 @@ import java.util.UUID;
public class HomeScreen extends ClientScreen implements FastTickable {
static final double padding = 5;
static final Identifier background = new Identifier("coffeeclient", "background.jpg");
static final Texture background = new Texture("background.jpg");
static final HttpClient downloader = HttpClient.newHttpClient();
static boolean isDev = false;
static String version = "unknown";
@ -49,7 +49,7 @@ public class HomeScreen extends ClientScreen implements FastTickable {
final ClientFontRenderer title = FontRenderers.getCustomNormal(40);
final ClientFontRenderer smaller = FontRenderers.getCustomNormal(30);
final ClientFontRenderer propFr = FontRenderers.getCustomNormal(22);
final Identifier currentAccountTexture = new Identifier("coffee", "tex_currentaccount_home");
final Texture currentAccountTexture = new Texture("dynamic/tex_currentaccount_home");
boolean loaded = false;
long initTime = System.currentTimeMillis();
double prog = 0;

View file

@ -1,5 +1,6 @@
package me.x150.sipprivate.feature.gui.screen;
import com.google.common.util.concurrent.AtomicDouble;
import me.x150.sipprivate.CoffeeClientMain;
import me.x150.sipprivate.feature.gui.FastTickable;
import me.x150.sipprivate.helper.font.FontRenderers;
@ -15,11 +16,11 @@ import org.apache.logging.log4j.Level;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.io.ByteArrayOutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.concurrent.atomic.AtomicBoolean;
public class LoadingScreen extends ClientScreen implements FastTickable {
@ -28,7 +29,8 @@ public class LoadingScreen extends ClientScreen implements FastTickable {
static Color RED = new Color(255, 50, 20);
AtomicBoolean loaded = new AtomicBoolean(false);
AtomicBoolean loadInProg = new AtomicBoolean(false);
double progress = 0;
// double progress = 0;
volatile AtomicDouble progress = new AtomicDouble();
double smoothProgress = 0;
double opacity = 1;
ClientFontRenderer title = FontRenderers.getCustomNormal(40);
@ -53,7 +55,8 @@ public class LoadingScreen extends ClientScreen implements FastTickable {
@Override
public void onFastTick() {
smoothProgress = Transitions.transition(smoothProgress, progress, 10, 0.0001);
smoothProgress = Transitions.transition(smoothProgress, progress.get(), 10, 0.0001);
// smoothProgress = progress.get();
if (CoffeeClientMain.client.getOverlay() == null) {
if (!loadInProg.get()) {
load();
@ -69,22 +72,39 @@ public class LoadingScreen extends ClientScreen implements FastTickable {
void load() {
loadInProg.set(true);
new Thread(() -> {
HttpClient downloader = HttpClient.newHttpClient();
for (int i = 0; i < CoffeeClientMain.resources.size(); i++) {
double progressBefore = i / ((double) CoffeeClientMain.resources.size());
double completedProgress = (i + 1) / ((double) CoffeeClientMain.resources.size());
CoffeeClientMain.ResourceEntry resource = CoffeeClientMain.resources.get(i);
CoffeeClientMain.log(Level.INFO, "Downloading " + resource.url());
try {
HttpRequest hrq = HttpRequest.newBuilder()
.uri(URI.create(resource.url()))
.build();
HttpResponse<byte[]> b = downloader.send(hrq, HttpResponse.BodyHandlers.ofByteArray());
BufferedImage bi = ImageIO.read(new ByteArrayInputStream(b.body()));
URL url = new URL(resource.url());
HttpURLConnection httpConnection = (HttpURLConnection) (url.openConnection());
long completeFileSize = httpConnection.getContentLength();
BufferedInputStream in = new BufferedInputStream(httpConnection.getInputStream());
ByteArrayOutputStream bout = new ByteArrayOutputStream();
byte[] data = new byte[16];
long downloadedFileSize = 0;
int x;
while ((x = in.read(data, 0, 16)) >= 0) {
downloadedFileSize += x;
double currentProgress = ((double) downloadedFileSize) / ((double) completeFileSize);
progress.set(MathHelper.lerp(currentProgress, progressBefore, completedProgress));
bout.write(data, 0, x);
}
bout.close();
in.close();
byte[] imageBuffer = bout.toByteArray();
BufferedImage bi = ImageIO.read(new ByteArrayInputStream(imageBuffer));
Utils.registerBufferedImageTexture(resource.tex(), bi);
CoffeeClientMain.log(Level.INFO, "Downloaded " + resource.url());
} catch (Exception ignored) {
CoffeeClientMain.log(Level.ERROR, "Failed to download " + resource.url());
} catch (Exception e) {
CoffeeClientMain.log(Level.ERROR, "Failed to download " + resource.url() + ": " + e.getMessage());
} finally {
progress = i / ((double) CoffeeClientMain.resources.size() - 1);
progress.set(MathHelper.lerp(1, progressBefore, completedProgress));
}
}
loaded.set(true);

View file

@ -3,11 +3,11 @@ package me.x150.sipprivate.feature.module.impl.exploit;
import me.x150.sipprivate.feature.gui.notifications.Notification;
import me.x150.sipprivate.feature.module.Module;
import me.x150.sipprivate.feature.module.ModuleType;
import me.x150.sipprivate.helper.Texture;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
public class SkinChangeExploit extends Module {
public Identifier skinId;
public Texture skinId;
public SkinChangeExploit() {
super("SkinChangeExploit", "Exploits the skin handler to set skins of everyone to a specific skin", ModuleType.EXPLOIT);

View file

@ -1,23 +1,25 @@
package me.x150.sipprivate.feature.module.impl.fun;
import me.x150.sipprivate.CoffeeClientMain;
import io.netty.buffer.Unpooled;
import me.x150.sipprivate.feature.module.Module;
import me.x150.sipprivate.feature.module.ModuleType;
import me.x150.sipprivate.helper.render.Renderer;
import me.x150.sipprivate.helper.event.EventType;
import me.x150.sipprivate.helper.event.Events;
import me.x150.sipprivate.helper.event.events.PacketEvent;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.network.PacketByteBuf;
public class Test extends Module {
Vec3d epos;
List<AnimatedCircle> ac = new ArrayList<>();
public Test() {
super("Test", "Testing stuff with the client, can be ignored", ModuleType.FUN);
Events.registerEventHandler(EventType.PACKET_RECEIVE, event -> {
if (!this.isEnabled()) return;
PacketEvent pe = (PacketEvent) event;
PacketByteBuf buffer = new PacketByteBuf(Unpooled.buffer());
pe.getPacket().write(buffer);
System.out.println(pe.getPacket().getClass().getSimpleName() + " - " + new String(buffer.getWrittenBytes()).replaceAll("\\p{C}", "."));
});
}
@Override
@ -27,15 +29,7 @@ public class Test extends Module {
@Override
public void enable() {
epos = CoffeeClientMain.client.player.getPos();
ac.clear();
for (int i = 0; i < 3; i++) {
double initialProg = i / 3d;
AnimatedCircle a = new AnimatedCircle();
a.spawnPos = epos;
a.animProg = initialProg;
ac.add(a);
}
}
@Override
@ -48,44 +42,12 @@ public class Test extends Module {
return null;
}
@Override
public void onFastTick() {
for (AnimatedCircle animatedCircle : ac) {
animatedCircle.tick();
}
super.onFastTick();
}
@Override
public void onWorldRender(MatrixStack matrices) {
for (AnimatedCircle animatedCircle : ac) {
animatedCircle.render(matrices);
}
}
@Override
public void onHudRender() {
}
static class AnimatedCircle {
double animProg = 0;
Vec3d spawnPos;
Color a = new Color(197, 37, 37);
Color b = new Color(200, 200, 200, 0);
public void render(MatrixStack stack) {
double progI = animProg * 2;
double expandProg = progI / 2d; // 0-2 of 0-2 as 0-1
double colorProg = MathHelper.clamp(progI - 1, 0, 1); // 1-2 of 0-2 as 0-1
Color color = Renderer.Util.lerp(b, a, colorProg);
double width = expandProg * 5;
Renderer.R3D.renderCircleOutline(stack, color, spawnPos, width, 0.03, 50);
}
void tick() {
animProg += 0.005;
animProg %= 1;
}
}
}

View file

@ -113,7 +113,6 @@ public class ESP extends Module {
}
for (Entity entity : CoffeeClientMain.client.world.getEntities()) {
if (entity.squaredDistanceTo(CoffeeClientMain.client.player) > Math.pow(range.getValue(), 2)) {
continue;

View file

@ -9,7 +9,6 @@ import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec2f;
import net.minecraft.util.math.Vec3d;
import java.awt.*;
@ -36,27 +35,27 @@ public class NameTags extends Module {
public void render(MatrixStack stack, AbstractClientPlayerEntity entity, Text text) {
String t = text.getString();
double healthHeight = 2;
double labelHeight = 2+FontRenderers.getNormal().getFontHeight()+2+healthHeight+2;
Vec3d headPos = Utils.getInterpolatedEntityPosition(entity).add(0,entity.getHeight()*2+0.3, 0);
double labelHeight = 2 + FontRenderers.getNormal().getFontHeight() + 2 + healthHeight + 2;
Vec3d headPos = Utils.getInterpolatedEntityPosition(entity).add(0, entity.getHeight() * 2 + 0.3, 0);
Vec3d a = Renderer.R2D.getScreenSpaceCoordinate(headPos, stack);
if (Renderer.R2D.isOnScreen(a)) {
Utils.TickManager.runOnNextRender(() -> {
MatrixStack stack1 = Renderer.R3D.getEmptyMatrixStack();
Vec3d actual = new Vec3d(a.x,a.y-labelHeight,a.z);
float fontWidth = FontRenderers.getNormal().getStringWidth(t)+1+4;
Vec3d actual = new Vec3d(a.x, a.y - labelHeight, a.z);
float fontWidth = FontRenderers.getNormal().getStringWidth(t) + 1 + 4;
float width = fontWidth;
width = Math.max(width, 60);
Renderer.R2D.renderRoundedQuad(stack1,new Color(0,0,0,200),actual.x-width/2d,actual.y,actual.x+width/2d,actual.y+labelHeight,3,20);
Renderer.R2D.renderRoundedQuad(stack1, new Color(0, 0, 0, 200), actual.x - width / 2d, actual.y, actual.x + width / 2d, actual.y + labelHeight, 3, 20);
// FontRenderers.getNormal().drawCenteredString(stack,t,actual.x,actual.y+2,0xFFFFFF);
FontRenderers.getNormal().drawString(stack1,t,actual.x-fontWidth/2d+2,actual.y+2,0xFFFFFF);
Renderer.R2D.renderRoundedQuad(stack1, new Color(60,60,60,255),actual.x-width/2d+2,actual.y+labelHeight-2-healthHeight,actual.x+width/2d-2,actual.y+labelHeight-2,healthHeight/2d,10);
FontRenderers.getNormal().drawString(stack1, t, actual.x - fontWidth / 2d + 2, actual.y + 2, 0xFFFFFF);
Renderer.R2D.renderRoundedQuad(stack1, new Color(60, 60, 60, 255), actual.x - width / 2d + 2, actual.y + labelHeight - 2 - healthHeight, actual.x + width / 2d - 2, actual.y + labelHeight - 2, healthHeight / 2d, 10);
float health = entity.getHealth();
float maxHealth = entity.getMaxHealth();
float healthPer = health/maxHealth;
float healthPer = health / maxHealth;
healthPer = MathHelper.clamp(healthPer, 0, 1);
double drawTo = MathHelper.lerp(healthPer,actual.x-width/2d+2+healthHeight,actual.x+width/2d-2);
double drawTo = MathHelper.lerp(healthPer, actual.x - width / 2d + 2 + healthHeight, actual.x + width / 2d - 2);
Color MID_END = Renderer.Util.lerp(GREEN, RED, healthPer);
Renderer.R2D.renderRoundedQuad(stack1, MID_END,actual.x-width/2d+2,actual.y+labelHeight-2-healthHeight,drawTo,actual.y+labelHeight-2,healthHeight/2d,10);
Renderer.R2D.renderRoundedQuad(stack1, MID_END, actual.x - width / 2d + 2, actual.y + labelHeight - 2 - healthHeight, drawTo, actual.y + labelHeight - 2, healthHeight / 2d, 10);
});
}
}

View file

@ -10,6 +10,7 @@ import me.x150.sipprivate.CoffeeClientMain;
import me.x150.sipprivate.feature.config.BooleanSetting;
import me.x150.sipprivate.feature.module.Module;
import me.x150.sipprivate.feature.module.ModuleType;
import me.x150.sipprivate.helper.Texture;
import me.x150.sipprivate.helper.font.FontRenderers;
import me.x150.sipprivate.helper.manager.AttackManager;
import me.x150.sipprivate.helper.render.Renderer;
@ -22,7 +23,6 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import org.lwjgl.opengl.GL40C;
@ -152,7 +152,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);
Identifier tex = Utils.Textures.getSkinPreviewTexture(entity.getUuid());
Texture tex = new Texture(Utils.Textures.getSkinPreviewTexture(entity.getUuid()));
RenderSystem.setShaderTexture(0, tex);
RenderSystem.enableBlend();
@ -179,8 +179,8 @@ public class TargetHud extends Module {
float mhealth = (float) trackedMaxHp;
float health = (float) trackedHp;
float hPer = health / mhealth;
hPer = MathHelper.clamp(hPer,0,1);
double renderToX = MathHelper.lerp(hPer,textLeftAlign,modalWidth-5);
hPer = MathHelper.clamp(hPer, 0, 1);
double renderToX = MathHelper.lerp(hPer, textLeftAlign, modalWidth - 5);
Color MID_END = Renderer.Util.lerp(GREEN, RED, hPer);
double pillHeight = 2;

View file

@ -0,0 +1,22 @@
package me.x150.sipprivate.helper;
import net.minecraft.util.Identifier;
public class Texture extends Identifier {
public Texture(String path) {
super("coffee", validatePath(path));
}
public Texture(Identifier i) {
super(i.getNamespace(), i.getPath());
}
static String validatePath(String path) {
if (isValid(path)) return path;
StringBuilder ret = new StringBuilder();
for (char c : path.toLowerCase().toCharArray()) {
if (isPathCharacterValid(c)) ret.append(c);
}
return ret.toString();
}
}

View file

@ -9,6 +9,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import me.x150.sipprivate.CoffeeClientMain;
import me.x150.sipprivate.feature.gui.screen.CoffeeConsoleScreen;
import me.x150.sipprivate.helper.Texture;
import me.x150.sipprivate.helper.font.adapter.FontAdapter;
import me.x150.sipprivate.mixin.IMinecraftClientAccessor;
import me.x150.sipprivate.mixin.IRenderTickCounterAccessor;
@ -24,7 +25,6 @@ import net.minecraft.nbt.StringNbtReader;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.text.LiteralText;
import net.minecraft.text.TextColor;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
@ -72,7 +72,7 @@ public class Utils {
return new Vec3d(MathHelper.lerp(p, b.x, a.x), MathHelper.lerp(p, b.y, a.y), MathHelper.lerp(p, b.z, a.z));
}
public static void registerBufferedImageTexture(Identifier i, BufferedImage bi) {
public static void registerBufferedImageTexture(Texture i, BufferedImage bi) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bi, "png", baos);
@ -130,13 +130,13 @@ public class Utils {
public static class Textures {
static final NativeImageBackedTexture EMPTY = new NativeImageBackedTexture(1, 1, false);
static final HttpClient downloader = HttpClient.newHttpClient();
static Map<UUID, Identifier> uCache = new ConcurrentHashMap<>();
static Map<UUID, Texture> uCache = new ConcurrentHashMap<>();
public static Identifier getSkinPreviewTexture(UUID uuid) {
public static Texture getSkinPreviewTexture(UUID uuid) {
if (uCache.containsKey(uuid)) return uCache.get(uuid);
// completely random id
// (hash code of uuid)(random numbers)
Identifier texIdent = new Identifier("coffee", uuid.hashCode() + (java.lang.Math.random() + "").split("\\.")[1]);
Texture texIdent = new Texture("preview/" + uuid.hashCode() + "");
uCache.put(uuid, texIdent);
HttpRequest hr = HttpRequest.newBuilder().uri(URI.create("https://crafatar.com/avatars/" + uuid + "?overlay")).header("User-Agent", "why").build();
CoffeeClientMain.client.execute(() -> {
@ -155,7 +155,7 @@ public class Utils {
return texIdent;
}
public static void registerBufferedImageTexture(BufferedImage image, Identifier tex) {
public static void registerBufferedImageTexture(BufferedImage image, Texture tex) {
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ImageIO.write(image, "png", stream);

View file

@ -1,5 +1,8 @@
package me.x150.sipprivate.mixin;
import io.netty.channel.ChannelHandlerContext;
import me.x150.sipprivate.feature.module.ModuleRegistry;
import me.x150.sipprivate.feature.module.impl.misc.AntiPacketKick;
import me.x150.sipprivate.helper.event.EventType;
import me.x150.sipprivate.helper.event.Events;
import me.x150.sipprivate.helper.event.events.PacketEvent;
@ -21,6 +24,13 @@ public class ClientConnectionMixin {
}
}
@Inject(method = "exceptionCaught", at = @At("HEAD"), cancellable = true)
public void atomic_catchException(ChannelHandlerContext context, Throwable ex, CallbackInfo ci) {
if (ModuleRegistry.getByClass(AntiPacketKick.class).isEnabled()) {
ci.cancel();
}
}
@Inject(method = "send(Lnet/minecraft/network/Packet;)V", cancellable = true, at = @At("HEAD"))
public void atomic_dispatchPacketSend(Packet<?> packet, CallbackInfo ci) {
if (Events.fireEvent(EventType.PACKET_SEND, new PacketEvent(packet))) {

View file

@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(PlayerEntityRenderer.class)
public class PlayerEntityRendererMixin {
@Inject(method="renderLabelIfPresent(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",at=@At("HEAD"),cancellable = true)
@Inject(method = "renderLabelIfPresent(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD"), cancellable = true)
void real(AbstractClientPlayerEntity abstractClientPlayerEntity, Text text, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) {
NameTags nt = ModuleRegistry.getByClass(NameTags.class);
if (nt.isEnabled()) {

View file

@ -24,7 +24,6 @@
"sipoverprivate.mixins.json"
],
"depends": {
"fabricloader": ">=0.12.12",
"fabric": "*"
"fabricloader": ">=0.12.12"
}
}