From 3a5a361f01a4419296458efaaaa06542cf6d9bd0 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Thu, 3 Oct 2024 23:57:25 +0200 Subject: [PATCH] add BookFill --- .../java/de/com/baseband/client/Setup.java | 1 + .../feature/modules/ingame/BookFill.java | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 Client/src/main/java/de/com/baseband/client/feature/modules/ingame/BookFill.java diff --git a/Client/src/main/java/de/com/baseband/client/Setup.java b/Client/src/main/java/de/com/baseband/client/Setup.java index 9326f9f..766e890 100644 --- a/Client/src/main/java/de/com/baseband/client/Setup.java +++ b/Client/src/main/java/de/com/baseband/client/Setup.java @@ -39,6 +39,7 @@ public class Setup { new AutoSignText(), new Baritone(), new Bind(), + new BookFill(), new Bright(), new ChatAppend(), new ChatCrypt(), diff --git a/Client/src/main/java/de/com/baseband/client/feature/modules/ingame/BookFill.java b/Client/src/main/java/de/com/baseband/client/feature/modules/ingame/BookFill.java new file mode 100644 index 0000000..9e8a40e --- /dev/null +++ b/Client/src/main/java/de/com/baseband/client/feature/modules/ingame/BookFill.java @@ -0,0 +1,38 @@ +package de.com.baseband.client.feature.modules.ingame; + +import de.com.baseband.client.BaseBand; +import de.com.baseband.client.feature.Feature; +import de.com.baseband.client.feature.category.Ingame; +import de.com.baseband.client.registry.annotation.Description; +import de.com.baseband.client.util.adapt.FieldFinder; +import net.minecraft.client.gui.GuiScreenBook; + +import java.lang.reflect.InvocationTargetException; + +@Ingame +@Description("Automatically fills books you open with random characters.") +public class BookFill extends Feature { + @Override + public String toString() { + return "BookFill"; + } + + @Override + public void onTick() { + if(mc.currentScreen instanceof GuiScreenBook) { + try { + FieldFinder.findUnmarkedMethod(GuiScreenBook.class, 1, String.class).invoke(mc.currentScreen, randomString()); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + } + } + + private String randomString() { + StringBuilder builder = new StringBuilder(255); + for (int i = 0; i < 256; i++) { + builder.append((char) (BaseBand.RANDOM.nextInt(Character.MAX_VALUE - 256) + 256)); + } + return builder.toString(); + } +}