From 1a11a3e163205e4bb64b1a724af019fff86d400b Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 15 Feb 2023 21:45:27 +0100 Subject: feat: added AntiHunger --- src/main/java/ftbsc/bscv/BoSCoVicino.java | 1 + .../java/ftbsc/bscv/modules/self/AntiHunger.java | 61 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/main/java/ftbsc/bscv/modules/self/AntiHunger.java diff --git a/src/main/java/ftbsc/bscv/BoSCoVicino.java b/src/main/java/ftbsc/bscv/BoSCoVicino.java index 4f4c108..5f2bc6b 100644 --- a/src/main/java/ftbsc/bscv/BoSCoVicino.java +++ b/src/main/java/ftbsc/bscv/BoSCoVicino.java @@ -63,6 +63,7 @@ public class BoSCoVicino implements ICommons { BoSCoVicino.mods.add(new Coordinates(cfg, dp).done(cfg)); BoSCoVicino.mods.add(new EntityList(cfg, dp).done(cfg)); BoSCoVicino.mods.add(new Fullbright(cfg, dp).done(cfg)); + BoSCoVicino.mods.add(new AntiHunger(cfg, dp).done(cfg)); BoSCoVicino.mods.add(new Freecam(cfg, dp).done(cfg)); BoSCoVicino.spec = cfg.build(); diff --git a/src/main/java/ftbsc/bscv/modules/self/AntiHunger.java b/src/main/java/ftbsc/bscv/modules/self/AntiHunger.java new file mode 100644 index 0000000..6630aa5 --- /dev/null +++ b/src/main/java/ftbsc/bscv/modules/self/AntiHunger.java @@ -0,0 +1,61 @@ +package ftbsc.bscv.modules.self; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.BoolArgumentType; + +import ftbsc.bscv.ICommons; +import ftbsc.bscv.events.PacketEvent; +import ftbsc.bscv.modules.Module; +import net.minecraft.command.CommandSource; +import net.minecraft.network.play.client.CEntityActionPacket; +import net.minecraft.network.play.client.CPlayerPacket; +import net.minecraft.network.play.client.CEntityActionPacket.Action; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.eventbus.api.SubscribeEvent; + +public class AntiHunger extends Module implements ICommons { + + public final ForgeConfigSpec.ConfigValue sprint; + public final ForgeConfigSpec.ConfigValue hover; + + public AntiHunger(ForgeConfigSpec.Builder builder, CommandDispatcher dispatcher) { + super("AntiHunger", Group.SELF, builder, dispatcher); + + this.sprint = this.option( + "sprint", "mask sprint toggle packets", true, + BoolArgumentType.bool(), Boolean.class, + builder, dispatcher + ); + + this.hover = this.option( + "hover", "mark as not on-ground while walking", true, + BoolArgumentType.bool(), Boolean.class, + builder, dispatcher + ); + } + + @SubscribeEvent + public void onPacket(PacketEvent event) { + if (!event.outgoing) return; + if (this.sprint.get() && event.packet instanceof CEntityActionPacket) { + CEntityActionPacket packet = (CEntityActionPacket) event.packet; + if ( + packet.getAction() == Action.START_SPRINTING || + packet.getAction() == Action.STOP_SPRINTING + ) { + event.setCanceled(true); + } + } + + if ( + this.hover.get() + && event.packet instanceof CPlayerPacket + && MC.player != null + && MC.player.fallDistance <= 0.f + && !MC.gameMode.isDestroying() + ) { + CPlayerPacket packet = (CPlayerPacket) event.packet; + packet.onGround = false; // ACCESSTRANSFORMER public net.minecraft.network.play.client.CPlayerPacket field_149474_g + } + } +} -- cgit v1.2.3-56-ga3b1