From d65d013a5c3758544b47c8ebcff482b780a8c6de Mon Sep 17 00:00:00 2001 From: froslanz Date: Fri, 30 Oct 2026 11:56:03 -0400 Subject: [PATCH] add ExpThrower module --- .../modules/player/ExpThrowerModule.java | 84 +++++++++++++++++++ .../java/cc/fros/manager/ModuleManager.java | 2 + 2 files changed, 86 insertions(+) create mode 100644 src/main/java/cc/fros/features/modules/player/ExpThrowerModule.java diff --git a/src/main/java/cc/fros/features/modules/player/ExpThrowerModule.java b/src/main/java/cc/fros/features/modules/player/ExpThrowerModule.java new file mode 100644 index 0000000..6b63e85 --- /dev/null +++ b/src/main/java/cc/fros/features/modules/player/ExpThrowerModule.java @@ -0,0 +1,84 @@ +package cc.fros.features.modules.player; + +import cc.fros.Fros; +import cc.fros.event.impl.entity.player.TickEvent; +import cc.fros.event.system.Subscribe; +import cc.fros.features.modules.Module; +import cc.fros.features.settings.Setting; +import cc.fros.util.inventory.InventoryUtil; +import cc.fros.util.inventory.Result; +import cc.fros.util.inventory.ResultType; +import cc.fros.util.models.Angles; +import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.item.Items; + +/** + * ExpThrower -- automatically throws experience bottles at your feet. + * Ported from meteor-client's {@code EXPThrower}. + */ +public class ExpThrowerModule extends Module { + private final Setting delay = num("Delay", 0, 0, 20); + private final Setting rotate = bool("Rotate", true); + private final Setting autoSwitch = mode("AutoSwitch", AutoSwitch.Normal); + + private int timer; + + public ExpThrowerModule() { + super("ExpThrower", "Automatically throws experience bottles.", Category.PLAYER); + } + + @Override + public void onEnable() { + timer = 0; + } + + @Override + public void onDisable() { + timer = 0; + } + + @Subscribe + public void onPreTick(TickEvent.Pre event) { + if (nullCheck() || !mc.player.isAlive()) return; + if (timer++ < delay.getValue()) return; + + Result bottle = InventoryUtil.find(Items.EXPERIENCE_BOTTLE, InventoryUtil.HOTBAR_SCOPE); + if (!bottle.found()) return; + if (autoSwitch.getValue() == AutoSwitch.None && !bottle.holding()) return; + + timer = 0; + + if (rotate.getValue()) { + // Face straight down so the bottle lands on the spot you are standing on + Fros.rotationManager.motion(new Angles(mc.player.getYRot(), 90f), 0, () -> throwBottle(bottle)); + } else { + throwBottle(bottle); + } + } + + private void throwBottle(Result bottle) { + switch (autoSwitch.getValue()) { + case None -> use(bottle.hand()); + case Normal -> InventoryUtil.withSwap(bottle, () -> use(bottle.hand())); + case Silent -> { + // Packet-only switch: the server sees the bottle while the client keeps its own slot + if (bottle.type() == ResultType.HOTBAR && bottle.slot() != InventoryUtil.selected()) { + mc.getConnection().send(new ServerboundSetCarriedItemPacket(bottle.slot())); + use(InteractionHand.MAIN_HAND); + mc.getConnection().send(new ServerboundSetCarriedItemPacket(InventoryUtil.selected())); + } else { + use(bottle.hand()); + } + } + } + } + + private void use(InteractionHand hand) { + mc.gameMode.useItem(mc.player, hand); + } + + public enum AutoSwitch { + None, Normal, Silent + } +} diff --git a/src/main/java/cc/fros/manager/ModuleManager.java b/src/main/java/cc/fros/manager/ModuleManager.java index dbdfd68..0bd0e83 100644 --- a/src/main/java/cc/fros/manager/ModuleManager.java +++ b/src/main/java/cc/fros/manager/ModuleManager.java @@ -35,6 +35,7 @@ import cc.fros.features.modules.misc.MCFModule; import cc.fros.features.modules.movement.FastAccelModule; import cc.fros.features.modules.movement.ReverseStepModule; import cc.fros.features.modules.movement.StepModule; +import cc.fros.features.modules.player.ExpThrowerModule; import cc.fros.features.modules.player.FastPlaceModule; import cc.fros.features.modules.player.NoFallModule; import cc.fros.features.modules.player.VelocityModule; @@ -85,6 +86,7 @@ public class ModuleManager implements Jsonable, Util { register(new KillAuraModule()); register(new CrystalAuraModule()); register(new SurroundModule()); + register(new ExpThrowerModule()); register(new FastAccelModule()); LOGGER.info("Registered {} modules", modules.size());