new initial client

This commit is contained in:
Daniella / Tove 2024-03-20 01:13:18 +01:00
parent 9870a0e6ab
commit 9c73c8de30
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
86 changed files with 1903 additions and 321 deletions

View file

@ -79,7 +79,7 @@ dependencies {
jarLibs(files('libs/TuddyLIB.jar'))
// should NOT go into the jar.
implementation(files('libs/mcregistry-1.0.jar'))
//implementation(files('libs/mcregistry-1.0.jar'))
//jarLibs 'club.minnced:java-discord-rpc:2.0.2'
@ -112,13 +112,13 @@ compileJava {
def targetFile = file("src/main/java/com/baseband/client/BaseBand.java")
/*def targetFile = file("src/main/java/com/baseband/client/BaseBand.java")
def content = targetFile.text
def updatedContent = content.replaceFirst("buildNumber = (\\d+)", { _, value -> "buildNumber = ${value.toInteger() + 1}" })
updatedContent = updatedContent.replaceFirst("public static String hash = \".*\";", "public static String hash = \"" + hash + "\";")
updatedContent = updatedContent.replaceFirst("public long timeOfCompile = .*;", "public long timeOfCompile = " + new Date().getTime() + "L;")
targetFile.text = updatedContent
targetFile.text = updatedContent*/
}
processResources {

View file

@ -1,222 +1,43 @@
/*
* Copyright (c) 2023 Jess H & Daniella H. All Rights Reserved.
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package com.baseband.client;
import com.baseband.client.command.CommandManager;
import com.baseband.client.event.EventBus;
import com.baseband.client.event.FMLEventProcessor;
import com.baseband.client.configuration.Updater;
import com.baseband.client.module.Module;
import com.baseband.client.module.modules.*;
import de.tudbut.parsing.TCN;
import de.tudbut.tools.Lock;
import de.tudbut.tools.Registry;
import de.tudbut.tools.Tools;
import net.minecraft.client.Minecraft;
import net.minecraft.launchwrapper.Launch;
import net.minecraftforge.common.MinecraftForge;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.opengl.Display;
import javax.swing.*;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.function.Consumer;
public class BaseBand {
public static int majorVersion = 1;
public static int buildNumber = 497;
public static String hash = "06b9a1db4ba97794";
public static String name = "BaseBand";
public long timeOfCompile = 1710629129384L;
public CommandManager commandRegistry;
public EventBus eventBus;
public ArrayList<Module> modules = new ArrayList<>();
public static BaseBand INSTANCE;
public static Registry Registry;
private static TCN registryData;
{ INSTANCE = this; }
public static BaseBand INSTANCE; { INSTANCE = this; }
private static ArrayList<Updater> updaters = new ArrayList<>();
public static final Logger log = LogManager.getLogger("BaseBand");
public static Minecraft mc;
public String getWatermark() {
switch (level) {
case 1: {
return "BaseBand+ v"+majorVersion+"."+buildNumber;
public static void registerUpdater(Updater updater) {
updaters.add(updater);
updater.populate();
}
case 2: {
return "BaseBand b"+BaseBand.majorVersion + "." + BaseBand.buildNumber + "+" + BaseBand.hash;
}
}
return "BaseBand v"+majorVersion;
}
public int level = 0; //Standard user
public void onInit() {
Utils.check();
mc = Minecraft.getMinecraft();
try {
Object keeper = BaseBand.class.getClassLoader().getClass().getFields()[1].get(BaseBand.class.getClassLoader());
for (Method access : keeper.getClass().getMethods()) {
if(Arrays.equals(access.getParameterTypes(), new Class<?>[]{Consumer.class}) && access.getDeclaringClass() == keeper.getClass()) {
access.invoke(keeper, (Consumer<Object>) accessor -> {
try {
Object registry = Arrays.stream(accessor.getClass().getMethods()).filter(x -> x.getParameterCount() == 0 && x.getDeclaringClass() == accessor.getClass()).findAny().get().invoke(accessor);
for (Method save : registry.getClass().getMethods()) {
if (save.getParameterCount() == 0 && save.getReturnType() == Void.TYPE && save.getDeclaringClass() == registry.getClass()) {
save.invoke(registry); // registry save
break;
}
}
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
Utils.crash();
}
});
}
}
} catch (Exception e) {
e.printStackTrace();
Utils.crash();
}
try {
Registry = new Registry("BaseBand.registry");
registryData = Registry.register("*");
} catch (Exception e) {
// tamper detected
Utils.crash();
}
// cant be a normal if statement because it might be null
if (registryData.getBoolean("LoaderPresent") == Boolean.TRUE) {
String key = registryData.getString("Key");
TCN data = TCN.readMap(Tools.stringToMap(new Key(key).decryptString(registryData.getString("Data"))));
registryData.set("Key", null);
registryData.set("Data", null);
this.level = data.getInteger("level");
} else {
// do other stuff here later?
log.info("No loader present, but able to start anyway ==> Debug environment detected.");
}
// unset so this won't be discovered and manipulated
registryData.set("LoaderPresent", null);
Registry.save();
commandRegistry = new CommandManager();
eventBus = new EventBus();
addModule(new Brightness());
addModule(new PacketTest());
addModule(new HUD());
addModule(new PacketFly());
addModule(new Speed());
addModule(new TPTracker());
addModule(new NoSlip());
addModule(new FastUse());
addModule(new ElytraFly());
addModule(new ChatCrypt());
addModule(new NameTags());
addModule(new ChatSuffix());
MinecraftForge.EVENT_BUS.register(new FMLEventProcessor());
try {
for (Module m : modules) {
if(m.isEnabled()) {
m.setEnabled(m.isEnabled());
MinecraftForge.EVENT_BUS.register(m);
eventBus.register(m);
}
}
} catch(Exception e) {
ConfigManager.save();
}
new Thread(() -> {
Lock lock = new Lock();
while(true) {
lock.lock(10000);
ConfigManager.save();
lock.waitHere();
}
}, "Config save thread").start();
Display.setTitle(getWatermark());
log.info("BaseBand Instantiated.");
}
private static void downloadMCRegistry() {
try {
Class.forName("de.tudbut.mcregistry.MCRegistry");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Minecraft might need to restart to download BaseBand's required libraries.");
try {
InputStream uis = new URL("https://github.com/TudbuT/mcregistry/releases/download/v1.0/mcregistry-1.0.jar").openStream();
Files.copy(uis, Paths.get("mods/mcregistry-1.0.jar"), StandardCopyOption.REPLACE_EXISTING);
Launch.classLoader.addURL(new URL("file://./mods/mcregistry-1.0.jar"));
uis.close();
try {
Class.forName("de.tudbut.mcregistry.MCRegistry");
} catch (ClassNotFoundException ex) {
System.out.println("----------- THIS IS NOT A BUG. CRASHING ON PURPOSE TO END GAME QUICKLY.");
throw new Error("THIS IS NOT A BUG!!!");
}
JOptionPane.showMessageDialog(null, "Libraries installed.");
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, "Unable to download BaseBand's required libraries. Please install mcregistry manually.");
throw new RuntimeException(ex);
}
Setup clientSetup = Setup.get();
Module[] modules = clientSetup.MODULES;
for (int i = 0; i < modules.length; i++) {
modules[i].register(this, mc);
}
}
public void addModule(Module m) {
Restrict annotation = m.getClass().getDeclaredAnnotation(Restrict.class);
if (annotation != null) {
if(level < annotation.value().level)
return;
}
modules.add(m);
}
public static <T extends Module> T getModule(Class<? extends T> module) {
for (int i = 0; i < INSTANCE.modules.size(); i++) {
if(INSTANCE.modules.get(i).getClass() == module) {
return (T) INSTANCE.modules.get(i);
}
}
throw new RuntimeException();
}
public static Module getModule(String name) {
for (Module m : INSTANCE.modules) {
if (m.toString().equalsIgnoreCase(name)) {
return m;
@Nonnull
public static <T extends Module> T getModule(Class<? extends T> clazz) {
Module[] modules = Setup.get().MODULES;
for (int i = 0; i < modules.length; i++) {
if(modules[i].getClass() == clazz) {
return (T) modules[i];
}
}
return null;
}
public static boolean isIngame() {
return Minecraft.getMinecraft().world != null && Minecraft.getMinecraft().player != null;
}
}

View file

@ -0,0 +1,34 @@
package com.baseband.client;
import com.baseband.client.module.Module;
import com.baseband.client.module.command.Test;
import de.tudbut.parsing.TCN;
/**
* @author TudbuT
*
* Client setup: Included modules, etc.
*/
public class Setup {
public final String REGISTRY_FILENAME = "baseband.db";
public final Module[] MODULES = new Module[] {
new Test(),
};
/// SINGLETON LOGIC ///
private static Setup INSTANCE;
public static Setup get() {
if(INSTANCE == null)
INSTANCE = new Setup();
return INSTANCE;
}
private Setup() {}
}

View file

@ -0,0 +1,39 @@
package com.baseband.client.configuration;
import de.tudbut.parsing.TCN;
import java.lang.reflect.Field;
import java.util.ArrayList;
public class ConfigHandle {
final String name;
TCN tcn;
ArrayList<Updater> onUpdate = new ArrayList<>();
public ConfigHandle(String name, TCN tcn) {
this.name = name;
this.tcn = tcn;
}
public String getName() {
return name;
}
public TCN getContent() {
return tcn;
}
public void updated() {
for (Updater updater : onUpdate) {
updater.onUpdateConfig();
}
}
public Updater linkWith(Object o, Field f) {
Updater updater = new Updater(this, o, f);
onUpdate.add(updater);
return updater;
}
}

View file

@ -0,0 +1,35 @@
package com.baseband.client.configuration;
import com.baseband.client.Setup;
import de.tudbut.parsing.TCN;
import de.tudbut.tools.Registry;
import java.io.IOException;
import java.util.HashMap;
public class Configuration {
private final Registry registry = new Registry(Setup.get().REGISTRY_FILENAME);
private Configuration() throws IOException {
}
private static Configuration INSTANCE;
static {
try {
INSTANCE = new Configuration();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static ConfigHandle register(String handle) throws IllegalAccessException {
return new ConfigHandle(handle, INSTANCE.registry.register(handle));
}
static void unregister(ConfigHandle handle) throws IllegalAccessException {
INSTANCE.registry.unregister(handle.name, handle.tcn);
handle.tcn = null;
}
}

View file

@ -0,0 +1,73 @@
package com.baseband.client.configuration;
import java.lang.reflect.Field;
public class Updater {
final ConfigHandle handle;
String id = "*";
Object o;
Field field;
Updater(ConfigHandle handle, Object o, Field field) {
this.handle = handle;
this.o = o;
this.field = field;
}
void onUpdateConfig() {
try {
if (field.getType() == String.class) {
field.set(o, handle.getContent().getString(id));
} else if (field.getType() == int.class) {
field.setInt(o, handle.getContent().getInteger(id));
} else if (field.getType() == long.class) {
field.setLong(o, handle.getContent().getLong(id));
} else if (field.getType() == float.class) {
field.setFloat(o, handle.getContent().getFloat(id));
} else if (field.getType() == double.class) {
field.setDouble(o, handle.getContent().getDouble(id));
} else if (field.getType() == boolean.class) {
field.setBoolean(o, handle.getContent().getBoolean(id));
} else {
throw new IllegalStateException("Unhandled type of field: " + field.getType());
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
void onUpdateField() {
try {
if(field.getType() == String.class ||
field.getType() == int.class ||
field.getType() == long.class ||
field.getType() == float.class ||
field.getType() == double.class ||
field.getType() == boolean.class) {
handle.getContent().set(id, field.get(o));
handle.updated();
} else {
throw new IllegalStateException("Unhandled type of field: " + field.getType());
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
public boolean isInvalid() {
return handle.getContent() == null;
}
public void poll() {
onUpdateField();
}
public void populate() {
onUpdateConfig();
}
public Updater name(String id) {
this.id = id;
return this;
}
}

View file

@ -0,0 +1,21 @@
package com.baseband.client.configuration.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author TudbuT
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Config {
/**
* Name
* @return the name
* @author TudbuT
*/
String value();
}

View file

@ -0,0 +1,20 @@
package com.baseband.client.configuration.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author TudbuT
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Range {
/**
* n..m
* @return the range
*/
String value();
}

View file

@ -0,0 +1,161 @@
package com.baseband.client.gui;
import com.baseband.client.BaseBand;
import com.baseband.client.Setup;
import com.baseband.client.gui.lib.GUIManager;
import com.baseband.client.gui.lib.component.Category;
import com.baseband.client.gui.lib.component.Component;
import com.baseband.client.module.Module;
import com.baseband.client.module.render.ClickGUI;
import de.tudbut.obj.TLMap;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import org.lwjgl.input.Mouse;
import org.lwjgl.util.Point;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
public class GuiRewrite extends GuiScreen {
// The mouse X and Y
private int cx;
private int cy;
private Category[] categories = new Category[0];
public GuiRewrite() {
this.mc = BaseBand.INSTANCE.mc;
ClickGUI clickGUI = BaseBand.getModule(ClickGUI.class);
if(!clickGUI.enabled)
clickGUI.toggle();
createComponents();
}
// Minecraft wants this
@Override
public boolean doesGuiPauseGame() {
return mc.player.timeInPortal != 0;
}
// The initiator, this can, for some reason, not be in the constructor
public void initGui() {
// Minecraft wants this
super.buttonList.clear();
super.buttonList.add(new GuiButton(0, -500, -500, ""));
super.initGui();
}
private void createComponents() {
ArrayList<Category> categories = new ArrayList<>();
int y = 10;
TLMap<com.baseband.client.module.Category, Category> map = new TLMap<>();
for (int i = 0 ; i < Setup.get().MODULES.length ; i++) {
Module module = Setup.get().MODULES[i];
if(!module.displayOnClickGUI()) {
continue;
}
Category category;
if((category = map.get(module.category)) == null) {
map.set(module.category, category = new Category() {{
text = module.category.name;
}});
if((module.category.x | module.category.y) != 0) {
category.location = new Point(module.category.x, module.category.y);
category.subComponentsShown = module.category.show;
}
if(category.location == null) {
category.location = new Point(10, y);
y += 20;
}
categories.add(category);
category.subComponents.clear();
}
category.subComponents.add(module);
}
this.categories = categories.toArray(new Category[0]);
}
// When ESC is pressed
@Override
public void onGuiClosed() {
super.onGuiClosed();
BaseBand.getModule(ClickGUI.class).enabled = false;
for (Category category : categories) {
com.baseband.client.module.Category.fromName(category.text).show = category.subComponentsShown;
}
}
@Override
public void updateScreen() {
for (Component value : GUIManager.renderedComponents.values()) {
value.update();
}
GUIManager.update();
}
// Called when the user presses a mouse button
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
// Update cx and cy
cx = mouseX;
cy = mouseY;
GUIManager.click(mouseX, mouseY, mouseButton);
}
// Update cx and cy
@Override
protected void mouseClickMove(int mouseX, int mouseY, int mouseButton, long timeSinceLastClick) {
cx = mouseX;
cy = mouseY;
GUIManager.move(mouseX, mouseY, mouseButton);
}
// Called when the user releases a mouse button
protected void mouseReleased(int mouseX, int mouseY, int state) {
super.mouseReleased(mouseX, mouseY, state);
// Update cx and cy
cx = mouseX;
cy = mouseY;
}
// Render the screen
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
// Update cx and cy
cx = mouseX;
cy = mouseY;
GUIManager.renderedComponents = new HashMap<>();
for (int i = 0 ; i < categories.length ; i++) {
if(categories[i].location.getY() < -10000) {
categories[i].location.setY(categories[i].location.getY() + 10000);
}
if(categories[i].location.getY() > 10000) {
categories[i].location.setY(categories[i].location.getY() - 10000);
}
categories[i].render();
}
// TMP fix for a strange bug that causes the mouse to be hidden
if (BaseBand.getModule(ClickGUI.class).mouseFix) {
drawRect(mouseX - 2, mouseY - 2, mouseX + 2, mouseY + 2, 0xffffffff);
}
int m = Mouse.getDWheel();
if(m != 0) {
for (int i = 0 ; i < categories.length ; i++) {
categories[i].location.setY(categories[i].location.getY() + m);
}
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
}

View file

@ -0,0 +1,429 @@
package com.baseband.client.gui;
import com.baseband.client.module.Module;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import org.lwjgl.input.Mouse;
import java.awt.*;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;
public class GuiTTC extends GuiScreen {
// The buttons to be rendered (sub buttons are in the button object)
// One button per module
private Button[] buttons;
// Theme
public interface ITheme {
int getGreenColor();
int getRedColor();
int getFrameColor();
int getBackgroundColor();
}
public enum Theme implements ITheme {
TTC(0xff80ff00, 0xff008800),
ETERNAL_BLUE(0xff4040ff, 0xffff0000, 0xffffffff, 0xff000030),
DARK(0xff008000, 0xff800000, 0xff808080, 0xff000000),
LIGHT(0xffcccccc, 0xff999999),
BLOOD(0xffaa0000, 0xff880000, 0xff00ffff, 0xaaaaaaaa),
SKY(0xff00cccc, 0xff009999, 0x000000),
KAMI_BLUE(0xbb353642, 0xbb353642, 0xffbbbbbb, 0xaaaaaaaa),
SCHLONGHAX(0xbb553662, 0xbb553662, 0xffbbbbbb, 0xaaaaaaaa),
ORANGE(0xffcc8000, 0xff996000, 0xff404040),
XV11(0xff3f718e, 0xff2d2d2d, 0xff67915f, 0xff000000),
TTC_OLD(0xff00ff00, 0xffff0000),
SOBERSHULKER(0xffff88ff, 0xffaa40aa, 0xffff88ff, 0xff000000),
VIRUS(0xffc0ddff, 0xffffffff, 0x00000000, 0xaa202040),
;
@Override
public int getGreenColor() {
return greenColor;
}
@Override
public int getRedColor() {
return redColor;
}
@Override
public int getFrameColor() {
return frameColor;
}
@Override
public int getBackgroundColor() {
return backgroundColor;
}
public final int greenColor;
public final int redColor;
public final int frameColor;
public final int backgroundColor;
Theme(int greenColor, int redColor) {
this.greenColor = greenColor;
this.redColor = redColor;
this.frameColor = 0xffffffff;
this.backgroundColor = 0xA0000000;
}
Theme(int greenColor, int redColor, int frameColor) {
this.greenColor = greenColor;
this.redColor = redColor;
this.frameColor = frameColor;
this.backgroundColor = 0xA0000000;
}
Theme(int greenColor, int redColor, int frameColor, int backgroundColor) {
this.greenColor = greenColor;
this.redColor = redColor;
this.frameColor = frameColor;
this.backgroundColor = backgroundColor;
}
}
/*
// The mouse X and Y
private int cx;
private int cy;
private int lastScrollPos = Mouse.getEventDWheel();
public GuiTTC() {
this.mc = TTCp.mc;
}
// Minecraft wants this
@Override
public boolean doesGuiPauseGame() {
return mc.player.timeInPortal != 0;
}
// The initiator, this can, for some reason, not be in the constructor
public void initGui() {
// Creates buttons
buttons = new Button[256];
resetButtons();
// Minecraft wants this
super.buttonList.clear();
super.buttonList.add(new GuiButton(0, -500, -500, ""));
super.initGui();
lastScrollPos = Mouse.getEventDWheel();
}
// When ESC is pressed
@Override
public void onGuiClosed() {
super.onGuiClosed();
ClickGUI.getInstance().enabled = false;
}
// Called every tick, idk why its called update tho
@Override
public void updateScreen() {
// Minecraft is stupid and sometimes forgets to call initScreen, so this is needed
while (buttons == null) {
try {
Thread.sleep(100);
}
catch (InterruptedException e) {
e.printStackTrace();
}
if (buttons == null)
resetButtons();
}
// Call onTick on every button
for (int i = 0; i < buttons.length; i++) {
if (buttons[i] != null)
buttons[i].onTick(this);
}
}
// Reset the buttons array
public void resetButtons() {
Button[] buttons = new Button[TTCp.modules.length];
for (int i = 0, j = 0; i < TTCp.modules.length; i++) {
int x = j / 15;
int y = j - x * 15;
// Don't add the button if it isn't requested
if (!TTCp.modules[i].displayOnClickGUI())
continue;
// Create the button
int r = i;
Button b = new Button(
10 + (155 * x), 10 + (y * 25), TTCp.modules[r].toString() + ": " + TTCp.modules[r].enabled,
(text) -> {
if (TTCp.modules[r].enabled = !TTCp.modules[r].enabled)
TTCp.modules[r].onEnable();
else
TTCp.modules[r].onDisable();
}, TTCp.modules[i]
);
buttons[i] = b;
j++;
}
this.buttons = buttons;
}
// Reset text on the buttons
private void updateButtons() {
while (buttons == null) {
try {
Thread.sleep(100);
}
catch (InterruptedException e) {
e.printStackTrace();
}
if (buttons == null)
resetButtons();
}
for (int i = 0; i < TTCp.modules.length; i++) {
if (buttons[i] != null)
buttons[i].text.set(TTCp.modules[i].toString() + ": " + TTCp.modules[i].enabled);
}
}
// Called when the user presses a mouse button
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
// Update cx and cy
cx = mouseX;
cy = mouseY;
// Notify buttons
for (int i = 0 ; i < buttons.length ; i++) {
Button button = buttons[i];
if (button != null)
if (button.mouseClicked(mouseX, mouseY, mouseButton))
return;
}
}
// Update cx and cy
@Override
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
cx = mouseX;
cy = mouseY;
}
// Called when the user releases a mouse button
protected void mouseReleased(int mouseX, int mouseY, int state) {
super.mouseReleased(mouseX, mouseY, state);
// Update cx and cy
cx = mouseX;
cy = mouseY;
// Notify buttons
for (int i = 0 ; i < buttons.length ; i++) {
Button button = buttons[i];
if (button != null)
button.mouseReleased();
}
}
// Render the screen
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
updateButtons();
this.drawDefaultBackground();
cx = mouseX;
cy = mouseY;
// Ask the buttons to render themselves
for (int i = 0; i < buttons.length; i++) {
if (buttons[i] != null)
buttons[i].draw(this);
}
// TMP fix for a strange bug that causes the mouse to be hidden
if (ClickGUI.getInstance().mouseFix) {
drawRect(mouseX - 2, mouseY - 2, mouseX + 2, mouseY + 2, 0xffffffff);
}
int m = -Mouse.getDWheel();
if(m != 0) {
for (int i = 0; i < buttons.length; i++) {
if(buttons[i] != null) {
int d = (lastScrollPos - m) / 3;
switch (ClickGUI.getInstance().sd) {
case Vertical:
buttons[i].y += d;
break;
case Horizontal:
buttons[i].x += d;
break;
}
}
}
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
public static class Button {
public int x, y;
public AtomicReference<String> text;
// Color for rendering
public int color = 0x8000ff00;
// The associated module, can be null if it is a sub button
public Module module;
// Called when the button is clicked
ButtonClickEvent event;
// If any mouse button is pressed
private boolean mouseDown = false;
// The mouse button that is pressed
private int mouseDownButton = 0;
// The sub buttons of the button, null if no module is associated to provide them
private Button[] subButtons;
private boolean display = true;
// Constructor used for sub buttons
public Button(String text, ButtonClickEvent event) {
this(0, 0, text, event, null);
}
// Constructor used by GuiTTC to construct a button with an associated module
// and main constructor
public Button(int x, int y, String text, ButtonClickEvent event, Module module) {
if (module != null) {
if (module.clickGuiX != null && module.clickGuiY != null) {
x = module.clickGuiX;
y = module.clickGuiY;
}
subButtons = module.subButtons.toArray(new Button[0]);
display = module.displayOnClickGUI();
}
this.x = x;
this.y = y;
this.text = new AtomicReference<>(text);
this.event = event;
this.module = module;
if(ClickGUI.getInstance() != null)
this.color = ClickGUI.getInstance().getTheme().getGreenColor();
}
// Render the button
public void draw(GuiTTC gui) {
if (!display)
return;
int color = this.color;
if (gui.cx >= x && gui.cy >= y && gui.cx <= x + 150 && gui.cy <= y + ySize()) {
Color c = new Color(color, true);
int r, g, b, a;
r = c.getRed();
g = c.getGreen();
b = c.getBlue();
a = c.getAlpha();
r += 0x20;
g += 0x20;
b += 0x20;
a += 0x20;
color = new Color(Math.min(r, 0xff),Math.min(g, 0xff),Math.min(b, 0xff),Math.min(a, 0xff)).getRGB();
}
drawRect(x, y, x + 150, y + ySize(), color);
//gui.fontRenderer.drawString(text.get(), x + 6, y + ySize() / 2f - 8 / 2f, ClickGUI.getInstance().getTheme().getFrameColor(), ClickGUI.getInstance().getTheme().hasShadow());
// Draw sub buttons
if (module != null && (module.enabled ^ module.clickGuiShow)) {
//subButtons = module.getSubButtons();
for (int i = 0; i < subButtons.length; i++) {
Button b = subButtons[i];
if(b != null) {
b.x = x;
b.y = y + ( ( i + 1 ) * 15 + ( 20 - 15 ) );
b.color = ClickGUI.getInstance().getTheme().getRedColor();
b.draw(gui);
}
}
}
}
public int ySize() {
return module == null ? 15 : 20;
}
public boolean mouseClicked(int clickX, int clickY, int button) {
if (clickX >= x && clickY >= y) {
if (clickX < x + 150 && clickY < y + ySize()) {
mouseDown = true;
if(ClickGUI.getInstance().flipButtons) {
button = (button == 0 ? 1 : (button == 1 ? 0 : button));
}
mouseDownButton = button;
click(button);
return true;
}
}
if (module != null && (module.enabled ^ module.clickGuiShow)) {
//subButtons = module.getSubButtons();
for (int i = 0; i < subButtons.length; i++) {
Button b = subButtons[i];
if(b != null) {
b.x = x;
b.y = y + ( ( i + 1 ) * 15 + ( 20 - 15 ) );
b.color = ClickGUI.getInstance().getTheme().getRedColor();
if (b.mouseClicked(clickX, clickY, button))
return true;
}
}
}
return false;
}
public void mouseReleased() {
mouseDown = false;
if (module != null && (module.enabled ^ module.clickGuiShow)) {
subButtons = module.subButtons.toArray(new Button[0]);
for (int i = 0; i < subButtons.length; i++) {
subButtons[i].mouseReleased();
}
}
}
// More simple onCLick, only called when the mouse is clicked while on the button
protected void click(int button) {
if (button == 0)
event.run(text);
if (button == 2 && module != null)
module.clickGuiShow = !module.clickGuiShow;
}
protected void onTick(GuiTTC gui) {
this.color = ClickGUI.getInstance().getTheme().getGreenColor();
if (module != null) {
if (mouseDown && mouseDownButton == 1) {
x = gui.cx - 150 / 2;
y = gui.cy - 10;
x = (x / 5) * 5;
y = (y / 5) * 5;
}
module.clickGuiX = x;
module.clickGuiY = y;
}
}
}
public interface ButtonClickEvent {
void run(AtomicReference<String> text);
}*/
}

View file

@ -0,0 +1,61 @@
package com.baseband.client.gui.lib;
import com.baseband.client.BaseBand;
import com.baseband.client.gui.GuiTTC;
import com.baseband.client.gui.lib.component.Component;
import com.baseband.client.module.render.ClickGUI;
import org.lwjgl.util.Rectangle;
import java.util.HashMap;
import java.util.Map;
@SuppressWarnings("ALL")
public class GUIManager {
public static int fontColorOn = 0xff00ff00;
public static int fontColorOff = 0xffff0000;
public static int frameColor = 0xffffffff;
public static int frameBackground = 0xA0000000;
public static int sliderBackground = 0xff808080;
public static int sliderColor = 0xffffffff;
public static HashMap<Rectangle, Component> renderedComponents = new HashMap<>();
static Component dragging = null;
public static synchronized void click(int mouseX, int mouseY, int mouseButton) {
dragging = null;
Map.Entry<Rectangle, Component>[] entries = renderedComponents.entrySet().toArray(new Map.Entry[0]);
for (int i = 0, entriesSize = entries.length ; i < entriesSize ; i++) {
Map.Entry<Rectangle, Component> entry = entries[i];
if(mouseX >= entry.getKey().getX() && mouseY >= entry.getKey().getY() && mouseX <= entry.getKey().getWidth() && mouseY <= entry.getKey().getHeight()) {
entry.getValue().click(mouseX - entry.getValue().loc.getX(), mouseY - entry.getValue().loc.getY(), mouseButton);
return;
}
}
}
public static synchronized void move(int mouseX, int mouseY, int mouseButton) {
if(dragging == null) {
Map.Entry<Rectangle, Component>[] entries = renderedComponents.entrySet().toArray(new Map.Entry[0]);
for (int i = 0, entriesSize = entries.length; i < entriesSize ; i++) {
Map.Entry<Rectangle, Component> entry = entries[i];
if (mouseX >= entry.getKey().getX() && mouseY >= entry.getKey().getY() && mouseX <= entry.getKey().getWidth() && mouseY <= entry.getKey().getHeight()) {
dragging = entry.getValue();
break;
}
}
}
if(dragging != null) {
dragging.move(mouseX - dragging.loc.getX(), mouseY - dragging.loc.getY(), mouseButton);
}
}
public static void update() {
GuiTTC.ITheme theme = BaseBand.getModule(ClickGUI.class).getTheme();
fontColorOn = theme.getGreenColor();
fontColorOff = theme.getRedColor();
frameColor = theme.getFrameColor();
frameBackground = theme.getBackgroundColor();
}
}

View file

@ -0,0 +1,26 @@
package com.baseband.client.gui.lib.component;
public class Button extends Component {
private final ClickEvent event;
{green = true;}
public Button(String s, ClickEvent event) {
this.text = s;
this.event = event;
}
@Override
public void click(int x, int y, int mouseButton) {
super.click(x, y, mouseButton);
if(mouseButton == 0) {
green = true;
event.click(this);
}
}
public interface ClickEvent {
void click(Button it);
}
}

View file

@ -0,0 +1,59 @@
package com.baseband.client.gui.lib.component;
import com.baseband.client.gui.lib.GUIManager;
import de.tudbut.obj.Transient;
import net.minecraft.client.gui.Gui;
import org.lwjgl.util.Point;
import org.lwjgl.util.Rectangle;
import java.util.concurrent.atomic.AtomicInteger;
public class Category extends Component {
{green = true;}
public Point location;
public void render() {
render(location.getX(), new AtomicInteger(location.getY()), -1, false, 0);
}
@Override
public void render(int x, AtomicInteger y, int sub, boolean isLastInList, int yLineSize) {
loc = new Point(x + 8 + sub * 8, y.get());
GUIManager.renderedComponents.put(new Rectangle(x + sub * 8, y.get(), x + (200 - sub * 8), y.get() + size()), this);
int width = fontRenderer.getStringWidth(text);
Gui.drawRect(x + 2, y.get() + 4, x + 200, y.get() + subSizes() + size(), GUIManager.frameBackground);
Gui.drawRect(x + 200, y.get() + 4, x + 200 - 1, y.get() + subSizes() + size(), GUIManager.frameColor);
Gui.drawRect(x + width, y.get() + 4, x + 200, y.get() + 4 + 1, GUIManager.frameColor);
fontRenderer.drawString(text, x, y.get(), green ? GUIManager.fontColorOn : GUIManager.fontColorOff);
y.addAndGet(size());
if(subComponentsShown) {
for (int i = 0 ; i < subComponents.size() ; i++) {
Component component = subComponents.get(i);
component.render(x, y, 0, false, component.size());
}
}
Gui.drawRect(x + 2, y.get(), x + 200, y.get() - 1, GUIManager.frameColor);
}
@Transient
int clickX = 0, clickY = 0;
@Override
public void click(int x, int y, int mouseButton) {
if(mouseButton == 0) {
subComponentsShown = !subComponentsShown;
}
clickX = x;
clickY = y;
}
public void move(int x, int y, int mouseButton) {
if(mouseButton == 1) {
location.setX(location.getX() + x - clickX);
location.setY(location.getY() + y - clickY);
loc = location;
}
}
}

View file

@ -0,0 +1,109 @@
package com.baseband.client.gui.lib.component;
import com.baseband.client.gui.lib.GUIManager;
import de.tudbut.obj.Save;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import org.lwjgl.util.Point;
import org.lwjgl.util.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
public abstract class Component {
public Point loc;
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
public ArrayList<Component> subComponents = new ArrayList<>();
public String text = "";
public boolean green = false;
@Save
public boolean subComponentsShown = false;
public boolean displayConfirmation = false;
private final Button[] confirmationButtons = new Button[3];
private static boolean makingCBs = false;
{
if(!makingCBs) {
makingCBs = true;
confirmationButtons[0] = new Button("Are you sure?", it -> { });
confirmationButtons[1] = new Button("Yes", it -> {
displayConfirmation = false;
onConfirm(true);
});
confirmationButtons[2] = new Button("No", it -> {
displayConfirmation = false;
onConfirm(false);
});
makingCBs = false;
}
}
public void render(int x, AtomicInteger y, int sub, boolean isLastInList, int yLineSize) {
loc = new Point(x + 8 + sub * 8, y.get());
GUIManager.renderedComponents.put(new Rectangle(x + sub * 8, y.get(), x + (200 - sub * 8), y.get() + size()), this);
if(isLastInList) {
Gui.drawRect(x + 2 + sub * 8, y.get(), x + 2 + sub * 8 + 1, y.get() + 4, GUIManager.frameColor);
}
else {
Gui.drawRect(x + 2 + sub * 8, y.get(), x + 2 + sub * 8 + 1, y.get() + yLineSize, GUIManager.frameColor);
}
Gui.drawRect(x + 2 + sub * 8, y.get(), x + 2 + sub * 8 + 1, y.get() + subSizes() + (isLastInList ? 5 : size()), GUIManager.frameColor);
Gui.drawRect(x + 2 + sub * 8, y.get() + 4, x + 5 + sub * 8 + 1, y.get() + 4 + 1, GUIManager.frameColor);
fontRenderer.drawString(text, x + 8 + sub * 8, y.get(), green ? GUIManager.fontColorOn : GUIManager.fontColorOff);
draw(x + 8 + sub * 8, y.get());
y.addAndGet(size());
if(subComponentsShown) {
List<Component> subComponents = this.subComponents;
if(displayConfirmation) {
subComponents = Arrays.asList(confirmationButtons);
}
for (int i = 0 ; i < subComponents.size() ; i++) {
Component component = subComponents.get(i);
component.render(
x, y, sub + 1,
i == subComponents.size() - 1,
i == subComponents.size() - 1 && isLastInList && component.subComponents.size() == 0 ? 4 : component.size()
);
}
}
}
public void draw(int x, int y) {
}
protected int subSizes() {
int size = 0;
if(subComponentsShown) {
if(displayConfirmation)
return 30;
for (int i = 0 ; i < subComponents.size() ; i++) {
size += subComponents.get(i).size() + subComponents.get(i).subSizes();
}
}
return size;
}
protected int size() {
return 10;
}
public void update() { }
public void click(int x, int y, int mouseButton) {
if(mouseButton == 0) {
green = !green;
}
if(mouseButton == 1 || mouseButton == 2) {
subComponentsShown = !subComponentsShown;
}
}
public void move(int x, int y, int mouseButton) { }
public void onConfirm(boolean result) { }
}

View file

@ -0,0 +1,40 @@
package com.baseband.client.gui.lib.component;
import com.baseband.client.configuration.ConfigHandle;
public class EnumButton extends Component {
ConfigHandle handle;
String field;
Class<? extends Enum<?>> enumType;
Enum<?>[] enums;
{green = true;}
public EnumButton(Class<? extends Enum<?>> enumType, String s, ConfigHandle handle, String field) {
this.enumType = enumType;
enums = enumType.getEnumConstants();
this.text = s;
this.handle = handle;
this.field = field;
for (int i = 0 ; i < enums.length ; i++) {
Button button;
int finalI = i;
subComponents.add(button = new Button(enums[i].toString(), it -> {
handle.getContent().set(field, finalI);
handle.updated();
for (Component component : subComponents) {
component.green = false;
}
it.green = true;
}));
button.green = handle.getContent().getInteger(field) == enums[i].ordinal();
}
}
@Override
public void click(int x, int y, int mouseButton) {
super.click(x, y, mouseButton);
green = true;
}
}

View file

@ -0,0 +1,72 @@
package com.baseband.client.gui.lib.component;
import com.baseband.client.configuration.ConfigHandle;
import com.baseband.client.gui.lib.GUIManager;
import net.minecraft.client.gui.Gui;
import java.util.function.Function;
public class IntSlider extends Component {
public float f = 0;
ConfigHandle handle;
String field;
Function<Integer, String> sliderText;
Function<Integer, Boolean> updateMethod;
int mapper;
int adder;
{green = true;}
public IntSlider(String s, ConfigHandle handle, String field, Function<Integer, String> text, int mapper, int adder, Function<Integer, Boolean> updateMethod) {
this.text = s;
this.handle = handle;
this.field = field;
this.sliderText = text;
this.mapper = mapper;
this.adder = adder;
this.updateMethod = updateMethod;
update();
}
public IntSlider(String s, ConfigHandle handle, String field, Function<Integer, String> text, int mapper, int adder) {
this(s, handle, field, text, mapper, adder, t -> true);
}
@Override
public void draw(int x, int y) {
Gui.drawRect(x, y + 13, x + 101, y + 14, GUIManager.sliderBackground);
Gui.drawRect((int) Math.floor(x + f * 100), y + 11, (int) Math.floor(x + f * 100) + 1, y + 16, GUIManager.sliderColor);
fontRenderer.drawString(sliderText.apply(Math.round(f * mapper + adder)), x + 100 + 4, y + 10, GUIManager.sliderColor);
}
@Override
public synchronized void update() {
f = (handle.getContent().getInteger(field) - adder) / (float) mapper;
}
@Override
public synchronized void click(int x, int y, int mouseButton) {
if(mouseButton == 0)
f = Math.max(Math.min(x, 100), 0) / 100f;
handle.getContent().set(field, Math.round(f * mapper + adder));
handle.updated();
if(!updateMethod.apply(Math.round(f * mapper + adder))) {
System.out.println("Something went wrong handling the sliders!");
throw new RuntimeException();
}
update();
}
@Override
public void move(int x, int y, int mouseButton) {
click(x, y, mouseButton);
}
@Override
protected int size() {
return 20;
}
}

View file

@ -0,0 +1,71 @@
package com.baseband.client.gui.lib.component;
import com.baseband.client.configuration.ConfigHandle;
import com.baseband.client.gui.lib.GUIManager;
import net.minecraft.client.gui.Gui;
import java.util.function.Function;
public class Slider extends Component {
public float f = 0;
ConfigHandle handle;
String field;
Function<Float, String> sliderText;
Function<Float, Boolean> updateMethod;
float mapper;
float adder;
{green = true;}
public Slider(String s, ConfigHandle handle, String field, Function<Float, String> text, float mapper, float adder, Function<Float, Boolean> updateMethod) {
this.text = s;
this.handle = handle;
this.field = field;
this.sliderText = text;
this.mapper = mapper;
this.adder = adder;
this.updateMethod = updateMethod;
update();
}
public Slider(String s, ConfigHandle handle, String field, Function<Float, String> text, float mapper, float adder) {
this(s, handle, field, text, mapper, adder, t -> true);
}
@Override
public void draw(int x, int y) {
Gui.drawRect(x, y + 13, x + 101, y + 14, GUIManager.sliderBackground);
Gui.drawRect((int) Math.floor(x + f * 100), y + 11, (int) Math.floor(x + f * 100) + 1, y + 16, GUIManager.sliderColor);
fontRenderer.drawString(sliderText.apply(f * mapper + adder), x + 100 + 4, y + 10, GUIManager.sliderColor);
}
@Override
public synchronized void update() {
f = (handle.getContent().getFloat(field) - adder) / mapper;
}
@Override
public synchronized void click(int x, int y, int mouseButton) {
if(mouseButton == 0)
f = Math.max(Math.min(x, 100), 0) / 100f;
handle.getContent().set(field, f * mapper + adder);
handle.updated();
if(!updateMethod.apply(f * mapper + adder)) {
System.out.println("Something went wrong handling the sliders!");
throw new RuntimeException();
}
update();
}
@Override
public void move(int x, int y, int mouseButton) {
click(x, y, mouseButton);
}
@Override
protected int size() {
return 20;
}
}

View file

@ -0,0 +1,42 @@
package com.baseband.client.gui.lib.component;
import com.baseband.client.configuration.ConfigHandle;
public class ToggleButton extends Component {
protected ConfigHandle handle;
protected String field;
private Runnable lambda;
public ToggleButton(String s, ConfigHandle handle, String field) {
this.text = s;
this.handle = handle;
this.field = field;
update();
}
public ToggleButton(String s, ConfigHandle handle, String field, Runnable lambda) {
this.lambda = lambda;
this.text = s;
this.handle = handle;
this.field = field;
update();
}
@Override
public synchronized void update() {
green = handle.getContent().getBoolean(field);
}
@Override
public synchronized void click(int x, int y, int mouseButton) {
super.click(x, y, mouseButton);
handle.getContent().set(field, green);
handle.updated();
if(lambda != null)
lambda.run();
}
public interface ClickEvent {
void click(Button it);
}
}

View file

@ -0,0 +1,53 @@
package com.baseband.client.module;
import com.baseband.client.BaseBand;
import com.baseband.client.configuration.ConfigHandle;
import com.baseband.client.configuration.Configuration;
import com.baseband.client.util.FieldUtil;
import com.baseband.client.util.Marker;
import javax.annotation.Nonnull;
public enum Category {
COMMAND("Commands"),
RENDER("Render")
;
Category(String name) {
this.name = name;
try {
handle = Configuration.register("Category/" + name.toLowerCase().replace(' ', '_'));
BaseBand.registerUpdater(handle.linkWith(this, FieldUtil.findMarked(getClass(), 1)).name("x"));
BaseBand.registerUpdater(handle.linkWith(this, FieldUtil.findMarked(getClass(), 2)).name("y"));
BaseBand.registerUpdater(handle.linkWith(this, FieldUtil.findMarked(getClass(), 3)).name("show"));
} catch (IllegalAccessException e) {
//:skollerolley:
throw new RuntimeException(e);
}
}
private ConfigHandle handle;
@Marker(1)
public int x;
@Marker(2)
public int y;
@Marker(3)
public boolean show;
public final String name;
public String toString() {
return name;
}
@Nonnull
public static Category fromName(String s) {
for (Category c : values()) {
if(c.name.equals(s))
return c;
}
return null;
}
}

View file

@ -1,81 +1,150 @@
/*
* Copyright (c) 2023 Jess H & Daniella H. All Rights Reserved.
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package com.baseband.client.module;
import com.baseband.client.BaseBand;
import com.baseband.client.configuration.ConfigHandle;
import com.baseband.client.configuration.Configuration;
import com.baseband.client.configuration.annotation.Config;
import com.baseband.client.configuration.annotation.Range;
import com.baseband.client.gui.lib.component.IntSlider;
import com.baseband.client.gui.lib.component.Slider;
import com.baseband.client.gui.lib.component.ToggleButton;
import com.baseband.client.util.FieldUtil;
import com.baseband.client.util.Marker;
import net.minecraft.client.Minecraft;
import net.minecraftforge.common.MinecraftForge;
import de.tudbut.obj.Save;
import de.tudbut.parsing.TCN;
import de.tudbut.tools.ConfigSaverTCN2;
public abstract class Module {
@Save
boolean isEnabled = defaultEnabled();
protected boolean defaultEnabled() { return false; }
import java.lang.reflect.Field;
import java.util.HashMap;
@Save
int key = defaultKey();
protected int defaultKey() { return 0; }
/**
* @author TudbuT
*/
public abstract class Module extends ToggleButton {
public void setEnabled(boolean enabled) {
isEnabled = enabled;
protected BaseBand bb;
protected Minecraft mc;
if(isEnabled) {
enable();
BaseBand.INSTANCE.eventBus.register(this);
MinecraftForge.EVENT_BUS.register(this);
} else {
disable();
BaseBand.INSTANCE.eventBus.unregister(this);
MinecraftForge.EVENT_BUS.unregister(this);
}
public Category category;
@Marker(1)
public boolean enabled = defaultEnable();
public Module() {
super("Uninit", null, "Enabled");
this.text = toString();
}
TCN data;
{
try {
data = BaseBand.Registry.register(this.toString());
if(data.getSub("@Save") != null)
ConfigSaverTCN2.read(data.getSub("@Save"), this);
} catch (IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
// module methods
protected boolean defaultEnable() {
return false;
}
public void updateData() {
data.set("@Save", ConfigSaverTCN2.write(this, false, true));
public void onDisable() {
}
protected static Minecraft mc = Minecraft.getMinecraft();
public void onEnable() {
public void setKey(int key) {
this.key = key;
}
public int getKey() {
return key;
}
public boolean isEnabled() {
return isEnabled;
}
public void enable(){}
public void disable(){}
public String getHudMeta() {
return "";
}
public abstract String toString();
public void toggle() {
setEnabled(!isEnabled);
protected void setup() {}
public boolean displayOnClickGUI() {
return true;
}
// own methods
public final void register(BaseBand bbInst, Minecraft mc) {
this.bb = bbInst;
this.mc = mc;
subComponents.clear();
ConfigHandle settings = config("Settings");
Field[] fields = getClass().getDeclaredFields();
for (Field f : fields) {
Config config = f.getDeclaredAnnotation(Config.class);
if (config != null) {
BaseBand.registerUpdater(settings.linkWith(this, f).name(config.value()));
if (f.getType() == boolean.class) {
subComponents.add(new ToggleButton(config.value(), settings, config.value()));
}
if (f.getType() == int.class) {
Range range = f.getDeclaredAnnotation(Range.class);
if (range != null) {
String[] r = range.value().split("\\.\\.");
int min = Integer.parseInt(r[0]);
int max = Integer.parseInt(r[1]);
subComponents.add(new IntSlider(config.value(), settings, config.value(), Object::toString, max - min, min));
} else {
throw new RuntimeException("No range specified for slider");
}
}
if (f.getType() == float.class) {
Range range = f.getDeclaredAnnotation(Range.class);
if (range != null) {
String[] r = range.value().split("\\.\\.");
float min = Float.parseFloat(r[0]);
float max = Float.parseFloat(r[1]);
subComponents.add(new Slider(config.value(), settings, config.value(), Object::toString, max - min, min));
} else {
throw new RuntimeException("No range specified for slider");
}
}
}
}
handle = settings;
BaseBand.registerUpdater(settings.linkWith(this, FieldUtil.findMarked(getClass(), 1)).name("Enabled"));
setup();
}
protected void check() {
if (bb == null || mc == null) {
throw new RuntimeException();
}
if (mc.world == null || mc.player == null) {
throw new NullPointerException();
}
}
public String getIDCategory() {
return category.toString().toLowerCase();
}
public String getIDName() {
return toString().toLowerCase().replace(' ', '_');
}
public String getID() {
return getIDCategory() + "." + getIDName();
}
private final HashMap<String, ConfigHandle> ownedHandles = new HashMap<>();
protected ConfigHandle config(String handle) {
if(ownedHandles.containsKey(handle)) {
return ownedHandles.get(handle);
}
try {
ConfigHandle h = Configuration.register(getID() + "/" + handle);
ownedHandles.put(handle, h);
return h;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
public void toggle() {
enabled = !enabled;
if(enabled)
onEnable();
else
onDisable();
}
}

View file

@ -0,0 +1,28 @@
package com.baseband.client.module.command;
import com.baseband.client.configuration.annotation.Config;
import com.baseband.client.configuration.annotation.Range;
import com.baseband.client.module.Module;
/**
* @author TudbuT
*
* Self-Test command, checks if everything is working
*/
public class Test extends Module {
@Config("Int Setting")
@Range("0..10")
private int intSetting = 5;
@Override
public String toString() {
return "Test";
}
@Override
protected void setup() {
}
}

View file

@ -0,0 +1,19 @@
package com.baseband.client.module.render;
import com.baseband.client.configuration.annotation.Config;
import com.baseband.client.gui.GuiTTC;
import com.baseband.client.module.Module;
public class ClickGUI extends Module {
@Config("Mouse Fix")
public boolean mouseFix;
@Override
public String toString() {
return "ClickGUI";
}
public GuiTTC.ITheme getTheme() {
return GuiTTC.Theme.TTC;
}
}

View file

@ -0,0 +1,18 @@
package com.baseband.client.util;
import javax.annotation.Nonnull;
import java.lang.reflect.Field;
public class FieldUtil {
@Nonnull
public static Field findMarked(Class<?> clazz, int id) {
Field[] fields = clazz.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
Marker marker = fields[i].getDeclaredAnnotation(Marker.class);
if(marker != null && marker.value() == id)
return fields[i];
}
return null;
}
}

View file

@ -0,0 +1,12 @@
package com.baseband.client.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Marker {
int value();
}

View file

@ -3,7 +3,7 @@
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package com.baseband.client;
package com.baseband.client.old;
//JessSystemV
//7:28 AM, 2023-10-05

View file

@ -0,0 +1,222 @@
/*
* Copyright (c) 2023 Jess H & Daniella H. All Rights Reserved.
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package com.baseband.client.old;
import com.baseband.client.old.command.CommandManager;
import com.baseband.client.old.event.EventBus;
import com.baseband.client.old.event.FMLEventProcessor;
import com.baseband.client.old.module.Module;
import com.baseband.client.old.module.modules.*;
import de.tudbut.parsing.TCN;
import de.tudbut.tools.Lock;
import de.tudbut.tools.Registry;
import de.tudbut.tools.Tools;
import net.minecraft.client.Minecraft;
import net.minecraft.launchwrapper.Launch;
import net.minecraftforge.common.MinecraftForge;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.opengl.Display;
import javax.swing.*;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.function.Consumer;
public class BaseBand {
public static int majorVersion = 1;
public static int buildNumber = 489;
public static String hash = "9eaa8192283c5bd8";
public static String name = "BaseBand";
public long timeOfCompile = 1710874072334L;
public CommandManager commandRegistry;
public EventBus eventBus;
public ArrayList<Module> modules = new ArrayList<>();
public static BaseBand INSTANCE;
public static Registry Registry;
private static TCN registryData;
{ INSTANCE = this; }
public static final Logger log = LogManager.getLogger("BaseBand");
public String getWatermark() {
switch (level) {
case 1: {
return "BaseBand+ v"+majorVersion+"."+buildNumber;
}
case 2: {
return "BaseBand b"+BaseBand.majorVersion + "." + BaseBand.buildNumber + "+" + BaseBand.hash;
}
}
return "BaseBand v"+majorVersion;
}
public int level = 0; //Standard user
public void onInit() {
Utils.check();
try {
Object keeper = BaseBand.class.getClassLoader().getClass().getFields()[1].get(BaseBand.class.getClassLoader());
for (Method access : keeper.getClass().getMethods()) {
if(Arrays.equals(access.getParameterTypes(), new Class<?>[]{Consumer.class}) && access.getDeclaringClass() == keeper.getClass()) {
access.invoke(keeper, (Consumer<Object>) accessor -> {
try {
Object registry = Arrays.stream(accessor.getClass().getMethods()).filter(x -> x.getParameterCount() == 0 && x.getDeclaringClass() == accessor.getClass()).findAny().get().invoke(accessor);
for (Method save : registry.getClass().getMethods()) {
if (save.getParameterCount() == 0 && save.getReturnType() == Void.TYPE && save.getDeclaringClass() == registry.getClass()) {
save.invoke(registry); // registry save
break;
}
}
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
Utils.crash();
}
});
}
}
} catch (Exception e) {
e.printStackTrace();
Utils.crash();
}
try {
Registry = new Registry("BaseBand.registry");
registryData = Registry.register("*");
} catch (Exception e) {
// tamper detected
Utils.crash();
}
// cant be a normal if statement because it might be null
if (registryData.getBoolean("LoaderPresent") == Boolean.TRUE) {
String key = registryData.getString("Key");
TCN data = TCN.readMap(Tools.stringToMap(new Key(key).decryptString(registryData.getString("Data"))));
registryData.set("Key", null);
registryData.set("Data", null);
this.level = data.getInteger("level");
} else {
// do other stuff here later?
log.info("No loader present, but able to start anyway ==> Debug environment detected.");
}
// unset so this won't be discovered and manipulated
registryData.set("LoaderPresent", null);
Registry.save();
commandRegistry = new CommandManager();
eventBus = new EventBus();
addModule(new Brightness());
addModule(new PacketTest());
addModule(new HUD());
addModule(new PacketFly());
addModule(new Speed());
addModule(new TPTracker());
addModule(new NoSlip());
addModule(new FastUse());
addModule(new ElytraFly());
addModule(new ChatCrypt());
addModule(new NameTags());
addModule(new ChatSuffix());
MinecraftForge.EVENT_BUS.register(new FMLEventProcessor());
try {
for (Module m : modules) {
if(m.isEnabled()) {
m.setEnabled(m.isEnabled());
MinecraftForge.EVENT_BUS.register(m);
eventBus.register(m);
}
}
} catch(Exception e) {
ConfigManager.save();
}
new Thread(() -> {
Lock lock = new Lock();
while(true) {
lock.lock(10000);
ConfigManager.save();
lock.waitHere();
}
}, "Config save thread").start();
Display.setTitle(getWatermark());
log.info("BaseBand Instantiated.");
}
private static void downloadMCRegistry() {
try {
Class.forName("de.tudbut.mcregistry.MCRegistry");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Minecraft might need to restart to download BaseBand's required libraries.");
try {
InputStream uis = new URL("https://github.com/TudbuT/mcregistry/releases/download/v1.0/mcregistry-1.0.jar").openStream();
Files.copy(uis, Paths.get("mods/mcregistry-1.0.jar"), StandardCopyOption.REPLACE_EXISTING);
Launch.classLoader.addURL(new URL("file://./mods/mcregistry-1.0.jar"));
uis.close();
try {
Class.forName("de.tudbut.mcregistry.MCRegistry");
} catch (ClassNotFoundException ex) {
System.out.println("----------- THIS IS NOT A BUG. CRASHING ON PURPOSE TO END GAME QUICKLY.");
throw new Error("THIS IS NOT A BUG!!!");
}
JOptionPane.showMessageDialog(null, "Libraries installed.");
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, "Unable to download BaseBand's required libraries. Please install mcregistry manually.");
throw new RuntimeException(ex);
}
}
}
public void addModule(Module m) {
Restrict annotation = m.getClass().getDeclaredAnnotation(Restrict.class);
if (annotation != null) {
if(level < annotation.value().level)
return;
}
modules.add(m);
}
public static <T extends Module> T getModule(Class<? extends T> module) {
for (int i = 0; i < INSTANCE.modules.size(); i++) {
if(INSTANCE.modules.get(i).getClass() == module) {
return (T) INSTANCE.modules.get(i);
}
}
throw new RuntimeException();
}
public static Module getModule(String name) {
for (Module m : INSTANCE.modules) {
if (m.toString().equalsIgnoreCase(name)) {
return m;
}
}
return null;
}
public static boolean isIngame() {
return Minecraft.getMinecraft().world != null && Minecraft.getMinecraft().player != null;
}
}

View file

@ -3,7 +3,7 @@
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package com.baseband.client;
package com.baseband.client.old;
import com.baseband.client.module.Module;
import de.tudbut.io.StreamReader;

View file

@ -3,7 +3,7 @@
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package com.baseband.client;
package com.baseband.client.old;
import de.tudbut.tools.Tools;

View file

@ -3,7 +3,7 @@
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package com.baseband.client;
package com.baseband.client.old;
import net.minecraft.client.Minecraft;
import net.minecraft.init.MobEffects;

View file

@ -3,7 +3,7 @@
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package com.baseband.client;
package com.baseband.client.old;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

View file

@ -3,7 +3,7 @@
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package com.baseband.client;
package com.baseband.client.old;
import de.tudbut.net.ic.PBIC;
import de.tudbut.type.Vector3d;

View file

@ -3,7 +3,7 @@
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package com.baseband.client;
package com.baseband.client.old;
import com.mojang.realmsclient.gui.ChatFormatting;
import net.minecraft.client.Minecraft;

View file

@ -0,0 +1,81 @@
/*
* Copyright (c) 2023 Jess H & Daniella H. All Rights Reserved.
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package com.baseband.client.module;
import com.baseband.client.BaseBand;
import net.minecraft.client.Minecraft;
import net.minecraftforge.common.MinecraftForge;
import de.tudbut.obj.Save;
import de.tudbut.parsing.TCN;
import de.tudbut.tools.ConfigSaverTCN2;
public abstract class Module {
@Save
boolean isEnabled = defaultEnabled();
protected boolean defaultEnabled() { return false; }
@Save
int key = defaultKey();
protected int defaultKey() { return 0; }
public void setEnabled(boolean enabled) {
isEnabled = enabled;
if(isEnabled) {
enable();
BaseBand.INSTANCE.eventBus.register(this);
MinecraftForge.EVENT_BUS.register(this);
} else {
disable();
BaseBand.INSTANCE.eventBus.unregister(this);
MinecraftForge.EVENT_BUS.unregister(this);
}
}
TCN data;
{
try {
data = BaseBand.Registry.register(this.toString());
if(data.getSub("@Save") != null)
ConfigSaverTCN2.read(data.getSub("@Save"), this);
} catch (IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
public void updateData() {
data.set("@Save", ConfigSaverTCN2.write(this, false, true));
}
protected static Minecraft mc = Minecraft.getMinecraft();
public void setKey(int key) {
this.key = key;
}
public int getKey() {
return key;
}
public boolean isEnabled() {
return isEnabled;
}
public void enable(){}
public void disable(){}
public String getHudMeta() {
return "";
}
public abstract String toString();
public void toggle() {
setEnabled(!isEnabled);
}
}

View file

@ -17,17 +17,8 @@ configurations {
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
implementation("net.dv8tion:JDA:5.0.0-beta.13")
embed("net.dv8tion:JDA:5.0.0-beta.13")
implementation 'org.json:json:20211205'
implementation group: 'org.mindrot', name: 'jbcrypt', version: '0.4'
embed group: 'org.mindrot', name: 'jbcrypt', version: '0.4'
embed group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.3'
implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.3'
embed 'org.json:json:20211205'
implementation(fileTree(dir: "libs", include: "*.jar"))
embed(fileTree(dir: "libs", include: "*.jar"))
}
jar {

View file

@ -1,29 +0,0 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDjDW0NxNZjue31
iSkZv0E/HVpRlqt1p/QOj8a+g/aEYMC6Gst+WQlx9ZEO5gwp8CLhQ1epcPV1RS2w
FbFVneJqqCTHVSABpMcsdN3M8sfd4DvJnj4j3vvZFpVWbcxPvdrqn9VxiGp0cxeh
soQBb6hmqDo5jfHkK+lSzGOEJyLV237fbuRwL8uJ+h8BVr3/PzybIMpBlv36CVJ2
76Pug9Uow/fl02sQrnA34fRpbOiE14FcVTqvz3zIp35h9Q3aoc76mMdBjfcWNLbc
JmaFKb30ZJjjm/FtB+Lvtw6q115lRdOFi8AF7Zb/MBTH3ybuFixoWaTEpjTAV//V
J0fFRNuHAgMBAAECggEAb6dWjYLSetAf+LKuh37JsyPYGm8hegZRuidx8JYsUATU
QbCTiVp3jpbX8p+mM6lnPadEIIrv6e9O/FxujE/L2+87xtpRlv1VBMOjnvl01+NB
A3DR1gn9h0/XuFzeMAiI8wAOknom/4TphhanW51xDqqDl3H6Fd6SKqlf9sjYFJmi
swj2KkKJq2y8jgNgQYRUzBGH4iLBKFNdKF3SZqxnrCE6/CUPLzpg+1l4OL3JYI5A
YOC7MqrpRxzYl9vCgaD55kCSIhlcmqSD1tfoQICQ8ZZdXpx1Q6NTBhGI0CPUmBrV
K6cbtJbtyGRu3rbUFpbuhozZa6a/7iuM3nGF267tQQKBgQD0MA3SKbWYw5RjdKpc
ym3GVRsqzLGBdFTDj1Qhsj3zCPQwiUNEaT2JTIDK0Ev1a2Lt/Ib5LFBGYBTfVDaj
qkMKKc0ez/JpcLTeMniwQpM17cgx8kcyc9uH8oYuyKipWDA0fv7i3WAFSK8GzrTx
DfYt26Z62w5BpB4fiIvqpAmsmQKBgQDuCSySZIeTWec10wVLyKf6o6PrXc7OQFbg
uVJHxJ9/fqYRKSctIjOsMCZifLUHkya5EI2w+vLutg087mFlB9THnikZ4tpRBbuX
wSEnFb+68RsPXesx7fPXPpu883ZRsg6/en1tUVRTeUpgyDhT06VOvAQHHcvW2zCK
2BsXYIy9HwKBgQDqHNxTX1vU/8ZX6DWhyw6eNWBbk26nz9GowNUHjW1pgm8jzaYp
g8DUzv039aatwGxUAWWipcK9Bkdcqs/L8GRf7R3U6cffIYi286rUSq/652Olx0RN
cdjLKVFOr2FNItjsq8lR1q7Fwh7Upv/BkQIyi0G8ziKH+oJK9042A1mnGQKBgCF+
vPzklIdRkU1rokUluS11tW07SAyR1SfOLBvZOTBxm+CyT8b0Fx1VsTEOp1KnjD1i
bO3IgkLA71/xk1bqITDtuo7f8ySPj/QswwOC9fXSU6J37s6Z00QolTWjdLTOP3EG
RXwKg7kzShoQUozJLWvE3TQ7JyHWuh/vhPBnL6a1AoGBAM5sgfn4q2G8pSf0dmgM
RTBFyYRzdgpUqD+yJkdsQIUM5TuVVwx/A3/042wQz4tqJC/ymkkogjf3w3TfwpSA
nZbl+JnfipeO0XMBsuvk+UQJHhO08SJy++1gmH+zj77NQXNFE6OwgP3LhIhmZsLH
HJanHAL/o+seW4ulFMvnmU76
-----END PRIVATE KEY-----

View file

@ -5,16 +5,22 @@
package dev.baseband.server;
import dev.baseband.server.socket.Bot;
import dev.baseband.server.socket.SocketHandler;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import de.tudbut.net.ws.Server;
import java.net.ServerSocket;
import java.net.Socket;
public class Main {
public static void main(String[] args) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
Bot.start();
SocketHandler.launch(args);
public static final RSAKey rsaKey = new RSAKey();
public static void main(String[] args) throws Exception {
Server server = new Server(40000);
server.addHandler(new ConnectionHandler());
server.run();
while(true);
}
}

View file

@ -3,7 +3,7 @@
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package dev.baseband.server.socket;
package dev.baseband.server.old;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;

View file

@ -3,7 +3,7 @@
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package dev.baseband.server.socket;
package dev.baseband.server.old;
import org.json.JSONException;
import org.json.JSONObject;

View file

@ -3,11 +3,10 @@
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package dev.baseband.server.socket;
package dev.baseband.server.old;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
public class Key {
//Daniella made the actual encryption,

View file

@ -3,7 +3,7 @@
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package dev.baseband.server.socket;
package dev.baseband.server.old;
import java.io.*;
import java.net.ServerSocket;

View file

@ -3,7 +3,7 @@
* Unauthorized copying of this file via any medium is Strictly Prohibited.
*/
package dev.baseband.server.socket;
package dev.baseband.server.old;
import org.mindrot.jbcrypt.BCrypt;