This commit is contained in:
0x3C50 2022-04-22 14:06:24 +02:00
parent 9b2d702e50
commit a796f83114
16 changed files with 208 additions and 173 deletions

View file

@ -5,6 +5,13 @@
package net.shadow.client.feature.command.impl; package net.shadow.client.feature.command.impl;
import net.shadow.client.feature.command.Command; import net.shadow.client.feature.command.Command;
import net.shadow.client.feature.module.AddonModule;
import net.shadow.client.feature.module.Module;
import net.shadow.client.feature.module.ModuleRegistry;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
public class Test extends Command { public class Test extends Command {
public Test() { public Test() {
@ -13,6 +20,16 @@ public class Test extends Command {
@Override @Override
public void onExecute(String[] args) { public void onExecute(String[] args) {
success("jooj"); StringBuilder sb = new StringBuilder();
for (Module module : ModuleRegistry.getModules()) {
if (module instanceof AddonModule) continue;
String cname = module.getClass().getSimpleName();
sb.append(String.format("registerModule(%s.class);",cname)).append("\n");
}
try {
Files.writeString(new File("bruh.txt").toPath(), sb.toString(), StandardOpenOption.CREATE);
} catch (Exception e) {
e.printStackTrace();
}
} }
} }

View file

@ -11,6 +11,7 @@ import net.shadow.client.feature.config.BooleanSetting;
import net.shadow.client.feature.config.DoubleSetting; import net.shadow.client.feature.config.DoubleSetting;
import net.shadow.client.feature.config.ModuleConfig; import net.shadow.client.feature.config.ModuleConfig;
import net.shadow.client.feature.gui.notifications.Notification; import net.shadow.client.feature.gui.notifications.Notification;
import net.shadow.client.helper.event.Events;
import net.shadow.client.helper.util.Utils; import net.shadow.client.helper.util.Utils;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
@ -119,9 +120,11 @@ public abstract class Module {
Notification.create(1000, "Module toggle", Notification.Type.INFO, (this.enabled ? "§aEn" : "§cDis") + "abled §r" + this.getName()); Notification.create(1000, "Module toggle", Notification.Type.INFO, (this.enabled ? "§aEn" : "§cDis") + "abled §r" + this.getName());
} }
if (this.enabled) { if (this.enabled) {
Events.registerEventHandlerClass(this);
this.enable(); this.enable();
} else { } else {
this.disable(); this.disable();
Events.unregisterEventHandlerClass(this);
} }
} }

View file

