summaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc
diff options
context:
space:
mode:
author alemi <me@alemi.dev>2023-02-13 01:21:46 +0100
committer alemi <me@alemi.dev>2023-02-13 01:21:46 +0100
commit114cd09dc949813fd50283d8581caeb559db36f7 (patch)
tree4995a1b96cb885bbe33be4e6c79886583c353f51 /src/main/java/ftbsc
parentb6c145f1eefbddd983ab4fa60d13c593a2616f60 (diff)
feat: basic freecam module
allows to fly and cancels some packets but still can't noclip
Diffstat (limited to 'src/main/java/ftbsc')
-rw-r--r--src/main/java/ftbsc/bscv/module/self/Freecam.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/main/java/ftbsc/bscv/module/self/Freecam.java b/src/main/java/ftbsc/bscv/module/self/Freecam.java
new file mode 100644
index 0000000..b3eff57
--- /dev/null
+++ b/src/main/java/ftbsc/bscv/module/self/Freecam.java
@@ -0,0 +1,60 @@
+package ftbsc.bscv.module.self;
+
+import com.mojang.brigadier.CommandDispatcher;
+import com.mojang.brigadier.arguments.BoolArgumentType;
+
+import ftbsc.bscv.BoSCoVicino;
+import ftbsc.bscv.events.PacketEvent;
+import ftbsc.bscv.module.QuickModule;
+import net.minecraft.command.CommandSource;
+import net.minecraft.network.play.client.CPlayerPacket;
+import net.minecraft.util.math.vector.Vector3d;
+import net.minecraft.world.GameType;
+import net.minecraftforge.common.ForgeConfigSpec;
+import net.minecraftforge.event.TickEvent;
+import net.minecraftforge.eventbus.api.SubscribeEvent;
+
+public class Freecam extends QuickModule {
+
+ public final ForgeConfigSpec.ConfigValue<Boolean> log;
+
+ public Freecam(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
+ super("Freecam", Group.SELF, UNBOUND, builder, dispatcher);
+
+ this.log = this.option(
+ "log", "log canceled packets", false,
+ BoolArgumentType.bool(), Boolean.class,
+ builder, dispatcher
+ );
+ }
+
+ private Vector3d prev_pos = new Vector3d(0.0, 0.0, 0.0);
+
+ @SubscribeEvent
+ public void onPacket(PacketEvent event) {
+ if (BoSCoVicino.minecraft.player == null) return;
+ if (event.outgoing && event.packet instanceof CPlayerPacket) { // TODO must ignore more packets than just this
+ if (this.log.get()) {
+ BoSCoVicino.log(String.format("[X] %s", event.packet.getClass().getName()));
+ }
+ event.setCanceled(true);
+ }
+ }
+
+ @Override
+ protected void onEnabled() {
+ if (BoSCoVicino.minecraft.player != null) {
+ this.prev_pos = BoSCoVicino.minecraft.player.position();
+ BoSCoVicino.minecraft.gameMode.setLocalMode(GameType.SPECTATOR);
+ }
+ }
+
+ @Override
+ protected void onDisabled() {
+ if (BoSCoVicino.minecraft.player != null) {
+ BoSCoVicino.minecraft.gameMode.setLocalMode(GameType.SURVIVAL);
+ BoSCoVicino.minecraft.player.setPos(this.prev_pos.x, this.prev_pos.y, this.prev_pos.z);
+ }
+ }
+
+}