This commit is contained in:
0x3C50 2022-04-05 01:04:17 +02:00
parent d729fba5b4
commit 1835c7187c
13 changed files with 174 additions and 38 deletions

View file

@ -148,7 +148,7 @@ public class ShadowMain implements ModInitializer {
FAST_TICKER.start();
// ModuleRegistry.sortModulesPostInit();
CommandRegistry.init();
System.out.println("sending post init");
log(Level.INFO, "Sending post window init");
Events.fireEvent(EventType.POST_INIT, new PostInitEvent());
for (Module module : ModuleRegistry.getModules()) {
module.postInit();

View file

@ -83,7 +83,7 @@ public class ItemExploit extends Command {
}
}
if (!argStack.isEmpty()) argsWhitespaced.add(argStack.toString().trim());
System.out.println(argsWhitespaced);
// System.out.println(argsWhitespaced);
OptionParser opt = new OptionParser(true);
opt.allowsUnrecognizedOptions();
for (Option<?> option : meant.getOptions()) {

View file

@ -86,7 +86,7 @@ public class HomeScreen extends ClientScreen implements FastTickable {
isDev = execF.isDirectory();
HomeScreen.version = IOUtils.toString(Objects.requireNonNull(HomeScreen.class.getClassLoader().getResourceAsStream("version.txt")), StandardCharsets.UTF_8);
HomeScreen.changelog = IOUtils.toString(Objects.requireNonNull(HomeScreen.class.getClassLoader().getResourceAsStream("changelogLatest.txt")), StandardCharsets.UTF_8);
System.out.println("updating acc");
// System.out.println("updating acc");
updateCurrentAccount(() -> {
});
@ -170,7 +170,7 @@ public class HomeScreen extends ClientScreen implements FastTickable {
ByteBuffer data = BufferUtils.createByteBuffer(bytes.length).put(bytes);
data.flip();
NativeImage img = NativeImage.read(data);
System.out.println(img);
// System.out.println(img);
NativeImageBackedTexture texture = new NativeImageBackedTexture(img);
ShadowMain.client.execute(() -> {

View file

@ -52,7 +52,7 @@ public class Annhilator extends Module {
int startY = MathHelper.clamp(r(pos.getY() - range.getValue()), Objects.requireNonNull(ShadowMain.client.world).getBottomY(), ShadowMain.client.world.getTopY());
int endY = MathHelper.clamp(r(pos.getY() + range.getValue()), ShadowMain.client.world.getBottomY(), ShadowMain.client.world.getTopY());
String cmd = "/fill " + r(pos.getX() - range.getValue()) + " " + startY + " " + r(pos.getZ() - range.getValue()) + " " + r(pos.getX() + range.getValue()) + " " + endY + " " + r(pos.getZ() + range.getValue()) + " " + "minecraft:" + block.getValue();
System.out.println(cmd);
// System.out.println(cmd);
client.player.sendChatMessage(cmd);
}

View file

@ -4,32 +4,43 @@
package net.shadow.client.feature.module.impl.misc;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.network.packet.c2s.play.ButtonClickC2SPacket;
import net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.shadow.client.feature.module.Module;
import net.shadow.client.feature.module.ModuleType;
import net.shadow.client.helper.event.EventListener;
import net.shadow.client.helper.event.EventType;
import net.shadow.client.helper.event.Events;
import net.shadow.client.helper.event.events.PacketEvent;
import net.shadow.client.helper.event.events.BlockRenderingEvent;
import net.shadow.client.helper.render.Renderer;
import net.shadow.client.helper.util.Utils;
import java.util.concurrent.CopyOnWriteArrayList;
public class Test extends Module {
static final Block searchTerm = Blocks.NETHER_PORTAL;
CopyOnWriteArrayList<BlockPos> discovered = new CopyOnWriteArrayList<>();
public Test() {
super("Test", "Testing stuff with the client, can be ignored", ModuleType.MISC);
Events.registerEventHandler(EventType.PACKET_SEND, e -> {
if (!this.isEnabled()) return;
PacketEvent event = (PacketEvent) e;
System.out.println(event.getPacket());
if (event.getPacket() instanceof ClickSlotC2SPacket uwu) {
System.out.println(uwu.getSlot() + " <- slot");
System.out.println(uwu.getButton() + " <- button");
Events.registerEventHandlerClass(this);
}
@EventListener(type = EventType.BLOCK_RENDER)
void onBlockRender(BlockRenderingEvent event) {
if (!this.isEnabled()) return;
BlockPos b = new BlockPos(event.getPosition());
boolean listContains = discovered.stream().anyMatch(blockPos -> blockPos.equals(b));
if (event.getBlockState().getBlock() == searchTerm) {
if (!listContains) {
discovered.add(b);
}
if (event.getPacket() instanceof ButtonClickC2SPacket uwu) {
System.out.println(uwu.getButtonId() + " <- Button id");
}
});
} else if (listContains) {
discovered.removeIf(blockPos -> blockPos.equals(b));
}
}
@Override
@ -49,6 +60,12 @@ public class Test extends Module {
@Override
public void onWorldRender(MatrixStack matrices) {
for (BlockPos bruh : discovered) {
Renderer.R3D.renderEdged(matrices, Vec3d.of(bruh), new Vec3d(1, 1, 1), Renderer.Util.modify(Utils.getCurrentRGB(), -1, -1, -1, 100).darker(), Renderer.Util.modify(Utils.getCurrentRGB(), -1, -1, -1, 255));
}
// for (BlockPos bruh : bruhs.pop()) {
// Renderer.R3D.renderEdged(matrices, Vec3d.of(bruh), new Vec3d(1,1,1), Renderer.Util.modify(Utils.getCurrentRGB(), -1, -1, -1, 100).darker(), Renderer.Util.modify(Utils.getCurrentRGB(), -1, -1, -1, 255));
// }
}
@Override
@ -58,6 +75,7 @@ public class Test extends Module {
@Override
public void tick() {
client.interactionManager.clickSlot(0, 0, 0, SlotActionType.QUICK_MOVE, client.player);
discovered.removeIf(blockPos -> client.world.getBlockState(blockPos).getBlock() != searchTerm);
// client.interactionManager.clickSlot(0, 0, 0, SlotActionType.QUICK_MOVE, client.player);
}
}

View file

@ -0,0 +1,24 @@
/*
* Copyright (c) Shadow client, 0x150, Saturn5VFive 2022. All rights reserved.
*/
package net.shadow.client.helper;
import java.util.ArrayList;
import java.util.List;
public class ConcurrentList<T> {
private List<T> list = new ArrayList<>();
public List<T> pop() {
return new ArrayList<>(list);
}
public void push(List<T> modifiedCopy) {
this.list = modifiedCopy;
}
public List<T> get() {
return list;
}
}

View file

@ -0,0 +1,13 @@
/*
* Copyright (c) Shadow client, 0x150, Saturn5VFive 2022. All rights reserved.
*/
package net.shadow.client.helper.event;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface EventListener {
EventType type();
}

View file

@ -4,28 +4,57 @@
package net.shadow.client.helper.event;
import net.shadow.client.ShadowMain;
import net.shadow.client.helper.event.events.base.Event;
import org.apache.logging.log4j.Level;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
public class Events {
static final Map<EventType, List<Consumer<Event>>> HANDLERS = new HashMap<>();
static final Map<EventType, List<Consumer<? extends Event>>> HANDLERS = new HashMap<>();
public static void registerEventHandler(EventType event, Consumer<Event> handler) {
public static void registerEventHandler(EventType event, Consumer<? extends Event> handler) {
if (!HANDLERS.containsKey(event)) {
HANDLERS.put(event, new ArrayList<>());
}
HANDLERS.get(event).add(handler);
}
public static void registerEventHandlerClass(Object instance) {
for (Method declaredMethod : instance.getClass().getDeclaredMethods()) {
for (Annotation declaredAnnotation : declaredMethod.getDeclaredAnnotations()) {
if (declaredAnnotation.annotationType() == EventListener.class) {
EventListener ev = (EventListener) declaredAnnotation;
Class<?>[] params = declaredMethod.getParameterTypes();
if (params.length != 1 || !Event.class.isAssignableFrom(params[0])) {
ShadowMain.log(Level.ERROR, "Event handler " + declaredMethod.getName() + "(" + Arrays.stream(params).map(Class::getSimpleName).collect(Collectors.joining(", ")) + ") -> " + declaredMethod.getReturnType().getName() + " from " + instance.getClass().getName() + " is malformed, skipping");
} else {
declaredMethod.setAccessible(true);
registerEventHandler(ev.type(), event -> {
try {
declaredMethod.invoke(instance, event);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
});
}
}
}
}
}
@SuppressWarnings("unchecked")
public static boolean fireEvent(EventType event, Event argument) {
if (HANDLERS.containsKey(event)) {
for (Consumer<Event> handler : HANDLERS.get(event)) {
for (Consumer handler : HANDLERS.get(event)) {
handler.accept(argument);
}
}

View file

@ -16,6 +16,7 @@ import net.shadow.client.helper.event.EventType;
import net.shadow.client.helper.event.Events;
import net.shadow.client.helper.event.events.base.NonCancellableEvent;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.Level;
import java.io.ByteArrayOutputStream;
import java.io.File;
@ -72,10 +73,10 @@ public class ConfigManager {
*/
public static void saveState() {
if (!loaded || !enabled) {
System.out.println("Not saving config because we didn't load it yet");
ShadowMain.log(Level.INFO, "Not saving config because we didn't load it yet");
return;
}
System.out.println("Saving state");
ShadowMain.log(Level.INFO, "Saving state");
JsonObject base = new JsonObject();
JsonArray enabled = new JsonArray();
JsonArray config = new JsonArray();
@ -101,7 +102,7 @@ public class ConfigManager {
FileUtils.writeByteArrayToFile(CONFIG_FILE, compress(base.toString().getBytes(StandardCharsets.UTF_8)));
} catch (Exception e) {
e.printStackTrace();
System.out.println("Failed to save config!");
ShadowMain.log(Level.ERROR, "Failed to save config!");
}
Events.fireEvent(EventType.CONFIG_SAVE, new NonCancellableEvent());
}

View file

@ -29,17 +29,23 @@ public class Renderer {
public static class R3D {
static final MatrixStack empty = new MatrixStack();
static final List<FadingBlock> fades = new ArrayList<>();
static List<FadingBlock> fades = new ArrayList<>();
public static void renderFadingBlock(Color outlineColor, Color fillColor, Vec3d start, Vec3d dimensions, long lifeTimeMs) {
FadingBlock fb = new FadingBlock(outlineColor, fillColor, start, dimensions, System.currentTimeMillis(), lifeTimeMs);
fades.removeIf(fadingBlock -> fadingBlock.start.equals(start) && fadingBlock.dimensions.equals(dimensions));
fades.add(fb);
// concurrentmodexception fuckaround
ArrayList<FadingBlock> clone = new ArrayList<>(fades);
clone.removeIf(fadingBlock -> fadingBlock.start.equals(start) && fadingBlock.dimensions.equals(dimensions));
clone.add(fb);
fades = clone;
}
public static void renderFadingBlocks(MatrixStack stack) {
fades.removeIf(FadingBlock::isDead);
for (FadingBlock fade : new ArrayList<>(fades)) {
// concurrentmodexception fuckaround, locks didnt work for some fucking reason
ArrayList<FadingBlock> clone = new ArrayList<>(fades);
clone.removeIf(FadingBlock::isDead);
for (FadingBlock fade : clone) {
if (fade == null) continue;
long lifetimeLeft = fade.getLifeTimeLeft();
double progress = lifetimeLeft / (double) fade.lifeTime;
@ -47,6 +53,7 @@ public class Renderer {
Color fill = Util.modify(fade.fill, -1, -1, -1, (int) (fade.fill.getAlpha() * progress));
Renderer.R3D.renderEdged(stack, fade.start, fade.dimensions, fill, out);
}
fades = clone;
}
public static void renderCircleOutline(MatrixStack stack, Color c, Vec3d start, double rad, double width, double segments) {

View file

@ -92,7 +92,6 @@ public class Utils {
NativeImageBackedTexture tex = new NativeImageBackedTexture(NativeImage.read(data));
ShadowMain.client.execute(() -> ShadowMain.client.getTextureManager().registerTexture(i, tex));
} catch (Exception e) {
System.out.println("failed to register");
e.printStackTrace();
}
}
@ -359,7 +358,6 @@ public class Utils {
}
public static void message0(String n, Color c) {
System.out.println(n);
LiteralText t = new LiteralText(n);
t.setStyle(t.getStyle().withColor(TextColor.fromRgb(c.getRGB())));
if (ShadowMain.client.player != null) ShadowMain.client.player.sendMessage(t, false);

View file

@ -0,0 +1,45 @@
/*
* Copyright (c) Shadow client, 0x150, Saturn5VFive 2022. All rights reserved.
*/
package net.shadow.client.mixin;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.client.render.chunk.BlockBufferBuilderStorage;
import net.minecraft.client.render.chunk.ChunkBuilder;
import net.minecraft.client.render.chunk.ChunkOcclusionDataBuilder;
import net.minecraft.client.render.chunk.ChunkRendererRegion;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.fluid.FluidState;
import net.minecraft.util.math.BlockPos;
import net.shadow.client.helper.event.EventType;
import net.shadow.client.helper.event.Events;
import net.shadow.client.helper.event.events.BlockRenderingEvent;
import org.spongepowered.asm.mixin.Debug;
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.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import java.util.Iterator;
import java.util.Random;
import java.util.Set;
@Debug(export = true)
@Mixin(targets = "net/minecraft/client/render/chunk/ChunkBuilder$BuiltChunk$RebuildTask")
public class RebuildTaskMixin {
@Inject(method = "render", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/util/math/MatrixStack;translate(DDD)V",
shift = At.Shift.AFTER
), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
void real(float cameraX, float cameraY, float cameraZ, ChunkBuilder.ChunkData data, BlockBufferBuilderStorage buffers, CallbackInfoReturnable<Set<BlockEntity>> cir, int i, BlockPos blockPos, BlockPos blockPos2, ChunkOcclusionDataBuilder chunkOcclusionDataBuilder, Set set, ChunkRendererRegion chunkRendererRegion, MatrixStack matrixStack, Random random, BlockRenderManager blockRenderManager, Iterator var15, BlockPos blockPos3, BlockState blockState, BlockState blockEntity, FluidState fluidState, RenderLayer renderLayer, BufferBuilder bufferBuilder) {
BlockRenderingEvent be = new BlockRenderingEvent(matrixStack, blockPos3, blockState);
Events.fireEvent(EventType.BLOCK_RENDER, be);
}
}

View file

@ -54,6 +54,7 @@
"PlayerEntityRendererMixin",
"PlayerInteractEntityC2SPacketAccessor",
"PlayerSkinMixin",
"RebuildTaskMixin",
"ScreenMixin",
"SelectWorldScreenMixin",
"SessionAccessor",