@ -49,6 +49,7 @@ import net.shadow.client.feature.module.impl.misc.AdBlock;
import net.shadow.client.feature.module.impl.misc.AdSpammer; import net.shadow.client.feature.module.impl.misc.AdSpammer;
import net.shadow.client.feature.module.impl.misc.AllowFormatCodes; import net.shadow.client.feature.module.impl.misc.AllowFormatCodes;
import net.shadow.client.feature.module.impl.misc.AntiCrash; import net.shadow.client.feature.module.impl.misc.AntiCrash;
import net.shadow.client.feature.module.impl.misc.AntiOffhandCrash;
import net.shadow.client.feature.module.impl.misc.AntiPacketKick; import net.shadow.client.feature.module.impl.misc.AntiPacketKick;
import net.shadow.client.feature.module.impl.misc.ClientSettings; import net.shadow.client.feature.module.impl.misc.ClientSettings;
import net.shadow.client.feature.module.impl.misc.DauntedAutoClaim; import net.shadow.client.feature.module.impl.misc.DauntedAutoClaim;
@ -133,6 +134,7 @@ import net.shadow.client.feature.module.impl.world.SurvivalNuker;
import net.shadow.client.feature.module.impl.world.XRAY; import net.shadow.client.feature.module.impl.world.XRAY;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
import java.lang.reflect.Constructor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@ -180,14 +182,27 @@ public class ModuleRegistry {
try { try {
initInner(); initInner();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); throw new RuntimeException(e);
System.exit(1);
} }
} }
private static void registerModule(Module module) { private static void registerModule(Class<? extends Module> moduleClass) {
ShadowMain.log(Level.INFO, "Initialized " + module.getName()); Module instance = null;
vanillaModules.add(module); for (Constructor<?> declaredConstructor : moduleClass.getDeclaredConstructors()) {
if (declaredConstructor.getParameterCount() != 0) {
throw new IllegalArgumentException(moduleClass.getName()+" has invalid constructor: expected "+moduleClass.getName()+"(), got "+declaredConstructor);
}
try {
instance = (Module) declaredConstructor.newInstance();
} catch (Exception e) {
throw new IllegalArgumentException("Failed to make instance of "+moduleClass.getName(), e);
}
}
if (instance == null) {
throw new IllegalArgumentException("Failed to make instance of "+moduleClass.getName());
}
ShadowMain.log(Level.INFO, "Initialized " + instance.getName()+" via "+moduleClass.getName());
vanillaModules.add(instance);
} }
private static void initInner() { private static void initInner() {
@ -195,133 +210,131 @@ public class ModuleRegistry {
initialized.set(true); initialized.set(true);
vanillaModules.clear(); vanillaModules.clear();
registerModule(new Flight()); registerModule(Flight.class);
registerModule(new Sprint()); registerModule(Sprint.class);
registerModule(new Fullbright()); registerModule(Fullbright.class);
registerModule(new Hud()); registerModule(Hud.class);
registerModule(new TargetHud()); registerModule(TargetHud.class);
//modules.add(new AntiOffhandCrash()); this should be under anticrash registerModule(AntiOffhandCrash.class);
registerModule(new AntiPacketKick()); registerModule(AntiPacketKick.class);
registerModule(new AntiRDI()); registerModule(AntiRDI.class);
registerModule(new BoatPhase()); registerModule(BoatPhase.class);
registerModule(new BoatCrash()); registerModule(BoatCrash.class);
registerModule(new Boom()); registerModule(Boom.class);
registerModule(new CaveMapper()); // its fun registerModule(CaveMapper.class);
registerModule(new InstaBow()); registerModule(InstaBow.class);
registerModule(new ChunkCrash()); registerModule(ChunkCrash.class);
registerModule(new OffhandCrash()); registerModule(OffhandCrash.class);
registerModule(new OOBCrash()); registerModule(OOBCrash.class);
registerModule(new Phase()); registerModule(Phase.class);
registerModule(new VanillaSpoof()); registerModule(VanillaSpoof.class);
registerModule(new XRAY()); registerModule(XRAY.class);
registerModule(new Decimator()); registerModule(Decimator.class);
registerModule(new ClickGUI()); registerModule(ClickGUI.class);
registerModule(new TpRange()); registerModule(TpRange.class);
registerModule(new AnyPlacer()); registerModule(AnyPlacer.class);
registerModule(new FireballDeflector()); // its a fucking utility client saturn registerModule(FireballDeflector.class);
registerModule(new ShulkerDeflector()); registerModule(ShulkerDeflector.class);
registerModule(new CarpetBomb()); registerModule(CarpetBomb.class);
//modules.add(new SkinChangeExploit()); litteral fucking joke module, to be re-written as personhider or whatever i named it (skinfuscator is a good name lol) registerModule(AutoTrap.class);
registerModule(new AutoTrap()); registerModule(AutoTNT.class);
registerModule(new AutoTNT()); registerModule(FakeHacker.class);
//modules.add(new LetThereBeLight()); awful why? registerModule(NoFall.class);
registerModule(new FakeHacker()); registerModule(ESP.class);
registerModule(new NoFall()); registerModule(Tracers.class);
registerModule(new ESP()); registerModule(Hyperspeed.class);
registerModule(new Tracers()); registerModule(AntiAnvil.class);
registerModule(new Hyperspeed()); registerModule(Swing.class);
registerModule(new AntiAnvil()); registerModule(AimAssist.class);
registerModule(new Swing()); registerModule(Criticals.class);
registerModule(new AimAssist()); registerModule(Killaura.class);
registerModule(new Criticals()); registerModule(Velocity.class);
registerModule(new Killaura()); //TODO: add settings and shit registerModule(AntiAntiXray.class);
registerModule(new Velocity()); registerModule(PingSpoof.class);
registerModule(new AntiAntiXray()); registerModule(AutoAttack.class);
registerModule(new PingSpoof()); registerModule(MouseEars.class);
registerModule(new AutoAttack()); registerModule(Spinner.class);
registerModule(new MouseEars()); //i really wanna remove this one | dont registerModule(AllowFormatCodes.class);
registerModule(new Spinner()); registerModule(InfChatLength.class);
registerModule(new AllowFormatCodes()); registerModule(NoTitles.class);
registerModule(new InfChatLength()); registerModule(PortalGUI.class);
registerModule(new NoTitles()); registerModule(Timer.class);
registerModule(new PortalGUI()); registerModule(XCarry.class);
registerModule(new Timer()); registerModule(AirJump.class);
registerModule(new XCarry()); registerModule(AutoElytra.class);
registerModule(new AirJump()); //TODO: unshit registerModule(Blink.class);
registerModule(new AutoElytra()); registerModule(Boost.class);
registerModule(new Blink()); registerModule(EdgeJump.class);
registerModule(new Boost()); registerModule(EdgeSneak.class);
registerModule(new EdgeJump()); // UTILITY CLIENT registerModule(EntityFly.class);
registerModule(new EdgeSneak()); registerModule(IgnoreWorldBorder.class);
registerModule(new EntityFly()); registerModule(InventoryWalk.class);
registerModule(new IgnoreWorldBorder()); //i'll allow it | as you should registerModule(Jesus.class);
registerModule(new InventoryWalk()); registerModule(LongJump.class);
registerModule(new Jesus()); registerModule(MoonGravity.class);
registerModule(new LongJump()); registerModule(NoJumpCool.class);
registerModule(new MoonGravity()); registerModule(NoLevitation.class);
registerModule(new NoJumpCool()); registerModule(NoPush.class);
registerModule(new NoLevitation()); registerModule(Step.class);
registerModule(new NoPush()); registerModule(Freecam.class);
registerModule(new Step()); registerModule(FreeLook.class);
registerModule(new Freecam()); registerModule(ItemByteSize.class);
registerModule(new FreeLook()); registerModule(Zoom.class);
registerModule(new ItemByteSize()); // TO BE RE-WRITTEN AS TOOLTIPS | keep it in for now tho registerModule(AutoTool.class);
registerModule(new Zoom()); registerModule(BlockTagViewer.class);
registerModule(new AutoTool()); // WHY????? this is so useless | how? registerModule(Annihilator.class);
registerModule(new BlockTagViewer()); registerModule(FastUse.class);
registerModule(new Annihilator()); registerModule(Flattener.class);
registerModule(new FastUse()); registerModule(GodBridge.class);
registerModule(new Flattener()); registerModule(InstantBreak.class);
registerModule(new GodBridge()); //TODO: add this as a mode to scaffold registerModule(MassUse.class);
registerModule(new InstantBreak()); //TODO: unshit registerModule(NoBreakDelay.class);
registerModule(new MassUse()); registerModule(SurvivalNuker.class);
registerModule(new NoBreakDelay()); registerModule(Nuker.class);
registerModule(new SurvivalNuker()); registerModule(Scaffold.class);
registerModule(new Nuker()); registerModule(Test.class);
registerModule(new Scaffold()); registerModule(BlocksMCFlight.class);
registerModule(new Test()); registerModule(NameTags.class);
registerModule(new BlocksMCFlight()); registerModule(Trail.class);
registerModule(new NameTags()); registerModule(AdBlock.class);
registerModule(new Trail()); registerModule(AutoLavacast.class);
registerModule(new AdBlock()); registerModule(Backtrack.class);
registerModule(new AutoLavacast()); registerModule(TabGui.class);
registerModule(new Backtrack()); registerModule(Theme.class);
registerModule(new TabGui()); registerModule(AntiCrash.class);
registerModule(new Theme()); registerModule(ClientSettings.class);
registerModule(new AntiCrash()); registerModule(NoLiquidFog.class);
registerModule(new ClientSettings()); registerModule(Spotlight.class);
registerModule(new NoLiquidFog()); registerModule(ShowTntPrime.class);
registerModule(new Spotlight()); registerModule(ToolsScreen.class);
registerModule(new ShowTntPrime()); registerModule(BookInflaterCrash.class);
registerModule(new ToolsScreen()); registerModule(BlockHighlighting.class);
registerModule(new BookInflaterCrash()); registerModule(AutoIgnite.class);
registerModule(new BlockHighlighting()); registerModule(DiscordRPC.class);
registerModule(new AutoIgnite()); registerModule(AirPlace.class);
registerModule(new DiscordRPC()); registerModule(AdSpammer.class);
registerModule(new AirPlace()); registerModule(AnimationCrash.class);
registerModule(new AdSpammer()); registerModule(AutoFireball.class);
registerModule(new AnimationCrash()); registerModule(AutoFish.class);
registerModule(new AutoFireball()); registerModule(AutoRun.class);
registerModule(new AutoFish()); registerModule(LecternCrash.class);
registerModule(new AutoRun()); registerModule(MinehutCrash.class);
registerModule(new LecternCrash()); registerModule(ArmorStandCrash.class);
registerModule(new MinehutCrash()); registerModule(LoominaCrash.class);
registerModule(new ArmorStandCrash()); registerModule(Reach.class);
registerModule(new LoominaCrash()); registerModule(Fling.class);
registerModule(new Reach()); registerModule(AutoSign.class);
registerModule(new Fling()); registerModule(SuperCrossbow.class);
registerModule(new AutoSign()); registerModule(ReverseKnockback.class);
registerModule(new SuperCrossbow()); registerModule(Speed.class);
registerModule(new ReverseKnockback()); registerModule(BoatFling.class);
registerModule(new Speed()); registerModule(FilterBypass.class);
registerModule(new BoatFling()); registerModule(InteractCrash.class);
registerModule(new FilterBypass()); registerModule(FlightCrash.class);
registerModule(new InteractCrash()); registerModule(ClickTP.class);
registerModule(new FlightCrash()); registerModule(ChestHighlighter.class);
registerModule(new ClickTP()); registerModule(DauntedAutoClaim.class);
registerModule(new ChestHighlighter()); registerModule(MoreChatHistory.class);
registerModule(new DauntedAutoClaim());
registerModule(new MoreChatHistory());
rebuildSharedModuleList(); rebuildSharedModuleList();
} }
@ -330,13 +343,21 @@ public class ModuleRegistry {
if (!initialized.get()) { if (!initialized.get()) {
init(); init();
} }
awaitLockOpen();
return sharedModuleList; return sharedModuleList;
} }
private static void awaitLockOpen() { private static void awaitLockOpen() {
if (reloadInProgress.get()) {
ShadowMain.log(Level.INFO, "Locking for some time for reload to complete");
long lockStart = System.currentTimeMillis();
long lockStartns = System.nanoTime();
while (reloadInProgress.get()) { while (reloadInProgress.get()) {
Thread.onSpinWait(); Thread.onSpinWait();
} }
ShadowMain.log(Level.INFO, "Lock opened within "+(System.currentTimeMillis()-lockStart)+" ms ("+(System.nanoTime()-lockStartns)+" ns)");
}
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View file

@ -15,7 +15,6 @@ import net.shadow.client.feature.module.Module;
import net.shadow.client.feature.module.ModuleType; import net.shadow.client.feature.module.ModuleType;
import net.shadow.client.helper.event.EventListener; import net.shadow.client.helper.event.EventListener;
import net.shadow.client.helper.event.EventType; 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.PacketEvent;
import net.shadow.client.helper.util.Utils; import net.shadow.client.helper.util.Utils;
@ -29,7 +28,7 @@ public class Fling extends Module {
public Fling() { public Fling() {
super("Fling", "Fling players in the air", ModuleType.COMBAT); super("Fling", "Fling players in the air", ModuleType.COMBAT);
Events.registerEventHandlerClass(this); // Events.registerEventHandlerClass(this);
} }
@Override @Override

View file

@ -13,7 +13,6 @@ import net.shadow.client.feature.module.Module;
import net.shadow.client.feature.module.ModuleType; import net.shadow.client.feature.module.ModuleType;
import net.shadow.client.helper.event.EventListener; import net.shadow.client.helper.event.EventListener;
import net.shadow.client.helper.event.EventType; 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.PacketEvent;
import java.util.ArrayList; import java.util.ArrayList;
@ -25,7 +24,7 @@ public class ReverseKnockback extends Module {
public ReverseKnockback() { public ReverseKnockback() {
super("ReverseKnockback", "Reverse the knockback you deal", ModuleType.MISC); super("ReverseKnockback", "Reverse the knockback you deal", ModuleType.MISC);
Events.registerEventHandlerClass(this); // Events.registerEventHandlerClass(this);
} }
@Override @Override

View file

@ -14,7 +14,6 @@ import net.shadow.client.feature.module.Module;
import net.shadow.client.feature.module.ModuleType; import net.shadow.client.feature.module.ModuleType;
import net.shadow.client.helper.event.EventListener; import net.shadow.client.helper.event.EventListener;
import net.shadow.client.helper.event.EventType; 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.PacketEvent;
import net.shadow.client.helper.util.Utils; import net.shadow.client.helper.util.Utils;
@ -29,7 +28,7 @@ public class FlightCrash extends Module {
public FlightCrash() { public FlightCrash() {
super("FlightCrash", "Generates a ton of chunks", ModuleType.CRASH); super("FlightCrash", "Generates a ton of chunks", ModuleType.CRASH);
Events.registerEventHandlerClass(this); // Events.registerEventHandlerClass(this);
} }
@Override @Override

View file

@ -19,7 +19,6 @@ import net.shadow.client.feature.module.Module;
import net.shadow.client.feature.module.ModuleType; import net.shadow.client.feature.module.ModuleType;
import net.shadow.client.helper.event.EventListener; import net.shadow.client.helper.event.EventListener;
import net.shadow.client.helper.event.EventType; 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.PacketEvent;
public class InteractCrash extends Module { public class InteractCrash extends Module {
@ -29,7 +28,7 @@ public class InteractCrash extends Module {
public InteractCrash() { public InteractCrash() {
super("InteractCrash", "Crash using interaction packets", ModuleType.CRASH); super("InteractCrash", "Crash using interaction packets", ModuleType.CRASH);
Events.registerEventHandlerClass(this); // Events.registerEventHandlerClass(this);
} }
@Override @Override

View file

@ -10,7 +10,6 @@ import net.shadow.client.feature.module.Module;
import net.shadow.client.feature.module.ModuleType; import net.shadow.client.feature.module.ModuleType;
import net.shadow.client.helper.event.EventListener; import net.shadow.client.helper.event.EventListener;
import net.shadow.client.helper.event.EventType; 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.PacketEvent;
public class FilterBypass extends Module { public class FilterBypass extends Module {
@ -19,7 +18,7 @@ public class FilterBypass extends Module {
public FilterBypass() { public FilterBypass() {
super("FilterBypass", "Bypass chat filters", ModuleType.EXPLOIT); super("FilterBypass", "Bypass chat filters", ModuleType.EXPLOIT);
Events.registerEventHandlerClass(this); // Events.registerEventHandlerClass(this);
} }
@Override @Override
@ -40,9 +39,9 @@ public class FilterBypass extends Module {
return null; return null;
} }
@EventListener(type = EventType.PACKET_RECEIVE) @EventListener(type = EventType.PACKET_SEND)
void onRecievePacket(PacketEvent event) { void onSendPacket(PacketEvent event) {
if (!this.isEnabled()) return; // if (!this.isEnabled()) return;
if (!blockPackets) return; if (!blockPackets) return;
if (event.getPacket() instanceof ChatMessageC2SPacket packet) { if (event.getPacket() instanceof ChatMessageC2SPacket packet) {
event.setCancelled(true); event.setCancelled(true);
@ -51,7 +50,6 @@ public class FilterBypass extends Module {
return; return;
} }
StringBuilder rvmsg = new StringBuilder(message).reverse(); StringBuilder rvmsg = new StringBuilder(message).reverse();
String msgout = rvmsg.toString();
String msgformatted = "\u202E " + rvmsg; String msgformatted = "\u202E " + rvmsg;
blockPackets = false; blockPackets = false;
client.player.networkHandler.sendPacket(new ChatMessageC2SPacket(msgformatted)); client.player.networkHandler.sendPacket(new ChatMessageC2SPacket(msgformatted));

View file

@ -13,7 +13,6 @@ import net.shadow.client.feature.module.Module;
import net.shadow.client.feature.module.ModuleType; import net.shadow.client.feature.module.ModuleType;
import net.shadow.client.helper.event.EventListener; import net.shadow.client.helper.event.EventListener;
import net.shadow.client.helper.event.EventType; import net.shadow.client.helper.event.EventType;
import net.shadow.client.helper.event.Events;
import net.shadow.client.helper.event.events.BlockRenderingEvent; import net.shadow.client.helper.event.events.BlockRenderingEvent;
import net.shadow.client.helper.render.Renderer; import net.shadow.client.helper.render.Renderer;
import net.shadow.client.helper.util.Utils; import net.shadow.client.helper.util.Utils;
@ -26,7 +25,7 @@ public class Test extends Module {
public Test() { public Test() {
super("Test", "Testing stuff with the client, can be ignored", ModuleType.MISC); super("Test", "Testing stuff with the client, can be ignored", ModuleType.MISC);
Events.registerEventHandlerClass(this); // Events.registerEventHandlerClass(this);
} }
@EventListener(type = EventType.BLOCK_RENDER) @EventListener(type = EventType.BLOCK_RENDER)

View file

@ -18,7 +18,6 @@ import net.shadow.client.feature.module.Module;
import net.shadow.client.feature.module.ModuleType; import net.shadow.client.feature.module.ModuleType;
import net.shadow.client.helper.event.EventListener; import net.shadow.client.helper.event.EventListener;
import net.shadow.client.helper.event.EventType; import net.shadow.client.helper.event.EventType;
import net.shadow.client.helper.event.Events;
import net.shadow.client.helper.event.events.MouseEvent; import net.shadow.client.helper.event.events.MouseEvent;
import net.shadow.client.helper.render.Renderer; import net.shadow.client.helper.render.Renderer;
import net.shadow.client.helper.util.Utils; import net.shadow.client.helper.util.Utils;
@ -31,7 +30,7 @@ public class ClickTP extends Module {
public ClickTP() { public ClickTP() {
super("ClickTP", "Teleport somewhere you clicked to", ModuleType.MOVEMENT); super("ClickTP", "Teleport somewhere you clicked to", ModuleType.MOVEMENT);
Events.registerEventHandlerClass(this); // Events.registerEventHandlerClass(this);
} }
private static int lengthTo(BlockPos p) { private static int lengthTo(BlockPos p) {

View file

@ -13,7 +13,6 @@ import net.shadow.client.feature.module.Module;
import net.shadow.client.feature.module.ModuleType; import net.shadow.client.feature.module.ModuleType;
import net.shadow.client.helper.event.EventListener; import net.shadow.client.helper.event.EventListener;
import net.shadow.client.helper.event.EventType; import net.shadow.client.helper.event.EventType;
import net.shadow.client.helper.event.Events;
import net.shadow.client.helper.event.events.BlockEntityRenderEvent; import net.shadow.client.helper.event.events.BlockEntityRenderEvent;
import net.shadow.client.helper.render.Renderer; import net.shadow.client.helper.render.Renderer;
@ -26,7 +25,7 @@ public class ChestHighlighter extends Module {
public ChestHighlighter() { public ChestHighlighter() {
super("ChestHighlighter", "No description", ModuleType.RENDER); super("ChestHighlighter", "No description", ModuleType.RENDER);
Events.registerEventHandlerClass(this); // Events.registerEventHandlerClass(this);
} }
void addIfNotExisting(BlockPos p) { void addIfNotExisting(BlockPos p) {

View file

@ -52,12 +52,6 @@ public class NameTags extends Module {
} }
} }
GameMode getGamemode(AbstractClientPlayerEntity p) {
PlayerListEntry ple = client.getNetworkHandler().getPlayerListEntry(p.getUuid());
if (ple == null) return null;
return ple.getGameMode();
}
void drawInternal(Vec3d screenPos, String text, AbstractClientPlayerEntity entity) { void drawInternal(Vec3d screenPos, String text, AbstractClientPlayerEntity entity) {
FontAdapter nameDrawer = FontRenderers.getRenderer(); FontAdapter nameDrawer = FontRenderers.getRenderer();
FontAdapter infoDrawer = FontRenderers.getCustomSize(12); FontAdapter infoDrawer = FontRenderers.getCustomSize(12);
@ -111,7 +105,7 @@ public class NameTags extends Module {
@Override @Override
public void onWorldRender(MatrixStack matrices) { public void onWorldRender(MatrixStack matrices) {
// sort the entire thing based on the most distant to the least distant because thats how rendering works // sort the entire thing based on the most distant to the least distant because thats how rendering works
for (AbstractClientPlayerEntity player : client.world.getPlayers().stream().sorted(Comparator.comparingDouble(value -> -value.getPos().distanceTo(client.gameRenderer.getCamera().getPos()))).toList()) { for (AbstractClientPlayerEntity player : client.world.getPlayers().stream().sorted(Comparator.comparingDouble(value -> -value.getPos().distanceTo(client.gameRenderer.getCamera().getPos()))).filter(abstractClientPlayerEntity -> !abstractClientPlayerEntity.equals(client.player)).toList()) {
// String t = player.getEntityName(); // String t = player.getEntityName();
render(matrices, player, player.getName()); render(matrices, player, player.getName());
} }

View file

@ -11,6 +11,7 @@ import org.apache.logging.log4j.Level;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
@ -21,8 +22,12 @@ public class Events {
static final List<ListenerEntry> entries = new CopyOnWriteArrayList<>(); static final List<ListenerEntry> entries = new CopyOnWriteArrayList<>();
public static ListenerEntry registerEventHandler(int uniqueId, EventType event, Consumer<? extends Event> handler) { public static ListenerEntry registerEventHandler(int uniqueId, EventType event, Consumer<? extends Event> handler) {
return registerEventHandler(uniqueId, event, handler, Events.class);
}
public static ListenerEntry registerEventHandler(int uniqueId, EventType event, Consumer<? extends Event> handler, Class<?> owner) {
if (entries.stream().noneMatch(listenerEntry -> listenerEntry.id == uniqueId)) { if (entries.stream().noneMatch(listenerEntry -> listenerEntry.id == uniqueId)) {
ListenerEntry le = new ListenerEntry(uniqueId, event, handler); ListenerEntry le = new ListenerEntry(uniqueId, event, handler, owner);
entries.add(le); entries.add(le);
return le; return le;
} else { } else {
@ -38,7 +43,14 @@ public class Events {
public static ListenerEntry registerEventHandler(EventType event, Consumer<? extends Event> handler) { public static ListenerEntry registerEventHandler(EventType event, Consumer<? extends Event> handler) {
return registerEventHandler((int) Math.floor(Math.random() * 0xFFFFFF), event, handler); return registerEventHandler((int) Math.floor(Math.random() * 0xFFFFFF), event, handler);
} }
public static void unregisterEventHandlerClass(Object instance) {
for (ListenerEntry entry : new ArrayList<>(entries)) {
if (entry.owner.equals(instance.getClass())) {
ShadowMain.log(Level.INFO, "Unregistering "+entry.type+":"+entry.id);
entries.remove(entry);
}
}
}
public static void registerEventHandlerClass(Object instance) { public static void registerEventHandlerClass(Object instance) {
for (Method declaredMethod : instance.getClass().getDeclaredMethods()) { for (Method declaredMethod : instance.getClass().getDeclaredMethods()) {
for (Annotation declaredAnnotation : declaredMethod.getDeclaredAnnotations()) { for (Annotation declaredAnnotation : declaredMethod.getDeclaredAnnotations()) {
@ -56,11 +68,9 @@ public class Events {
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
} }
}); }, instance.getClass());
ShadowMain.log(Level.INFO, "Registered event handler " + declaredMethod + " with id " + l.id); ShadowMain.log(Level.INFO, "Registered event handler " + declaredMethod + " with id " + l.id);
} }
} }
} }
} }
@ -76,6 +86,6 @@ public class Events {
return argument.isCancelled(); return argument.isCancelled();
} }
record ListenerEntry(int id, EventType type, Consumer<? extends Event> eventListener) { record ListenerEntry(int id, EventType type, Consumer<? extends Event> eventListener, Class<?> owner) {
} }
} }

View file

@ -90,7 +90,7 @@ public class GameRendererMixin {
} }
} }
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;raycast(DFZ)Lnet/minecraft/util/hit/HitResult;"), method = "updateTargetedEntity") @Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;raycast(DFZ)Lnet/minecraft/util/hit/HitResult;"), method = "updateTargetedEntity",require = 0)
HitResult replaceFreelookHitResult(Entity instance, double maxDistance, float tickDelta, boolean includeFluids) { HitResult replaceFreelookHitResult(Entity instance, double maxDistance, float tickDelta, boolean includeFluids) {
if (ModuleRegistry.getByClass(FreeLook.class).isEnabled()) { if (ModuleRegistry.getByClass(FreeLook.class).isEnabled()) {
Vec3d vec3d = instance.getCameraPosVec(tickDelta); Vec3d vec3d = instance.getCameraPosVec(tickDelta);

View file

@ -1,3 +1,2 @@
Port all the items Fixed compat issues
Fix automated crash reports Fixed race condition crash on startup
Sus

View file

@ -1 +1 @@
19 20