This commit is contained in:
0x150 2021-12-18 19:53:58 +01:00
parent bf07ddfabe
commit f7777f40c9
26 changed files with 1635 additions and 1 deletions

View file

@ -1,14 +1,28 @@
package me.x150.sipprivate;
import me.x150.sipprivate.feature.command.CommandRegistry;
import me.x150.sipprivate.feature.gui.FastTickable;
import me.x150.sipprivate.feature.module.Module;
import me.x150.sipprivate.feature.module.ModuleRegistry;
import me.x150.sipprivate.helper.event.EventType;
import me.x150.sipprivate.helper.event.Events;
import me.x150.sipprivate.helper.event.events.PostInitEvent;
import me.x150.sipprivate.helper.font.FontRenderers;
import me.x150.sipprivate.helper.font.adapter.impl.ClientFontRenderer;
import me.x150.sipprivate.helper.font.adapter.impl.VanillaFontRenderer;
import me.x150.sipprivate.helper.font.render.GlyphPageFontRenderer;
import me.x150.sipprivate.keybinding.KeybindingManager;
import me.x150.sipprivate.util.ConfigManager;
import me.x150.sipprivate.util.Utils;
import net.fabricmc.api.ModInitializer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Element;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.util.ArrayList;
public class SipoverPrivate implements ModInitializer {
@ -17,6 +31,8 @@ public class SipoverPrivate implements ModInitializer {
public static Logger LOGGER = LogManager.getLogger();
public static MinecraftClient client = MinecraftClient.getInstance();
public static SipoverPrivate INSTANCE;
public static File BASE = new File(MinecraftClient.getInstance().runDirectory, "sip");
public static void log(Level level, String message) {
@ -24,6 +40,7 @@ public class SipoverPrivate implements ModInitializer {
}
@Override public void onInitialize() {
INSTANCE = this;
log(Level.INFO, "Initializing");
Runtime.getRuntime().addShutdownHook(new Thread(ConfigManager::saveState));
if (BASE.exists() && !BASE.isDirectory()) {
@ -38,4 +55,88 @@ public class SipoverPrivate implements ModInitializer {
//TODO: Initializer
}
public static Thread MODULE_FTTICKER;
public static Thread FAST_TICKER;
public boolean initialized = false;
void initFonts() {
FontRenderers.setNormal(new ClientFontRenderer(GlyphPageFontRenderer.createFromID("Font.ttf", 17, false, false, false)));
FontRenderers.setTitle(new ClientFontRenderer(GlyphPageFontRenderer.createFromID("Font.ttf", 25, false, false, false)));
FontRenderers.setMono(new ClientFontRenderer(GlyphPageFontRenderer.createFromID("Font.ttf", 17, false, false, false)));
FontRenderers.setVanilla(new VanillaFontRenderer());
}
void tickModulesNWC() {
for (Module module : ModuleRegistry.getModules()) {
try {
if (module.isEnabled()) {
module.onFastTick_NWC();
}
} catch (Exception ignored) {
}
}
}
void tickModules() {
for (Module module : ModuleRegistry.getModules()) {
try {
if (module.isEnabled()) {
module.onFastTick();
}
} catch (Exception ignored) {
}
}
}
void tickGuiSystem() {
// NotificationRenderer.onFastTick();
try {
if (client.currentScreen != null) {
if (client.currentScreen instanceof FastTickable tickable) {
tickable.onFastTick();
}
for (Element child : new ArrayList<>(client.currentScreen.children())) { // wow i hate this
if (child instanceof FastTickable t) {
t.onFastTick();
}
}
}
} catch (Exception ignored) {
}
}
public void postWindowInit() {
initialized = true;
initFonts();
ConfigManager.loadState();
MODULE_FTTICKER = new Thread(() -> {
while (true) {
Utils.sleep(10);
tickModulesNWC(); // always ticks even when we're not in a world
if (client.player == null || client.world == null) {
continue;
}
tickModules(); // only ticks when we're in a world
}
}, "100_tps_ticker:modules");
FAST_TICKER = new Thread(() -> {
while (true) {
Utils.sleep(10);
tickGuiSystem(); // ticks gui elements
// Themes.tickThemes(); // Tick themes
if (client.player == null || client.world == null) {
continue;
}
// Rotations.update(); // updates rotations, again only if we are in a world
}
}, "100_tps_ticker:gui");
MODULE_FTTICKER.start();
FAST_TICKER.start();
// ModuleRegistry.sortModulesPostInit();
CommandRegistry.init();
System.out.println("sending post init");
Events.fireEvent(EventType.POST_INIT, new PostInitEvent());
}
}

View file

@ -0,0 +1,6 @@
package me.x150.sipprivate.feature.gui;
public interface FastTickable {
void onFastTick();
}

View file

@ -0,0 +1,17 @@
package me.x150.sipprivate.feature.gui;
import me.x150.sipprivate.SipoverPrivate;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.text.Text;
public class HomeScreen extends Screen {
public HomeScreen() {
super(Text.of(""));
}
@Override protected void init() {
SipoverPrivate.client.setScreen(new TitleScreen());
super.init();
}
}

View file

@ -0,0 +1,10 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.event;
public enum EventType {
PACKET_SEND, PACKET_RECEIVE, ENTITY_RENDER, BLOCK_ENTITY_RENDER, BLOCK_RENDER, MOUSE_EVENT, LORE_QUERY, CONFIG_SAVE, NOCLIP_QUERY, KEYBOARD, RECIPE_CLICKED, POST_INIT
}

View file

@ -0,0 +1,35 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.event;
import me.x150.sipprivate.helper.event.events.base.Event;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
public class Events {
static final Map<EventType, List<Consumer<Event>>> HANDLERS = new HashMap<>();
public static void registerEventHandler(EventType event, Consumer<Event> handler) {
if (!HANDLERS.containsKey(event)) {
HANDLERS.put(event, new ArrayList<>());
}
HANDLERS.get(event).add(handler);
}
public static boolean fireEvent(EventType event, Event argument) {
if (HANDLERS.containsKey(event)) {
for (Consumer<Event> handler : HANDLERS.get(event)) {
handler.accept(argument);
}
}
return argument.isCancelled();
}
}

View file

@ -0,0 +1,23 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.event.events;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.util.math.MatrixStack;
@SuppressWarnings("unused") public class BlockEntityRenderEvent extends RenderEvent {
final BlockEntity entity;
public BlockEntityRenderEvent(MatrixStack stack, BlockEntity entity) {
super(stack);
this.entity = entity;
}
public BlockEntity getBlockEntity() {
return entity;
}
}

View file

@ -0,0 +1,30 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.event.events;
import net.minecraft.block.BlockState;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.BlockPos;
public class BlockRenderingEvent extends RenderEvent {
final BlockPos bp;
final BlockState state;
public BlockRenderingEvent(MatrixStack stack, BlockPos pos, BlockState state) {
super(stack);
this.bp = pos;
this.state = state;
}
@SuppressWarnings("unused") public BlockPos getPosition() {
return bp;
}
public BlockState getBlockState() {
return state;
}
}

View file

@ -0,0 +1,23 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.event.events;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
public class EntityRenderEvent extends RenderEvent {
final Entity target;
public EntityRenderEvent(MatrixStack stack, Entity e) {
super(stack);
this.target = e;
}
public Entity getEntity() {
return target;
}
}

View file

@ -0,0 +1,30 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.event.events;
import me.x150.sipprivate.helper.event.events.base.NonCancellableEvent;
public class KeyboardEvent extends NonCancellableEvent {
final int kc;
final int t;
public KeyboardEvent(int keycode, int type) {
this.kc = keycode;
this.t = type;
}
public int getKeycode() {
return kc;
}
/**
* @return the type of the event<br>0 = key released<br>1 = key pressed<br>2 = key event repeated
*/
public int getType() {
return t;
}
}

View file

@ -0,0 +1,39 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.event.events;
import me.x150.sipprivate.helper.event.events.base.NonCancellableEvent;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import java.util.List;
public class LoreQueryEvent extends NonCancellableEvent {
final ItemStack source;
final List<Text> lore;
public LoreQueryEvent(ItemStack stack, List<Text> currentLore) {
this.source = stack;
this.lore = currentLore;
}
public ItemStack getSource() {
return source;
}
public List<Text> getLore() {
return lore;
}
public void addLore(String v) {
lore.add(Text.of(v));
}
public void addClientLore(String v) {
addLore("[§9A§r] §7" + v + "§r");
}
}

View file

@ -0,0 +1,31 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.event.events;
import me.x150.sipprivate.helper.event.events.base.NonCancellableEvent;
public class MouseEvent extends NonCancellableEvent {
final int button;
final MouseEventType type;
public MouseEvent(int button, int action) {
this.button = button;
type = action == 1 ? MouseEventType.MOUSE_CLICKED : MouseEventType.MOUSE_RELEASED;
}
public int getButton() {
return button;
}
public MouseEventType getAction() {
return type;
}
public enum MouseEventType {
MOUSE_CLICKED, MOUSE_RELEASED
}
}

View file

@ -0,0 +1,22 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.event.events;
import me.x150.sipprivate.helper.event.events.base.Event;
import net.minecraft.network.Packet;
public class PacketEvent extends Event {
private final Packet<?> packet;
public PacketEvent(Packet<?> packet) {
this.packet = packet;
}
public Packet<?> getPacket() {
return packet;
}
}

View file

@ -0,0 +1,43 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.event.events;
import me.x150.sipprivate.helper.event.events.base.NonCancellableEvent;
import net.minecraft.entity.player.PlayerEntity;
public class PlayerNoClipQueryEvent extends NonCancellableEvent {
final PlayerEntity player;
NoClipState state = NoClipState.UNSET;
public PlayerNoClipQueryEvent(PlayerEntity player) {
this.player = player;
}
public PlayerEntity getPlayer() {
return player;
}
public NoClipState getNoClipState() {
return state;
}
public void setNoClipState(NoClipState state) {
this.state = state;
}
public boolean getNoClip() {
if (state == NoClipState.UNSET) {
return player.isSpectator();
} else {
return state == NoClipState.ACTIVE;
}
}
public enum NoClipState {
UNSET, ACTIVE, INACTIVE
}
}

View file

@ -0,0 +1,7 @@
package me.x150.sipprivate.helper.event.events;
import me.x150.sipprivate.helper.event.events.base.NonCancellableEvent;
public class PostInitEvent extends NonCancellableEvent {
}

View file

@ -0,0 +1,28 @@
package me.x150.sipprivate.helper.event.events;
import me.x150.sipprivate.helper.event.events.base.Event;
import net.minecraft.recipe.Recipe;
public class RecipeClickedEvent extends Event {
final int syncId;
final Recipe<?> recipe;
final boolean craftAll;
public RecipeClickedEvent(int syncId, Recipe<?> recipe, boolean craftAll) {
this.syncId = syncId;
this.recipe = recipe;
this.craftAll = craftAll;
}
public Recipe<?> getRecipe() {
return recipe;
}
public int getSyncId() {
return syncId;
}
public boolean craftAll() {
return craftAll;
}
}

View file

@ -0,0 +1,22 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.event.events;
import me.x150.sipprivate.helper.event.events.base.Event;
import net.minecraft.client.util.math.MatrixStack;
public class RenderEvent extends Event {
final MatrixStack stack;
public RenderEvent(MatrixStack stack) {
this.stack = stack;
}
public MatrixStack getStack() {
return stack;
}
}

View file

@ -0,0 +1,19 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.event.events.base;
public class Event {
boolean cancelled = false;
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View file

@ -0,0 +1,17 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.event.events.base;
public class NonCancellableEvent extends Event {
@Override public boolean isCancelled() {
return false;
}
@Override public void setCancelled(boolean cancelled) {
throw new IllegalStateException("Event cannot be cancelled.");
}
}

View file

@ -0,0 +1,357 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.math;
import net.minecraft.util.math.Matrix4f;
import org.lwjgl.system.MemoryStack;
import java.nio.FloatBuffer;
@SuppressWarnings("UnusedReturnValue") public class Matrix4x4 {
public float a00;
public float a01;
public float a02;
public float a03;
public float a10;
public float a11;
public float a12;
public float a13;
public float a20;
public float a21;
public float a22;
public float a23;
public float a30;
public float a31;
public float a32;
public float a33;
public Matrix4x4(FloatBuffer floatBuffer) {
int offset = floatBuffer.position();
this.a00 = floatBuffer.get(offset);
this.a01 = floatBuffer.get(offset + 1);
this.a02 = floatBuffer.get(offset + 2);
this.a03 = floatBuffer.get(offset + 3);
this.a10 = floatBuffer.get(offset + 4);
this.a11 = floatBuffer.get(offset + 5);
this.a12 = floatBuffer.get(offset + 6);
this.a13 = floatBuffer.get(offset + 7);
this.a20 = floatBuffer.get(offset + 8);
this.a21 = floatBuffer.get(offset + 9);
this.a22 = floatBuffer.get(offset + 10);
this.a23 = floatBuffer.get(offset + 11);
this.a30 = floatBuffer.get(offset + 12);
this.a31 = floatBuffer.get(offset + 13);
this.a32 = floatBuffer.get(offset + 14);
this.a33 = floatBuffer.get(offset + 15);
}
public Matrix4x4(float[] floats) {
this.a00 = floats[0];
this.a01 = floats[1];
this.a02 = floats[2];
this.a03 = floats[3];
this.a10 = floats[4];
this.a11 = floats[5];
this.a12 = floats[6];
this.a13 = floats[7];
this.a20 = floats[8];
this.a21 = floats[9];
this.a22 = floats[10];
this.a23 = floats[11];
this.a30 = floats[12];
this.a31 = floats[13];
this.a32 = floats[14];
this.a33 = floats[15];
}
public Matrix4x4() {
identity();
}
public static Matrix4x4 copyFromRowMajor(Matrix4f matrix4f) {
try (MemoryStack memoryStack = MemoryStack.stackPush()) {
FloatBuffer floatBuffer = memoryStack.mallocFloat(16);
matrix4f.write(floatBuffer, true);
return new Matrix4x4(floatBuffer);
}
}
public static Matrix4x4 copyFromColumnMajor(Matrix4f matrix4f) {
try (MemoryStack memoryStack = MemoryStack.stackPush()) {
FloatBuffer floatBuffer = memoryStack.mallocFloat(16);
matrix4f.write(floatBuffer, false);
return new Matrix4x4(floatBuffer);
}
}
public static Matrix4x4 ortho2DMatrix(float left, float right, float bottom, float top, float near, float far) {
Matrix4x4 matrix4x4 = new Matrix4x4();
matrix4x4.identity();
// calculate right matrix elements
double rm00 = 2.0 / (right - left);
double rm11 = 2.0 / (top - bottom);
double rm30 = (right + left) / (left - right);
double rm31 = (top + bottom) / (bottom - top);
// perform optimized multiplication
// compute the last column first, because other columns do not depend on it
matrix4x4.a30 = (float) (matrix4x4.a00 * rm30 + matrix4x4.a10 * rm31 + matrix4x4.a30);
matrix4x4.a31 = (float) (matrix4x4.a01 * rm30 + matrix4x4.a11 * rm31 + matrix4x4.a31);
matrix4x4.a32 = (float) (matrix4x4.a02 * rm30 + matrix4x4.a12 * rm31 + matrix4x4.a32);
matrix4x4.a33 = (float) (matrix4x4.a03 * rm30 + matrix4x4.a13 * rm31 + matrix4x4.a33);
matrix4x4.a00 = (float) (matrix4x4.a00 * rm00);
matrix4x4.a01 = (float) (matrix4x4.a01 * rm00);
matrix4x4.a02 = (float) (matrix4x4.a02 * rm00);
matrix4x4.a03 = (float) (matrix4x4.a03 * rm00);
matrix4x4.a10 = (float) (matrix4x4.a10 * rm11);
matrix4x4.a11 = (float) (matrix4x4.a11 * rm11);
matrix4x4.a12 = (float) (matrix4x4.a12 * rm11);
matrix4x4.a13 = (float) (matrix4x4.a13 * rm11);
matrix4x4.a20 = -matrix4x4.a20;
matrix4x4.a21 = -matrix4x4.a21;
matrix4x4.a22 = -matrix4x4.a22;
matrix4x4.a23 = -matrix4x4.a23;
return matrix4x4;
}
public static Matrix4x4 projectionMatrix(float width, float height, float fov, float near, float far) {
Matrix4x4 proj = new Matrix4x4();
float aspectRatio = width / height;
float zp = far + near;
float zm = far - near;
float a00 = 1 / aspectRatio;
float a11 = 1;
float a22 = -zp / zm;
float a23 = -(2 * far * near) / zm;
proj.a00 = a00;
proj.a11 = a11;
proj.a22 = a22;
proj.a23 = a23;
proj.a32 = -1;
return proj;
}
public static Matrix4x4 scale(float x, float y, float z) {
Matrix4x4 matrix4x4 = new Matrix4x4();
matrix4x4.a00 = x;
matrix4x4.a11 = y;
matrix4x4.a22 = z;
matrix4x4.a33 = 1.0F;
return matrix4x4;
}
public static Matrix4x4 translate(float x, float y, float z) {
Matrix4x4 matrix4x4 = new Matrix4x4();
matrix4x4.a00 = 1.0F;
matrix4x4.a11 = 1.0F;
matrix4x4.a22 = 1.0F;
matrix4x4.a33 = 1.0F;
matrix4x4.a03 = x;
matrix4x4.a13 = y;
matrix4x4.a23 = z;
return matrix4x4;
}
public Matrix4x4 identity() {
this.a00 = 1;
this.a01 = 0;
this.a02 = 0;
this.a03 = 0;
this.a10 = 0;
this.a11 = 1;
this.a12 = 0;
this.a13 = 0;
this.a20 = 0;
this.a21 = 0;
this.a22 = 1;
this.a23 = 0;
this.a30 = 0;
this.a31 = 0;
this.a32 = 0;
this.a33 = 1;
return this;
}
public Vector3D project(float x, float y, float z, int[] viewport, Vector3D winCoordsDest) {
float invW = 1.0f / Math.fma(a03, x, Math.fma(a13, y, Math.fma(a23, z, a33)));
float nx = Math.fma(a00, x, Math.fma(a10, y, Math.fma(a20, z, a30))) * invW;
float ny = Math.fma(a01, x, Math.fma(a11, y, Math.fma(a21, z, a31))) * invW;
float nz = Math.fma(a02, x, Math.fma(a12, y, Math.fma(a22, z, a32))) * invW;
winCoordsDest.setX(Math.fma(Math.fma(nx, 0.5f, 0.5f), viewport[2], viewport[0]));
winCoordsDest.setY(Math.fma(Math.fma(ny, 0.5f, 0.5f), viewport[3], viewport[1]));
winCoordsDest.setZ(Math.fma(0.5f, nz, 0.5f));
return winCoordsDest;
}
public Matrix4x4 mul(Matrix4x4 matrix4x4) {
float nm00 = Math.fma(a00, matrix4x4.a00, Math.fma(a10, matrix4x4.a01, Math.fma(a20, matrix4x4.a02, a30 * matrix4x4.a03)));
float nm01 = Math.fma(a01, matrix4x4.a00, Math.fma(a11, matrix4x4.a01, Math.fma(a21, matrix4x4.a02, a31 * matrix4x4.a03)));
float nm02 = Math.fma(a02, matrix4x4.a00, Math.fma(a12, matrix4x4.a01, Math.fma(a22, matrix4x4.a02, a32 * matrix4x4.a03)));
float nm03 = Math.fma(a03, matrix4x4.a00, Math.fma(a13, matrix4x4.a01, Math.fma(a23, matrix4x4.a02, a33 * matrix4x4.a03)));
float nm10 = Math.fma(a00, matrix4x4.a10, Math.fma(a10, matrix4x4.a11, Math.fma(a20, matrix4x4.a12, a30 * matrix4x4.a13)));
float nm11 = Math.fma(a01, matrix4x4.a10, Math.fma(a11, matrix4x4.a11, Math.fma(a21, matrix4x4.a12, a31 * matrix4x4.a13)));
float nm12 = Math.fma(a02, matrix4x4.a10, Math.fma(a12, matrix4x4.a11, Math.fma(a22, matrix4x4.a12, a32 * matrix4x4.a13)));
float nm13 = Math.fma(a03, matrix4x4.a10, Math.fma(a13, matrix4x4.a11, Math.fma(a23, matrix4x4.a12, a33 * matrix4x4.a13)));
float nm20 = Math.fma(a00, matrix4x4.a20, Math.fma(a10, matrix4x4.a21, Math.fma(a20, matrix4x4.a22, a30 * matrix4x4.a23)));
float nm21 = Math.fma(a01, matrix4x4.a20, Math.fma(a11, matrix4x4.a21, Math.fma(a21, matrix4x4.a22, a31 * matrix4x4.a23)));
float nm22 = Math.fma(a02, matrix4x4.a20, Math.fma(a12, matrix4x4.a21, Math.fma(a22, matrix4x4.a22, a32 * matrix4x4.a23)));
float nm23 = Math.fma(a03, matrix4x4.a20, Math.fma(a13, matrix4x4.a21, Math.fma(a23, matrix4x4.a22, a33 * matrix4x4.a23)));
float nm30 = Math.fma(a00, matrix4x4.a30, Math.fma(a10, matrix4x4.a31, Math.fma(a20, matrix4x4.a32, a30 * matrix4x4.a33)));
float nm31 = Math.fma(a01, matrix4x4.a30, Math.fma(a11, matrix4x4.a31, Math.fma(a21, matrix4x4.a32, a31 * matrix4x4.a33)));
float nm32 = Math.fma(a02, matrix4x4.a30, Math.fma(a12, matrix4x4.a31, Math.fma(a22, matrix4x4.a32, a32 * matrix4x4.a33)));
float nm33 = Math.fma(a03, matrix4x4.a30, Math.fma(a13, matrix4x4.a31, Math.fma(a23, matrix4x4.a32, a33 * matrix4x4.a33)));
return new Matrix4x4(new float[]{nm00, nm01, nm02, nm03, nm10, nm11, nm12, nm13, nm20, nm21, nm22, nm23, nm30, nm31, nm32, nm33});
}
public Matrix4x4 set(Matrix4x4 matrix4x4) {
this.a00 = matrix4x4.a00;
this.a01 = matrix4x4.a01;
this.a02 = matrix4x4.a02;
this.a03 = matrix4x4.a03;
this.a10 = matrix4x4.a10;
this.a11 = matrix4x4.a11;
this.a12 = matrix4x4.a12;
this.a13 = matrix4x4.a13;
this.a20 = matrix4x4.a20;
this.a21 = matrix4x4.a21;
this.a22 = matrix4x4.a22;
this.a23 = matrix4x4.a23;
this.a30 = matrix4x4.a30;
this.a31 = matrix4x4.a31;
this.a32 = matrix4x4.a32;
this.a33 = matrix4x4.a33;
return this;
}
public Matrix4x4 multiply(float scalar) {
this.a00 *= scalar;
this.a01 *= scalar;
this.a02 *= scalar;
this.a03 *= scalar;
this.a10 *= scalar;
this.a11 *= scalar;
this.a12 *= scalar;
this.a13 *= scalar;
this.a20 *= scalar;
this.a21 *= scalar;
this.a22 *= scalar;
this.a23 *= scalar;
this.a30 *= scalar;
this.a31 *= scalar;
this.a32 *= scalar;
this.a33 *= scalar;
return this;
}
public Matrix4x4 add(Matrix4x4 matrix) {
this.a00 += matrix.a00;
this.a01 += matrix.a01;
this.a02 += matrix.a02;
this.a03 += matrix.a03;
this.a10 += matrix.a10;
this.a11 += matrix.a11;
this.a12 += matrix.a12;
this.a13 += matrix.a13;
this.a20 += matrix.a20;
this.a21 += matrix.a21;
this.a22 += matrix.a22;
this.a23 += matrix.a23;
this.a30 += matrix.a30;
this.a31 += matrix.a31;
this.a32 += matrix.a32;
this.a33 += matrix.a33;
return this;
}
public Matrix4x4 subtract(Matrix4x4 matrix) {
this.a00 -= matrix.a00;
this.a01 -= matrix.a01;
this.a02 -= matrix.a02;
this.a03 -= matrix.a03;
this.a10 -= matrix.a10;
this.a11 -= matrix.a11;
this.a12 -= matrix.a12;
this.a13 -= matrix.a13;
this.a20 -= matrix.a20;
this.a21 -= matrix.a21;
this.a22 -= matrix.a22;
this.a23 -= matrix.a23;
this.a30 -= matrix.a30;
this.a31 -= matrix.a31;
this.a32 -= matrix.a32;
this.a33 -= matrix.a33;
return this;
}
public float[] toFloatArray() {
float[] floats = new float[4 * 4];
floats[0] = this.a00;
floats[1] = this.a01;
floats[2] = this.a02;
floats[3] = this.a03;
floats[4] = this.a10;
floats[5] = this.a11;
floats[6] = this.a12;
floats[7] = this.a13;
floats[8] = this.a20;
floats[9] = this.a21;
floats[10] = this.a22;
floats[11] = this.a23;
floats[12] = this.a30;
floats[13] = this.a31;
floats[14] = this.a32;
floats[15] = this.a33;
return floats;
}
public FloatBuffer toFloatBuffer() {
try (MemoryStack memoryStack = MemoryStack.stackPush()) {
FloatBuffer floatBuffer = memoryStack.mallocFloat(16);
floatBuffer.put(0, this.a00);
floatBuffer.put(1, this.a01);
floatBuffer.put(2, this.a02);
floatBuffer.put(3, this.a03);
floatBuffer.put(4, this.a10);
floatBuffer.put(5, this.a11);
floatBuffer.put(6, this.a12);
floatBuffer.put(7, this.a13);
floatBuffer.put(8, this.a20);
floatBuffer.put(9, this.a21);
floatBuffer.put(10, this.a22);
floatBuffer.put(11, this.a23);
floatBuffer.put(12, this.a30);
floatBuffer.put(13, this.a31);
floatBuffer.put(14, this.a32);
floatBuffer.put(15, this.a33);
return floatBuffer;
}
}
public Matrix4f toMinecraft() {
Matrix4f matrix4f = new Matrix4f();
try (MemoryStack memoryStack = MemoryStack.stackPush()) {
FloatBuffer floatBuffer = memoryStack.mallocFloat(16);
floatBuffer.put(0, this.a00);
floatBuffer.put(1, this.a01);
floatBuffer.put(2, this.a02);
floatBuffer.put(3, this.a03);
floatBuffer.put(4, this.a10);
floatBuffer.put(5, this.a11);
floatBuffer.put(6, this.a12);
floatBuffer.put(7, this.a13);
floatBuffer.put(8, this.a20);
floatBuffer.put(9, this.a21);
floatBuffer.put(10, this.a22);
floatBuffer.put(11, this.a23);
floatBuffer.put(12, this.a30);
floatBuffer.put(13, this.a31);
floatBuffer.put(14, this.a32);
floatBuffer.put(15, this.a33);
matrix4f.read(floatBuffer, false);
return matrix4f;
}
}
}

View file

@ -0,0 +1,146 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.math;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Vec3d;
public class Vector3D {
public double x, y, z;
public Vector3D() {
this.x = 0;
this.y = 0;
this.z = 0;
}
public Vector3D(Vec3d vec3d) {
this.x = vec3d.x;
this.y = vec3d.y;
this.z = vec3d.z;
}
public Vector3D(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public double getZ() {
return z;
}
public void setZ(double z) {
this.z = z;
}
public Vector3D multiply(double mulX, double mulY, double mulZ) {
this.x *= mulX;
this.y *= mulY;
this.z *= mulZ;
return this;
}
public Vector3D divide(double divX, double divY, double divZ) {
this.x /= divX;
this.y /= divY;
this.z /= divZ;
return this;
}
public Vector3D add(double addX, double addY, double addZ) {
this.x += addX;
this.y += addY;
this.z += addZ;
return this;
}
public Vector3D subtract(double subX, double subY, double subZ) {
this.x -= subX;
this.y -= subY;
this.z -= subZ;
return this;
}
public Vector3D transform(Matrix4f matrix4f) {
return transform(Matrix4x4.copyFromRowMajor(matrix4f));
}
public Vector3D transform(Matrix4x4 matrix4x4) {
double f = this.x;
double g = this.y;
double h = this.z;
this.x = matrix4x4.a00 * f + matrix4x4.a01 * g + matrix4x4.a02 * h + matrix4x4.a03;
this.y = matrix4x4.a10 * f + matrix4x4.a11 * g + matrix4x4.a12 * h + matrix4x4.a13;
this.z = matrix4x4.a20 * f + matrix4x4.a21 * g + matrix4x4.a22 * h + matrix4x4.a23;
return this;
}
public Vector3D multiply(Vector3D vector3D) {
return multiply(vector3D.getX(), vector3D.getY(), vector3D.getZ());
}
public Vector3D divide(Vector3D vector3D) {
return divide(vector3D.getX(), vector3D.getY(), vector3D.getZ());
}
public Vector3D add(Vector3D vector3D) {
return add(vector3D.getX(), vector3D.getY(), vector3D.getZ());
}
public Vector3D subtract(Vector3D vector3D) {
return subtract(vector3D.getX(), vector3D.getY(), vector3D.getZ());
}
public Vector3D multiply(double mul) {
this.x *= mul;
this.y *= mul;
this.z *= mul;
return this;
}
public Vector3D divide(double div) {
this.x /= div;
this.y /= div;
this.z /= div;
return this;
}
public Vector3D add(double add) {
this.x += add;
this.y += add;
this.z += add;
return this;
}
public Vector3D subtract(double sub) {
this.x -= sub;
this.y -= sub;
this.z -= sub;
return this;
}
public Vec3d toMinecraft() {
return new Vec3d(x, y, z);
}
}

View file

@ -0,0 +1,64 @@
/*
* This file is part of the atomic client distribution.
* Copyright (c) 2021-2021 0x150.
*/
package me.x150.sipprivate.helper.render;
import me.x150.sipprivate.util.Utils;
@SuppressWarnings("unused") public class CustomColor extends java.awt.Color {
final int alpha;
private boolean isChroma = false;
public CustomColor(int r, int g, int b, boolean isChroma) {
this(r, g, b);
this.isChroma = isChroma;
}
public CustomColor(int r, int g, int b) {
super(r, g, b);
alpha = 255;
}
public CustomColor(int r, int g, int b, int a, boolean isChroma) {
this(r, g, b, a);
this.isChroma = isChroma;
}
public CustomColor(int r, int g, int b, int a) {
super(r, g, b, a);
alpha = a;
}
public CustomColor(int rgb, boolean isChroma) {
this(rgb);
this.isChroma = isChroma;
}
public CustomColor(int rgb) {
super(rgb);
alpha = (rgb >> 24) & 0xFF;
}
public boolean isChroma() {
return isChroma;
}
public void setChroma(boolean chroma) {
isChroma = chroma;
}
@Override public int getRGB() {
if (isChroma) {
java.awt.Color chroma = Utils.getCurrentRGB();
return new CustomColor(chroma.getRed(), chroma.getGreen(), chroma.getBlue(), alpha).getRGB();
}
return super.getRGB();
}
@Override public int getAlpha() {
return alpha;
}
}

View file

@ -0,0 +1,503 @@
package me.x150.sipprivate.helper.render;
import com.mojang.blaze3d.systems.RenderSystem;
import me.x150.sipprivate.SipoverPrivate;
import me.x150.sipprivate.feature.gui.HomeScreen;
import me.x150.sipprivate.helper.math.Matrix4x4;
import me.x150.sipprivate.helper.math.Vector3D;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.multiplayer.SocialInteractionsScreen;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Quaternion;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.Vector4f;
import org.lwjgl.opengl.GL11;
import java.awt.Color;
public class Renderer {
public static class R3D {
static final MatrixStack empty = new MatrixStack();
private static MatrixStack lastRenderStack = new MatrixStack();
public static void renderOutlineIntern(Vec3d start, Vec3d dimensions, MatrixStack stack, BufferBuilder buffer) {
Camera c = SipoverPrivate.client.gameRenderer.getCamera();
Vec3d camPos = c.getPos();
start = start.subtract(camPos);
Vec3d end = start.add(dimensions);
Matrix4f matrix = stack.peek().getPositionMatrix();
float x1 = (float) start.x;
float y1 = (float) start.y;
float z1 = (float) start.z;
float x2 = (float) end.x;
float y2 = (float) end.y;
float z2 = (float) end.z;
buffer.vertex(matrix, x1, y1, z1).next();
buffer.vertex(matrix, x1, y1, z2).next();
buffer.vertex(matrix, x1, y1, z2).next();
buffer.vertex(matrix, x2, y1, z2).next();
buffer.vertex(matrix, x2, y1, z2).next();
buffer.vertex(matrix, x2, y1, z1).next();
buffer.vertex(matrix, x2, y1, z1).next();
buffer.vertex(matrix, x1, y1, z1).next();
buffer.vertex(matrix, x1, y2, z1).next();
buffer.vertex(matrix, x1, y2, z2).next();
buffer.vertex(matrix, x1, y2, z2).next();
buffer.vertex(matrix, x2, y2, z2).next();
buffer.vertex(matrix, x2, y2, z2).next();
buffer.vertex(matrix, x2, y2, z1).next();
buffer.vertex(matrix, x2, y2, z1).next();
buffer.vertex(matrix, x1, y2, z1).next();
buffer.vertex(matrix, x1, y1, z1).next();
buffer.vertex(matrix, x1, y2, z1).next();
buffer.vertex(matrix, x2, y1, z1).next();
buffer.vertex(matrix, x2, y2, z1).next();
buffer.vertex(matrix, x2, y1, z2).next();
buffer.vertex(matrix, x2, y2, z2).next();
buffer.vertex(matrix, x1, y1, z2).next();
buffer.vertex(matrix, x1, y2, z2).next();
}
//you can call renderOutlineIntern multiple times to save performance
public static void renderOutline(Vec3d start, Vec3d dimensions, Color color, MatrixStack stack) {
RenderSystem.defaultBlendFunc();
RenderSystem.enableBlend();
BufferBuilder buffer = renderPrepare(color);
renderOutlineIntern(start, dimensions, stack, buffer);
buffer.end();
BufferRenderer.draw(buffer);
GL11.glDepthFunc(GL11.GL_LEQUAL);
RenderSystem.disableBlend();
}
public static BufferBuilder renderPrepare(Color color) {
float red = color.getRed() / 255f;
float green = color.getGreen() / 255f;
float blue = color.getBlue() / 255f;
float alpha = color.getAlpha() / 255f;
RenderSystem.setShader(GameRenderer::getPositionShader);
GL11.glDepthFunc(GL11.GL_ALWAYS);
RenderSystem.setShaderColor(red, green, blue, alpha);
//RenderSystem.lineWidth(2f);
BufferBuilder buffer = Tessellator.getInstance().getBuffer();
buffer.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION);
return buffer;
}
public static void renderFilled(Vec3d start, Vec3d dimensions, Color color, MatrixStack stack) {
renderFilled(start, dimensions, color, stack, GL11.GL_ALWAYS);
}
public static MatrixStack getLastRenderStack() {
return lastRenderStack;
}
public static void setLastRenderStack(MatrixStack lastRenderStack) {
R3D.lastRenderStack = lastRenderStack;
}
public static MatrixStack getEmptyMatrixStack() {
empty.loadIdentity(); // essentially clear the stack
return empty;
}
public static void renderFilled(Vec3d start, Vec3d dimensions, Color color, MatrixStack stack, int GLMODE) {
float red = color.getRed() / 255f;
float green = color.getGreen() / 255f;
float blue = color.getBlue() / 255f;
float alpha = color.getAlpha() / 255f;
Camera c = SipoverPrivate.client.gameRenderer.getCamera();
Vec3d camPos = c.getPos();
start = start.subtract(camPos);
Vec3d end = start.add(dimensions);
Matrix4f matrix = stack.peek().getPositionMatrix();
float x1 = (float) start.x;
float y1 = (float) start.y;
float z1 = (float) start.z;
float x2 = (float) end.x;
float y2 = (float) end.y;
float z2 = (float) end.z;
BufferBuilder buffer = Tessellator.getInstance().getBuffer();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
GL11.glDepthFunc(GLMODE);
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
RenderSystem.defaultBlendFunc();
RenderSystem.enableBlend();
RenderSystem.disableCull();
buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
buffer.vertex(matrix, x1, y2, z1).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x1, y2, z2).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x2, y2, z2).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x2, y2, z1).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x1, y1, z2).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x2, y1, z2).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x2, y2, z2).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x1, y2, z2).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x2, y2, z2).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x2, y1, z2).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x2, y1, z1).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x2, y2, z1).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x2, y2, z1).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x2, y1, z1).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x1, y1, z1).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x1, y2, z1).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x1, y2, z1).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x1, y1, z1).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x1, y1, z2).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x1, y2, z2).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x1, y1, z1).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x2, y1, z1).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x2, y1, z2).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x1, y1, z2).color(red, green, blue, alpha).next();
buffer.end();
BufferRenderer.draw(buffer);
GL11.glDepthFunc(GL11.GL_LEQUAL);
RenderSystem.disableBlend();
RenderSystem.enableCull();
}
public static void line(Vec3d start, Vec3d end, Color color, MatrixStack matrices) {
float red = color.getRed() / 255f;
float green = color.getGreen() / 255f;
float blue = color.getBlue() / 255f;
float alpha = color.getAlpha() / 255f;
Camera c = SipoverPrivate.client.gameRenderer.getCamera();
Vec3d camPos = c.getPos();
start = start.subtract(camPos);
end = end.subtract(camPos);
Matrix4f matrix = matrices.peek().getPositionMatrix();
float x1 = (float) start.x;
float y1 = (float) start.y;
float z1 = (float) start.z;
float x2 = (float) end.x;
float y2 = (float) end.y;
float z2 = (float) end.z;
BufferBuilder buffer = Tessellator.getInstance().getBuffer();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
GL11.glDepthFunc(GL11.GL_ALWAYS);
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
RenderSystem.defaultBlendFunc();
RenderSystem.enableBlend();
buffer.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
buffer.vertex(matrix, x1, y1, z1).color(red, green, blue, alpha).next();
buffer.vertex(matrix, x2, y2, z2).color(red, green, blue, alpha).next();
buffer.end();
BufferRenderer.draw(buffer);
GL11.glDepthFunc(GL11.GL_LEQUAL);
RenderSystem.disableBlend();
}
public static Vec3d getCrosshairVector() {
Camera camera = SipoverPrivate.client.gameRenderer.getCamera();
ClientPlayerEntity player = SipoverPrivate.client.player;
float f = 0.017453292F;
float pi = (float) Math.PI;
assert player != null;
float f1 = MathHelper.cos(-player.getYaw() * f - pi);
float f2 = MathHelper.sin(-player.getYaw() * f - pi);
float f3 = -MathHelper.cos(-player.getPitch() * f);
float f4 = MathHelper.sin(-player.getPitch() * f);
return new Vec3d(f2 * f3, f4, f1 * f3).add(camera.getPos());
}
}
public static class R2D {
public static final Identifier OPTIONS_BACKGROUND_TEXTURE = new Identifier("sipoverprivate", "background.jpg");
public static void scissor(double x, double y, double width, double height) {
float d = (float) SipoverPrivate.client.getWindow().getScaleFactor();
int ay = (int) ((SipoverPrivate.client.getWindow().getScaledHeight() - (y + height)) * d);
RenderSystem.enableScissor((int) (x * d), ay, (int) (width * d), (int) (height * d));
}
public static void unscissor() {
RenderSystem.disableScissor();
}
public static void drawEntity(double x, double y, double size, float mouseX, float mouseY, LivingEntity entity, MatrixStack stack) {
float f = (float) Math.atan(mouseX / 40.0F);
float g = (float) Math.atan(mouseY / 40.0F);
MatrixStack matrixStack = RenderSystem.getModelViewStack();
matrixStack.push();
matrixStack.translate(x, y, 1050.0D);
matrixStack.scale(1.0F, 1.0F, -1.0F);
RenderSystem.applyModelViewMatrix();
stack.push();
stack.translate(0.0D, 0.0D, 1000.0D);
stack.scale((float) size, (float) size, (float) size);
Quaternion quaternion = Vec3f.POSITIVE_Z.getDegreesQuaternion(180.0F);
Quaternion quaternion2 = Vec3f.POSITIVE_X.getDegreesQuaternion(g * 20.0F);
quaternion.hamiltonProduct(quaternion2);
stack.multiply(quaternion);
float h = entity.bodyYaw;
float i = entity.getYaw();
float j = entity.getPitch();
float k = entity.prevHeadYaw;
float l = entity.headYaw;
entity.bodyYaw = 180.0F + f * 20.0F;
entity.setYaw(180.0F + f * 40.0F);
entity.setPitch(-g * 20.0F);
entity.headYaw = entity.getYaw();
entity.prevHeadYaw = entity.getYaw();
DiffuseLighting.method_34742();
EntityRenderDispatcher entityRenderDispatcher = MinecraftClient.getInstance().getEntityRenderDispatcher();
quaternion2.conjugate();
entityRenderDispatcher.setRotation(quaternion2);
entityRenderDispatcher.setRenderShadows(false);
VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
//noinspection deprecation
RenderSystem.runAsFancy(() -> entityRenderDispatcher.render(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, stack, immediate, 15728880));
immediate.draw();
entityRenderDispatcher.setRenderShadows(true);
entity.bodyYaw = h;
entity.setYaw(i);
entity.setPitch(j);
entity.prevHeadYaw = k;
entity.headYaw = l;
matrixStack.pop();
stack.pop();
RenderSystem.applyModelViewMatrix();
DiffuseLighting.enableGuiDepthLighting();
}
public static boolean isOnScreen(Vec3d pos) {
return pos != null && (pos.z > -1 && pos.z < 1);
}
public static Vec3d getScreenSpaceCoordinate(Vec3d pos, MatrixStack stack) {
Camera camera = SipoverPrivate.client.getEntityRenderDispatcher().camera;
Matrix4f matrix = stack.peek().getPositionMatrix();
double x = pos.x - camera.getPos().x;
double y = pos.y - camera.getPos().y;
double z = pos.z - camera.getPos().z;
Vector4f vector4f = new Vector4f((float) x, (float) y, (float) z, 1.f);
vector4f.transform(matrix);
int displayHeight = SipoverPrivate.client.getWindow().getHeight();
Vector3D screenCoords = new Vector3D();
int[] viewport = new int[4];
GL11.glGetIntegerv(GL11.GL_VIEWPORT, viewport);
Matrix4x4 matrix4x4Proj = Matrix4x4.copyFromColumnMajor(RenderSystem.getProjectionMatrix());//no more joml :)
Matrix4x4 matrix4x4Model = Matrix4x4.copyFromColumnMajor(RenderSystem.getModelViewMatrix());//but I do the math myself now :( (heck math)
matrix4x4Proj.mul(matrix4x4Model).project(vector4f.getX(), vector4f.getY(), vector4f.getZ(), viewport, screenCoords);
return new Vec3d(screenCoords.x / SipoverPrivate.client.getWindow().getScaleFactor(), (displayHeight - screenCoords.y) / SipoverPrivate.client.getWindow()
.getScaleFactor(), screenCoords.z);
}
public static Vec3d getScreenSpaceCoordinate(Vec3d pos) {
return getScreenSpaceCoordinate(pos, R3D.getLastRenderStack());
}
public static void gradientLineScreen(Color start, Color end, double x, double y, double x1, double y1) {
float g = start.getRed() / 255f;
float h = start.getGreen() / 255f;
float k = start.getBlue() / 255f;
float f = start.getAlpha() / 255f;
float g1 = end.getRed() / 255f;
float h1 = end.getGreen() / 255f;
float k1 = end.getBlue() / 255f;
float f1 = end.getAlpha() / 255f;
Matrix4f m = R3D.getEmptyMatrixStack().peek().getPositionMatrix();
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
RenderSystem.defaultBlendFunc();
RenderSystem.enableBlend();
RenderSystem.disableTexture();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(m, (float) x, (float) y, 0f).color(g, h, k, f).next();
bufferBuilder.vertex(m, (float) x1, (float) y1, 0f).color(g1, h1, k1, f1).next();
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
RenderSystem.enableTexture();
RenderSystem.disableBlend();
}
public static void fill(MatrixStack matrices, Color c, double x1, double y1, double x2, double y2) {
RenderSystem.setShaderColor(1, 1, 1, 1);
int color = c.getRGB();
double j;
if (x1 < x2) {
j = x1;
x1 = x2;
x2 = j;
}
if (y1 < y2) {
j = y1;
y1 = y2;
y2 = j;
}
Matrix4f matrix = matrices.peek().getPositionMatrix();
float f = (float) (color >> 24 & 255) / 255.0F;
float g = (float) (color >> 16 & 255) / 255.0F;
float h = (float) (color >> 8 & 255) / 255.0F;
float k = (float) (color & 255) / 255.0F;
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
RenderSystem.defaultBlendFunc();
RenderSystem.enableBlend();
RenderSystem.disableTexture();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(matrix, (float) x1, (float) y2, 0.0F).color(g, h, k, f).next();
bufferBuilder.vertex(matrix, (float) x2, (float) y2, 0.0F).color(g, h, k, f).next();
bufferBuilder.vertex(matrix, (float) x2, (float) y1, 0.0F).color(g, h, k, f).next();
bufferBuilder.vertex(matrix, (float) x1, (float) y1, 0.0F).color(g, h, k, f).next();
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
RenderSystem.enableTexture();
RenderSystem.disableBlend();
}
public static void fillGradientH(MatrixStack matrices, Color c2, Color c1, double x1, double y1, double x2, double y2) {
float r1 = c1.getRed() / 255f;
float g1 = c1.getGreen() / 255f;
float b1 = c1.getBlue() / 255f;
float a1 = c1.getAlpha() / 255f;
float r2 = c2.getRed() / 255f;
float g2 = c2.getGreen() / 255f;
float b2 = c2.getBlue() / 255f;
float a2 = c2.getAlpha() / 255f;
double j;
if (x1 < x2) {
j = x1;
x1 = x2;
x2 = j;
}
if (y1 < y2) {
j = y1;
y1 = y2;
y2 = j;
}
Matrix4f matrix = matrices.peek().getPositionMatrix();
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
RenderSystem.defaultBlendFunc();
RenderSystem.enableBlend();
RenderSystem.disableTexture();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(matrix, (float) x1, (float) y2, 0.0F).color(r1, g1, b1, a1).next();
bufferBuilder.vertex(matrix, (float) x2, (float) y2, 0.0F).color(r2, g2, b2, a2).next();
bufferBuilder.vertex(matrix, (float) x2, (float) y1, 0.0F).color(r2, g2, b2, a2).next();
bufferBuilder.vertex(matrix, (float) x1, (float) y1, 0.0F).color(r1, g1, b1, a1).next();
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
RenderSystem.enableTexture();
RenderSystem.disableBlend();
}
public static void fill(Color c, double x1, double y1, double x2, double y2) {
fill(R3D.getEmptyMatrixStack(), c, x1, y1, x2, y2);
}
public static void lineScreenD(Color c, double x, double y, double x1, double y1) {
float g = c.getRed() / 255f;
float h = c.getGreen() / 255f;
float k = c.getBlue() / 255f;
float f = c.getAlpha() / 255f;
Matrix4f m = R3D.getEmptyMatrixStack().peek().getPositionMatrix();
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
RenderSystem.defaultBlendFunc();
RenderSystem.enableBlend();
RenderSystem.disableTexture();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(m, (float) x, (float) y, 0f).color(g, h, k, f).next();
bufferBuilder.vertex(m, (float) x1, (float) y1, 0f).color(g, h, k, f).next();
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
RenderSystem.enableTexture();
RenderSystem.disableBlend();
}
public static void renderBackgroundTexture() {
if (SipoverPrivate.client.currentScreen instanceof SocialInteractionsScreen) {
return;
}
int width = SipoverPrivate.client.getWindow().getScaledWidth();
int height = SipoverPrivate.client.getWindow().getScaledHeight();
RenderSystem.setShaderColor(1, 1, 1, 1);
RenderSystem.setShaderTexture(0, OPTIONS_BACKGROUND_TEXTURE);
Screen.drawTexture(R3D.getEmptyMatrixStack(), 0, 0, 0, 0, width, height, width, height);
if (!(SipoverPrivate.client.currentScreen instanceof HomeScreen)) {
DrawableHelper.fill(R3D.getEmptyMatrixStack(), 0, 0, width, height, new Color(0, 0, 0, 60).getRGB());
}
}
}
public static class Util {
public static int lerp(int o, int i, double p) {
return (int) Math.floor(i + (o - i) * MathHelper.clamp(p, 0, 1));
}
public static double lerp(double i, double o, double p) {
return (i + (o - i) * MathHelper.clamp(p, 0, 1));
}
public static Color lerp(Color a, Color b, double c) {
return new Color(lerp(a.getRed(), b.getRed(), c), lerp(a.getGreen(), b.getGreen(), c), lerp(a.getBlue(), b.getBlue(), c), lerp(a.getAlpha(), b.getAlpha(), c));
}
/**
* @param original the original color
* @param redOverwrite the new red (or -1 for original)
* @param greenOverwrite the new green (or -1 for original)
* @param blueOverwrite the new blue (or -1 for original)
* @param alphaOverwrite the new alpha (or -1 for original)
* @return the modified color
*/
public static Color modify(Color original, int redOverwrite, int greenOverwrite, int blueOverwrite, int alphaOverwrite) {
return new Color(redOverwrite == -1 ? original.getRed() : redOverwrite, greenOverwrite == -1 ? original.getGreen() : greenOverwrite, blueOverwrite == -1 ? original.getBlue() : blueOverwrite, alphaOverwrite == -1 ? original.getAlpha() : alphaOverwrite);
}
}
}

