feat: basic freecam module
allows to fly and cancels some packets but still can't noclip
This commit is contained in:
parent
b6c145f1ee
commit
114cd09dc9
1 changed files with 60 additions and 0 deletions
60
src/main/java/ftbsc/bscv/module/self/Freecam.java
Normal file
60
src/main/java/ftbsc/bscv/module/self/Freecam.java
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue