add ExpThrower module
This commit is contained in:
@@ -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<Integer> delay = num("Delay", 0, 0, 20);
|
||||
private final Setting<Boolean> rotate = bool("Rotate", true);
|
||||
private final Setting<AutoSwitch> 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
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user