View file

@ -0,0 +1,54 @@
package me.x150.sipprivate.mixin;
import me.x150.sipprivate.SipoverPrivate;
import me.x150.sipprivate.feature.module.Module;
import me.x150.sipprivate.feature.module.ModuleRegistry;
import me.x150.sipprivate.helper.ImGuiManager;
import me.x150.sipprivate.helper.render.Renderer;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(GameRenderer.class) public class GameRendererMixin {
Module noRender;
private boolean vb;
private boolean dis;
@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/GameRenderer;renderHand:Z", opcode = Opcodes.GETFIELD, ordinal = 0), method = "renderWorld")
void atomic_dispatchWorldRender(float tickDelta, long limitTime, MatrixStack matrix, CallbackInfo ci) {
Renderer.R3D.setLastRenderStack(matrix);
if (vb) {
SipoverPrivate.client.options.bobView = true;
vb = false;
}
for (Module module : ModuleRegistry.getModules()) {
if (module.isEnabled()) {
module.onWorldRender(matrix);
}
}
}
@Inject(method = "render", at = @At("HEAD")) void atomic_initShit(float tickDelta, long startTime, boolean tick, CallbackInfo ci) {
if (!ImGuiManager.isInitialized()) {
ImGuiManager.init();
}
}
@Inject(at = @At("HEAD"), method = "renderWorld") private void atomic_preRenderWorld(float tickDelta, long limitTime, MatrixStack matrix, CallbackInfo ci) {
dis = true;
}
@Inject(at = @At("HEAD"), method = "bobView", cancellable = true) private void atomic_stopCursorBob(MatrixStack matrices, float f, CallbackInfo ci) {
if (SipoverPrivate.client.options.bobView && dis) {
vb = true;
SipoverPrivate.client.options.bobView = false;
dis = false;
ci.cancel();
}
}
}

View file

@ -1,7 +1,9 @@
package me.x150.sipprivate.mixin;
import me.x150.sipprivate.SipoverPrivate;
import me.x150.sipprivate.util.ConfigManager;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.RunArgs;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -11,4 +13,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Inject(method = "stop", at = @At("HEAD")) void real(CallbackInfo ci) {
ConfigManager.saveState();
}
@Inject(method = "<init>", at = @At("TAIL")) void atomic_postInit(RunArgs args, CallbackInfo ci) {
SipoverPrivate.INSTANCE.postWindowInit();
}
}

BIN
src/main/resources/Font.ttf Normal file

Binary file not shown.

View file

@ -1,9 +1,10 @@
{
"required": true,
"package": "me.x150.sipprivate.mixin",
"compatibilityLevel": "JAVA_8",
"compatibilityLevel": "JAVA_17",
"mixins": [
"ClientPlayerEntityMixin",
"GameRendererMixin",
"IMinecraftClientAccessor",
"IRenderTickCounterAccessor",
"KeyboardMixin",