From dde0467086d2bf78eeab2d4568994324b06e17e9 Mon Sep 17 00:00:00 2001 From: 0x3C50 Date: Mon, 4 Apr 2022 02:34:42 +0200 Subject: [PATCH] the reformat --- .../shadow/client/feature/addon/Addon.java | 4 +- .../client/feature/addon/AddonManager.java | 26 +++--- .../feature/command/CommandRegistry.java | 16 ++-- .../argument/StringArgumentParser.java | 2 - .../client/feature/config/SettingBase.java | 3 +- .../gui/screen/AddonManagerScreen.java | 91 ++++++++++--------- .../client/feature/module/ModuleRegistry.java | 12 +-- .../module/impl/crash/LecternCrash.java | 9 +- .../client/feature/module/impl/misc/Test.java | 17 ++-- .../module/impl/movement/NoLevitation.java | 4 +- .../feature/module/impl/render/Hud.java | 5 +- .../shadow/client/mixin/GameMenuMixin.java | 4 +- .../client/mixin/LivingEntityMixin.java | 2 +- 13 files changed, 89 insertions(+), 106 deletions(-) diff --git a/src/main/java/net/shadow/client/feature/addon/Addon.java b/src/main/java/net/shadow/client/feature/addon/Addon.java index 933bcc3..4b5e796 100644 --- a/src/main/java/net/shadow/client/feature/addon/Addon.java +++ b/src/main/java/net/shadow/client/feature/addon/Addon.java @@ -8,16 +8,16 @@ import net.minecraft.util.Identifier; import net.shadow.client.feature.command.Command; import net.shadow.client.feature.module.AddonModule; -import java.awt.image.BufferedImage; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; @SuppressWarnings("unused") public abstract class Addon { - private final AtomicBoolean isEnabled = new AtomicBoolean(false); public final String name; public final String description; public final String[] developers; + private final AtomicBoolean isEnabled = new AtomicBoolean(false); + public Addon(String name, String description, String[] developers) { this.name = name; this.description = description; diff --git a/src/main/java/net/shadow/client/feature/addon/AddonManager.java b/src/main/java/net/shadow/client/feature/addon/AddonManager.java index 4d821c2..32ba2b2 100644 --- a/src/main/java/net/shadow/client/feature/addon/AddonManager.java +++ b/src/main/java/net/shadow/client/feature/addon/AddonManager.java @@ -4,14 +4,12 @@ package net.shadow.client.feature.addon; -import net.minecraft.entity.passive.AbstractDonkeyEntity; import net.shadow.client.ShadowMain; import net.shadow.client.feature.command.Command; import net.shadow.client.feature.command.CommandRegistry; import net.shadow.client.feature.config.ModuleConfig; import net.shadow.client.feature.config.SettingBase; import net.shadow.client.feature.gui.clickgui.ClickGUI; -import net.shadow.client.feature.gui.clickgui.theme.impl.Shadow; import net.shadow.client.feature.module.AddonModule; import net.shadow.client.feature.module.Module; import net.shadow.client.feature.module.ModuleRegistry; @@ -32,7 +30,6 @@ public class AddonManager { 0xCA, 0xFE, 0xBA, 0xBE }; public static AddonManager INSTANCE; - record AddonEntry(File sourceFile, String name, String description, String[] devs, Addon registeredAddon) {} private final List loadedAddons = new ArrayList<>(); @SuppressWarnings("ResultOfMethodCallIgnored") @@ -43,14 +40,14 @@ public class AddonManager { initializeAddons(); } - public List getLoadedAddons() { - return loadedAddons.stream().map(addonEntry -> addonEntry.registeredAddon).toList(); - } - public static void init() { new AddonManager(); } + public List getLoadedAddons() { + return loadedAddons.stream().map(addonEntry -> addonEntry.registeredAddon).toList(); + } + void initializeAddons() { for (File file : Objects.requireNonNull(ADDON_DIRECTORY.listFiles())) { if (file.getName().endsWith(".jar")) { @@ -92,11 +89,12 @@ public class AddonManager { @SuppressWarnings("ResultOfMethodCallIgnored") public void discoverNewAddons() { for (File file : Objects.requireNonNull(ADDON_DIRECTORY.listFiles())) { - if (loadedAddons.stream().anyMatch(addonEntry -> addonEntry.sourceFile.getAbsoluteFile().equals(file.getAbsoluteFile()))) continue; + if (loadedAddons.stream().anyMatch(addonEntry -> addonEntry.sourceFile.getAbsoluteFile().equals(file.getAbsoluteFile()))) + continue; if (file.getName().endsWith(".jar")) { if (safeLoadAddon(file) == null) { ShadowMain.log(Level.WARN, "Renaming addon to prevent re-discovery because it failed to load"); - file.renameTo(new File(file.getAbsolutePath()+".disabled")); + file.renameTo(new File(file.getAbsolutePath() + ".disabled")); } } } @@ -110,9 +108,6 @@ public class AddonManager { storedConfig.put(customModule.module().getName(), customModule.module().config); } } -// if (addon.getAdditionalModules() != null) for (AddonModule additionalModule : addon.getAdditionalModules()) { -// storedConfig.put(additionalModule.getName(), additionalModule.config); -// } if (addon.isEnabled()) disableAddon(addon); AddonEntry meant = null; for (AddonEntry loadedAddon : loadedAddons) { @@ -218,7 +213,7 @@ public class AddonManager { try { mainClass = (Addon) loadedClass.getDeclaredConstructor().newInstance(); } catch (NoSuchMethodException e) { - throw new IllegalStateException("Jarfile "+location.getName()+" has invalid main class: No constructor without arguments"); + throw new IllegalStateException("Jarfile " + location.getName() + " has invalid main class: No constructor without arguments"); } // System.out.println("Found main class " + loadedClass.getName()); } @@ -228,8 +223,11 @@ public class AddonManager { if (mainClass == null) throw new IllegalStateException("Jarfile " + location.getName() + " does not have a main class"); ShadowMain.log(Level.INFO, "Discovered addon " + mainClass.name + " by " + String.join(", ", mainClass.developers)); - loadedAddons.add(new AddonEntry(location,mainClass.name,mainClass.description,mainClass.developers,mainClass)); + loadedAddons.add(new AddonEntry(location, mainClass.name, mainClass.description, mainClass.developers, mainClass)); return mainClass; } + + record AddonEntry(File sourceFile, String name, String description, String[] devs, Addon registeredAddon) { + } } diff --git a/src/main/java/net/shadow/client/feature/command/CommandRegistry.java b/src/main/java/net/shadow/client/feature/command/CommandRegistry.java index 32d82f3..8e21461 100644 --- a/src/main/java/net/shadow/client/feature/command/CommandRegistry.java +++ b/src/main/java/net/shadow/client/feature/command/CommandRegistry.java @@ -18,6 +18,11 @@ public class CommandRegistry { private static final List customCommands = new ArrayList<>(); private static final List sharedCommands = new ArrayList<>(); + static { + // TODO: 18.12.21 add commands + init(); + } + public static void registerCustomCommand(Addon addon, Command command) { for (CustomCommandEntry e : customCommands) { if (e.command.getClass() == command.getClass()) { @@ -96,18 +101,10 @@ public class CommandRegistry { vanillaCommands.add(new ClearInventory()); } - static { - // TODO: 18.12.21 add commands - init(); - } - public static List getCommands() { return sharedCommands; } - record CustomCommandEntry(Addon addon, Command command) { - } - public static void execute(String command) { String[] spl = command.split(" +"); String cmd = spl[0].toLowerCase(); @@ -139,4 +136,7 @@ public class CommandRegistry { } return null; } + + record CustomCommandEntry(Addon addon, Command command) { + } } diff --git a/src/main/java/net/shadow/client/feature/command/argument/StringArgumentParser.java b/src/main/java/net/shadow/client/feature/command/argument/StringArgumentParser.java index a66fd26..b15a11d 100644 --- a/src/main/java/net/shadow/client/feature/command/argument/StringArgumentParser.java +++ b/src/main/java/net/shadow/client/feature/command/argument/StringArgumentParser.java @@ -4,8 +4,6 @@ package net.shadow.client.feature.command.argument; -import net.shadow.client.feature.command.exception.CommandException; - public class StringArgumentParser implements ArgumentParser { @Override public String parse(String argument) { diff --git a/src/main/java/net/shadow/client/feature/config/SettingBase.java b/src/main/java/net/shadow/client/feature/config/SettingBase.java index df27c81..fae5816 100644 --- a/src/main/java/net/shadow/client/feature/config/SettingBase.java +++ b/src/main/java/net/shadow/client/feature/config/SettingBase.java @@ -24,13 +24,12 @@ public abstract class SettingBase { */ final V defaultValue; final List suppliers = new ArrayList<>(); + final Consumer onChanged; /** * The current value of this setting */ V value; - final Consumer onChanged; - /** * Constructs a new Setting * diff --git a/src/main/java/net/shadow/client/feature/gui/screen/AddonManagerScreen.java b/src/main/java/net/shadow/client/feature/gui/screen/AddonManagerScreen.java index bd061ab..8a00ec4 100644 --- a/src/main/java/net/shadow/client/feature/gui/screen/AddonManagerScreen.java +++ b/src/main/java/net/shadow/client/feature/gui/screen/AddonManagerScreen.java @@ -5,18 +5,15 @@ package net.shadow.client.feature.gui.screen; import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; -import net.shadow.client.ShadowMain; import net.shadow.client.feature.addon.Addon; import net.shadow.client.feature.addon.AddonManager; import net.shadow.client.feature.gui.FastTickable; import net.shadow.client.feature.gui.clickgui.ClickGUI; import net.shadow.client.feature.gui.widget.RoundButton; import net.shadow.client.helper.GameTexture; -import net.shadow.client.helper.Texture; import net.shadow.client.helper.Timer; import net.shadow.client.helper.font.FontRenderers; import net.shadow.client.helper.font.adapter.FontAdapter; @@ -24,17 +21,19 @@ import net.shadow.client.helper.render.ClipStack; import net.shadow.client.helper.render.Rectangle; import net.shadow.client.helper.render.Renderer; import net.shadow.client.helper.render.Scroller; -import net.shadow.client.helper.util.Utils; import org.lwjgl.opengl.GL40C; import java.awt.*; -import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; public class AddonManagerScreen extends ClientScreen implements FastTickable { Timer discoverTimer = new Timer(); Scroller scroller = new Scroller(0); + double WIDGET_WIDTH = 600; + double WIDGET_HEIGHT = 300; + List viewerList = new ArrayList<>(); + @Override public void onFastTick() { scroller.tick(); @@ -46,7 +45,7 @@ public class AddonManagerScreen extends ClientScreen implements FastTickable { AddonManager.INSTANCE.discoverNewAddons(); for (Addon loadedAddon : AddonManager.INSTANCE.getLoadedAddons()) { if (viewerList.stream().noneMatch(addonViewer -> addonViewer.addon == loadedAddon)) { - viewerList.add(new AddonViewer(loadedAddon, WIDGET_WIDTH-10)); + viewerList.add(new AddonViewer(loadedAddon, WIDGET_WIDTH - 10)); } } } @@ -54,19 +53,16 @@ public class AddonManagerScreen extends ClientScreen implements FastTickable { @Override public boolean mouseScrolled(double mouseX, double mouseY, double amount) { - if (new Rectangle(width/2d-WIDGET_WIDTH/2d,height/2d-WIDGET_HEIGHT/2d,width/2d+WIDGET_WIDTH/2d,height/2d+WIDGET_HEIGHT/2d).contains(mouseX,mouseY)) { - double contentHeight = viewerList.stream().map(addonViewer -> addonViewer.getHeight()+5).reduce(Double::sum).orElse(0d)+5; - double entitledScroll = Math.max(0, contentHeight-WIDGET_HEIGHT); - scroller.setBounds(0,entitledScroll); + if (new Rectangle(width / 2d - WIDGET_WIDTH / 2d, height / 2d - WIDGET_HEIGHT / 2d, width / 2d + WIDGET_WIDTH / 2d, height / 2d + WIDGET_HEIGHT / 2d).contains(mouseX, mouseY)) { + double contentHeight = viewerList.stream().map(addonViewer -> addonViewer.getHeight() + 5).reduce(Double::sum).orElse(0d) + 5; + double entitledScroll = Math.max(0, contentHeight - WIDGET_HEIGHT); + scroller.setBounds(0, entitledScroll); scroller.scroll(amount); } return super.mouseScrolled(mouseX, mouseY, amount); } - double WIDGET_WIDTH = 600; - double WIDGET_HEIGHT = 300; - List viewerList = new ArrayList<>(); @Override protected void init() { reInitViewers(); @@ -75,21 +71,21 @@ public class AddonManagerScreen extends ClientScreen implements FastTickable { void reInitViewers() { viewerList.clear(); for (Addon loadedAddon : AddonManager.INSTANCE.getLoadedAddons()) { - viewerList.add(new AddonViewer(loadedAddon, WIDGET_WIDTH-10)); + viewerList.add(new AddonViewer(loadedAddon, WIDGET_WIDTH - 10)); } } @Override public void renderInternal(MatrixStack stack, int mouseX, int mouseY, float delta) { renderBackground(stack); - Renderer.R2D.renderRoundedQuad(stack,new Color(20,20,20),width/2d-WIDGET_WIDTH/2d,height/2d-WIDGET_HEIGHT/2d,width/2d+WIDGET_WIDTH/2d,height/2d+WIDGET_HEIGHT/2d,5,20); - ClipStack.globalInstance.addWindow(stack, new Rectangle(width/2d-WIDGET_WIDTH/2d,height/2d-WIDGET_HEIGHT/2d,width/2d+WIDGET_WIDTH/2d,height/2d+WIDGET_HEIGHT/2d)); + Renderer.R2D.renderRoundedQuad(stack, new Color(20, 20, 20), width / 2d - WIDGET_WIDTH / 2d, height / 2d - WIDGET_HEIGHT / 2d, width / 2d + WIDGET_WIDTH / 2d, height / 2d + WIDGET_HEIGHT / 2d, 5, 20); + ClipStack.globalInstance.addWindow(stack, new Rectangle(width / 2d - WIDGET_WIDTH / 2d, height / 2d - WIDGET_HEIGHT / 2d, width / 2d + WIDGET_WIDTH / 2d, height / 2d + WIDGET_HEIGHT / 2d)); double yOffset = 0; - double xRoot = width/2d-WIDGET_WIDTH/2d+5; - double yRoot = height/2d-WIDGET_HEIGHT/2d+5; + double xRoot = width / 2d - WIDGET_WIDTH / 2d + 5; + double yRoot = height / 2d - WIDGET_HEIGHT / 2d + 5; for (AddonViewer addonViewer : viewerList) { - addonViewer.render(stack,xRoot,yRoot+yOffset+scroller.getScroll(),mouseX,mouseY); - yOffset += addonViewer.getHeight()+5; + addonViewer.render(stack, xRoot, yRoot + yOffset + scroller.getScroll(), mouseX, mouseY); + yOffset += addonViewer.getHeight() + 5; } ClipStack.globalInstance.popWindow(); super.renderInternal(stack, mouseX, mouseY, delta); @@ -104,69 +100,74 @@ public class AddonManagerScreen extends ClientScreen implements FastTickable { } class AddonViewer implements FastTickable { - Addon addon; - double width; static final double iconDimensions = 64; static final double padding = 5; + Addon addon; + double width; double lastX, lastY; RoundButton disable, reload; + public AddonViewer(Addon addon, double width) { this.addon = addon; this.width = width; - disable = new RoundButton(RoundButton.STANDARD,0,0,60,20,addon.isEnabled()?"Disable":"Enable", () -> { + disable = new RoundButton(RoundButton.STANDARD, 0, 0, 60, 20, addon.isEnabled() ? "Disable" : "Enable", () -> { if (addon.isEnabled()) AddonManager.INSTANCE.disableAddon(addon); else AddonManager.INSTANCE.enableAddon(addon); - disable.setText(addon.isEnabled()?"Disable":"Enable"); + disable.setText(addon.isEnabled() ? "Disable" : "Enable"); ClickGUI.reInit(); }); - reload = new RoundButton(RoundButton.STANDARD,0,0,60,20,"Reload",() -> { + reload = new RoundButton(RoundButton.STANDARD, 0, 0, 60, 20, "Reload", () -> { AddonManager.INSTANCE.reload(addon); reInitViewers(); ClickGUI.reInit(); }); } + public void render(MatrixStack stack, double x, double y, int mouseX, int mouseY) { lastX = x; lastY = y; - Color background = new Color(30,30,30); - Renderer.R2D.renderRoundedQuad(stack,background,x,y,x+width,y+getHeight(),5,20); + Color background = new Color(30, 30, 30); + Renderer.R2D.renderRoundedQuad(stack, background, x, y, x + width, y + getHeight(), 5, 20); RenderSystem.enableBlend(); RenderSystem.colorMask(false, false, false, true); RenderSystem.clearColor(0.0F, 0.0F, 0.0F, 0.0F); RenderSystem.clear(GL40C.GL_COLOR_BUFFER_BIT, false); RenderSystem.colorMask(true, true, true, true); RenderSystem.setShader(GameRenderer::getPositionColorShader); - Renderer.R2D.renderRoundedQuadInternal(stack.peek().getPositionMatrix(), background.getRed()/255f, background.getGreen()/255f, background.getBlue()/255f, 1, x + padding, y + padding, x + padding + iconDimensions, y + padding + iconDimensions, 6, 10); + Renderer.R2D.renderRoundedQuadInternal(stack.peek().getPositionMatrix(), background.getRed() / 255f, background.getGreen() / 255f, background.getBlue() / 255f, 1, x + padding, y + padding, x + padding + iconDimensions, y + padding + iconDimensions, 6, 10); RenderSystem.blendFunc(GL40C.GL_DST_ALPHA, GL40C.GL_ONE_MINUS_DST_ALPHA); Identifier icon = addon.getIcon(); if (icon == null) icon = GameTexture.ICONS_ADDON_PROVIDED.getWhere(); RenderSystem.setShaderTexture(0, addon.getIcon()); - if (!addon.isEnabled()) RenderSystem.setShaderColor(0.6f,0.6f,0.6f,1f); + if (!addon.isEnabled()) RenderSystem.setShaderColor(0.6f, 0.6f, 0.6f, 1f); Renderer.R2D.renderTexture(stack, x + padding, y + padding, iconDimensions, iconDimensions, 0, 0, iconDimensions, iconDimensions, iconDimensions, iconDimensions); RenderSystem.defaultBlendFunc(); - RenderSystem.setShaderColor(1f,1f,1f,1f); + RenderSystem.setShaderColor(1f, 1f, 1f, 1f); FontAdapter title = FontRenderers.getCustomSize(30); FontAdapter normal = FontRenderers.getRenderer(); - double entireHeight = title.getFontHeight()+normal.getFontHeight()*2d; - if (addon.isEnabled()) title.drawString(stack,addon.name, (float) (x+padding+iconDimensions+padding), (float) (y+getHeight()/2d-entireHeight/2d),0xFFFFFF); - else title.drawString(stack,addon.name, (float) (x+padding+iconDimensions+padding), (float) (y+getHeight()/2d-entireHeight/2d),0.6f,0.6f,0.6f,1f); - normal.drawString(stack,addon.description, (float) (x+padding+iconDimensions+padding), (float) (y+getHeight()/2d-entireHeight/2d+title.getFontHeight()),0.6f,0.6f,0.6f,1f); - normal.drawString(stack,"Developer(s): "+String.join(", ", addon.developers), (float) (x+padding+iconDimensions+padding), (float) (y+getHeight()/2d-entireHeight/2d+title.getFontHeight()+normal.getFontHeight()),0.6f,0.6f,0.6f,1f); + double entireHeight = title.getFontHeight() + normal.getFontHeight() * 2d; + if (addon.isEnabled()) + title.drawString(stack, addon.name, (float) (x + padding + iconDimensions + padding), (float) (y + getHeight() / 2d - entireHeight / 2d), 0xFFFFFF); + else + title.drawString(stack, addon.name, (float) (x + padding + iconDimensions + padding), (float) (y + getHeight() / 2d - entireHeight / 2d), 0.6f, 0.6f, 0.6f, 1f); + normal.drawString(stack, addon.description, (float) (x + padding + iconDimensions + padding), (float) (y + getHeight() / 2d - entireHeight / 2d + title.getFontHeight()), 0.6f, 0.6f, 0.6f, 1f); + normal.drawString(stack, "Developer(s): " + String.join(", ", addon.developers), (float) (x + padding + iconDimensions + padding), (float) (y + getHeight() / 2d - entireHeight / 2d + title.getFontHeight() + normal.getFontHeight()), 0.6f, 0.6f, 0.6f, 1f); - double buttonRowHeight = disable.getHeight()+padding+reload.getHeight(); + double buttonRowHeight = disable.getHeight() + padding + reload.getHeight(); - disable.setX(x+width-disable.getWidth()-padding); - disable.setY(y+getHeight()/2d-buttonRowHeight/2d); - disable.render(stack,mouseX,mouseY,0); - reload.setX(x+width-disable.getWidth()-padding); - reload.setY(y+getHeight()/2d-buttonRowHeight/2d+disable.getHeight()+padding); - reload.render(stack,mouseX,mouseY,0); + disable.setX(x + width - disable.getWidth() - padding); + disable.setY(y + getHeight() / 2d - buttonRowHeight / 2d); + disable.render(stack, mouseX, mouseY, 0); + reload.setX(x + width - disable.getWidth() - padding); + reload.setY(y + getHeight() / 2d - buttonRowHeight / 2d + disable.getHeight() + padding); + reload.render(stack, mouseX, mouseY, 0); } - public void clicked(double mouseX, double mouseY,int button) { - disable.mouseClicked(mouseX,mouseY,button); + + public void clicked(double mouseX, double mouseY, int button) { + disable.mouseClicked(mouseX, mouseY, button); reload.mouseClicked(mouseX, mouseY, button); } @@ -177,7 +178,7 @@ public class AddonManagerScreen extends ClientScreen implements FastTickable { } public double getHeight() { - return iconDimensions +padding*2; + return iconDimensions + padding * 2; } } } diff --git a/src/main/java/net/shadow/client/feature/module/ModuleRegistry.java b/src/main/java/net/shadow/client/feature/module/ModuleRegistry.java index c61fcd8..7e2b5fb 100644 --- a/src/main/java/net/shadow/client/feature/module/ModuleRegistry.java +++ b/src/main/java/net/shadow/client/feature/module/ModuleRegistry.java @@ -20,14 +20,13 @@ import net.shadow.client.feature.module.impl.world.*; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; public class ModuleRegistry { static final List vanillaModules = new ArrayList<>(); static final List customModules = new ArrayList<>(); static final List sharedModuleList = new ArrayList<>(); static final AtomicBoolean reloadInProgress = new AtomicBoolean(false); + static final AtomicBoolean initialized = new AtomicBoolean(false); public static List getCustomModules() { return customModules; @@ -42,7 +41,6 @@ public class ModuleRegistry { customModules.add(new AddonModuleEntry(source, module)); rebuildSharedModuleList(); } - static final AtomicBoolean initialized = new AtomicBoolean(false); public static void clearCustomModules(Addon addon) { for (AddonModuleEntry customModule : customModules) { @@ -188,11 +186,8 @@ public class ModuleRegistry { return sharedModuleList; } - public record AddonModuleEntry(Addon addon, Module module) { - } - private static void awaitLockOpen() { - while(reloadInProgress.get()) { + while (reloadInProgress.get()) { Thread.onSpinWait(); } } @@ -223,4 +218,7 @@ public class ModuleRegistry { } return null; } + + public record AddonModuleEntry(Addon addon, Module module) { + } } diff --git a/src/main/java/net/shadow/client/feature/module/impl/crash/LecternCrash.java b/src/main/java/net/shadow/client/feature/module/impl/crash/LecternCrash.java index f47cefc..f571f63 100644 --- a/src/main/java/net/shadow/client/feature/module/impl/crash/LecternCrash.java +++ b/src/main/java/net/shadow/client/feature/module/impl/crash/LecternCrash.java @@ -4,8 +4,8 @@ package net.shadow.client.feature.module.impl.crash; -import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket; @@ -14,9 +14,6 @@ import net.minecraft.screen.slot.SlotActionType; import net.shadow.client.feature.gui.notifications.Notification; import net.shadow.client.feature.module.Module; import net.shadow.client.feature.module.ModuleType; -import net.minecraft.client.util.math.MatrixStack; -import net.shadow.client.helper.event.EventType; -import net.shadow.client.helper.event.Events; public class LecternCrash extends Module { public LecternCrash() { @@ -27,10 +24,10 @@ public class LecternCrash extends Module { public void tick() { if (client.player.currentScreenHandler instanceof LecternScreenHandler handler) { int sid = handler.syncId; - ClickSlotC2SPacket p = new ClickSlotC2SPacket(sid,0,0,0, SlotActionType.QUICK_MOVE,new ItemStack(Items.AIR),new Int2ObjectOpenHashMap<>()); + ClickSlotC2SPacket p = new ClickSlotC2SPacket(sid, 0, 0, 0, SlotActionType.QUICK_MOVE, new ItemStack(Items.AIR), new Int2ObjectOpenHashMap<>()); client.getNetworkHandler().sendPacket(p); client.player.closeHandledScreen(); - Notification.create(5000,"LecternCrash", Notification.Type.SUCCESS,"Sent exploit packet"); + Notification.create(5000, "LecternCrash", Notification.Type.SUCCESS, "Sent exploit packet"); } } diff --git a/src/main/java/net/shadow/client/feature/module/impl/misc/Test.java b/src/main/java/net/shadow/client/feature/module/impl/misc/Test.java index bbf703a..5cfbccd 100644 --- a/src/main/java/net/shadow/client/feature/module/impl/misc/Test.java +++ b/src/main/java/net/shadow/client/feature/module/impl/misc/Test.java @@ -5,34 +5,28 @@ package net.shadow.client.feature.module.impl.misc; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.network.Packet; import net.minecraft.network.packet.c2s.play.ButtonClickC2SPacket; import net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.screen.slot.SlotActionType; -import net.shadow.client.feature.gui.notifications.Notification; import net.shadow.client.feature.module.Module; import net.shadow.client.feature.module.ModuleType; -import net.shadow.client.helper.Timer; import net.shadow.client.helper.event.EventType; import net.shadow.client.helper.event.Events; import net.shadow.client.helper.event.events.PacketEvent; -import java.lang.reflect.Field; - public class Test extends Module { 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; + if (!this.isEnabled()) return; + PacketEvent event = (PacketEvent) e; System.out.println(event.getPacket()); - if(event.getPacket() instanceof ClickSlotC2SPacket uwu){ + if (event.getPacket() instanceof ClickSlotC2SPacket uwu) { System.out.println(uwu.getSlot() + " <- slot"); System.out.println(uwu.getButton() + " <- button"); } - if(event.getPacket() instanceof ButtonClickC2SPacket uwu){ + if (event.getPacket() instanceof ButtonClickC2SPacket uwu) { System.out.println(uwu.getButtonId() + " <- Button id"); } }); @@ -42,6 +36,7 @@ public class Test extends Module { public void enable() { } + @Override public void disable() { @@ -63,6 +58,6 @@ public class Test extends Module { @Override public void tick() { - client.interactionManager.clickSlot(0,0,0, SlotActionType.QUICK_MOVE,client.player); + client.interactionManager.clickSlot(0, 0, 0, SlotActionType.QUICK_MOVE, client.player); } } diff --git a/src/main/java/net/shadow/client/feature/module/impl/movement/NoLevitation.java b/src/main/java/net/shadow/client/feature/module/impl/movement/NoLevitation.java index c51ca09..6d5b19b 100644 --- a/src/main/java/net/shadow/client/feature/module/impl/movement/NoLevitation.java +++ b/src/main/java/net/shadow/client/feature/module/impl/movement/NoLevitation.java @@ -5,8 +5,6 @@ package net.shadow.client.feature.module.impl.movement; import net.fabricmc.loader.api.FabricLoader; -import net.fabricmc.loader.impl.FabricLoaderImpl; -import net.fabricmc.loader.impl.launch.FabricLauncher; import net.minecraft.client.util.math.MatrixStack; import net.shadow.client.feature.gui.notifications.Notification; import net.shadow.client.feature.module.Module; @@ -26,7 +24,7 @@ public class NoLevitation extends Module { @Override public void enable() { if (FabricLoader.getInstance().isModLoaded("meteor-client")) { - Notification.create(4000,"NoLevitation", Notification.Type.ERROR, "Meteor is currently loaded and prevents this from working. Use meteor's NoLevitation"); + Notification.create(4000, "NoLevitation", Notification.Type.ERROR, "Meteor is currently loaded and prevents this from working. Use meteor's NoLevitation"); setEnabled(false); } } diff --git a/src/main/java/net/shadow/client/feature/module/impl/render/Hud.java b/src/main/java/net/shadow/client/feature/module/impl/render/Hud.java index 4aa2b71..2ad63cb 100644 --- a/src/main/java/net/shadow/client/feature/module/impl/render/Hud.java +++ b/src/main/java/net/shadow/client/feature/module/impl/render/Hud.java @@ -5,7 +5,6 @@ package net.shadow.client.feature.module.impl.render; import com.mojang.blaze3d.systems.RenderSystem; -import lombok.val; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket; @@ -47,10 +46,10 @@ public class Hud extends Module { final BooleanSetting coords = this.config.create(new BooleanSetting.Builder(true).name("Coordinates").description("Whether to show current coordinates").get()); final BooleanSetting ping = this.config.create(new BooleanSetting.Builder(true).name("Ping").description("Whether to show current ping").get()); final BooleanSetting modules = this.config.create(new BooleanSetting.Builder(true).name("Array list").description("Whether to show currently enabled modules").get()); - Map entryList = new ConcurrentHashMap<>(); -// final List moduleList = new ArrayList<>(); + // final List moduleList = new ArrayList<>(); final Timer tpsUpdateTimer = new Timer(); final List last5SecondTpsAverage = new ArrayList<>(); + Map entryList = new ConcurrentHashMap<>(); long lastTimePacketReceived; double rNoConnectionPosY = -10d; Notification serverNotResponding = null; diff --git a/src/main/java/net/shadow/client/mixin/GameMenuMixin.java b/src/main/java/net/shadow/client/mixin/GameMenuMixin.java index 7fca0c6..ce10710 100644 --- a/src/main/java/net/shadow/client/mixin/GameMenuMixin.java +++ b/src/main/java/net/shadow/client/mixin/GameMenuMixin.java @@ -20,9 +20,9 @@ public class GameMenuMixin extends Screen { super(title); } - @Inject(method="initWidgets",at=@At("RETURN")) + @Inject(method = "initWidgets", at = @At("RETURN")) void addAddons(CallbackInfo ci) { - addDrawableChild(new RoundButton(RoundButton.STANDARD,5,5,60,20,"Addons",() -> { + addDrawableChild(new RoundButton(RoundButton.STANDARD, 5, 5, 60, 20, "Addons", () -> { assert client != null; client.setScreen(new AddonManagerScreen()); })); diff --git a/src/main/java/net/shadow/client/mixin/LivingEntityMixin.java b/src/main/java/net/shadow/client/mixin/LivingEntityMixin.java index 385c735..ef028f0 100644 --- a/src/main/java/net/shadow/client/mixin/LivingEntityMixin.java +++ b/src/main/java/net/shadow/client/mixin/LivingEntityMixin.java @@ -52,7 +52,7 @@ public class LivingEntityMixin { } } - @Redirect(method = "travel", at = @At(value = "INVOKE", target = "net/minecraft/entity/LivingEntity.hasStatusEffect(Lnet/minecraft/entity/effect/StatusEffect;)Z"),require = 0) + @Redirect(method = "travel", at = @At(value = "INVOKE", target = "net/minecraft/entity/LivingEntity.hasStatusEffect(Lnet/minecraft/entity/effect/StatusEffect;)Z"), require = 0) boolean atomic_stopLevitationEffect(LivingEntity instance, StatusEffect effect) { if (instance.equals(ShadowMain.client.player) && ModuleRegistry.getByClass(NoLevitation.class).isEnabled() && effect == StatusEffects.LEVITATION) { return false;