aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author alemi <me@alemi.dev>2023-03-08 17:25:50 +0100
committer alemi <me@alemi.dev>2023-03-08 17:25:50 +0100
commitfbee15327253169d2545e6c364c8d9a8267b7a5e (patch)
tree083edee8565e804a8c6286574dc103b1f0751d64 /src
parenta9a232838d1c448945e14f6629cc26e012424b86 (diff)
feat: better antikick for VanillaFlight
Diffstat (limited to 'src')
-rw-r--r--src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java b/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java
index 2b238a4..214b141 100644
--- a/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java
+++ b/src/main/java/ftbsc/bscv/modules/motion/VanillaFlight.java
@@ -1,7 +1,6 @@
package ftbsc.bscv.modules.motion;
import com.google.auto.service.AutoService;
-import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.ICommons;
import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.modules.QuickModule;
@@ -22,9 +21,15 @@ public class VanillaFlight extends QuickModule implements ICommons {
return UNBOUND;
}
+ private enum AntikickMode {
+ NONE,
+ PACKET,
+ FORCED
+ }
+
public final ForgeConfigSpec.ConfigValue<Boolean> force;
public final ForgeConfigSpec.ConfigValue<Double> speed;
- public final ForgeConfigSpec.ConfigValue<Boolean> antikick;
+ public final ForgeConfigSpec.ConfigValue<AntikickMode> antikick;
public final ForgeConfigSpec.ConfigValue<Double> antikick_magnitude;
public final ForgeConfigSpec.ConfigValue<Integer> antikick_cycle;
@@ -46,23 +51,23 @@ public class VanillaFlight extends QuickModule implements ICommons {
.comment("flight speed to set")
.build(this);
- this.antikick = Setting.Bool.builder()
- .fallback(false)
+ this.antikick = Setting.Switch.builder(AntikickMode.class)
+ .fallback(AntikickMode.NONE)
.name("antikick")
.comment("prevent vanilla flight kick by descending")
.build(this);
this.antikick_magnitude = Setting.Decimal.builder()
.min(0.)
- .fallback(1.)
+ .fallback(0.032)
.name("magnitude")
.comment("magnitude of antikick push")
.build(this);
this.antikick_cycle = Setting.Number.builder()
- .min(0)
- .max(79)
- .fallback(0)
+ .min(1)
+ .max(80)
+ .fallback(70)
.name("cycle")
.comment("how often to run antikick routine")
.build(this);
@@ -81,18 +86,23 @@ public class VanillaFlight extends QuickModule implements ICommons {
if (this.force.get()) {
MC.player.abilities.flying = true;
}
- if (this.antikick.get() && MC.player.abilities.flying) {
- this.tick = ( this.tick + 1 ) % this.antikick_cycle.get();
- if (this.tick == 0) {
- Vector3d pos = MC.player.position();
- Boscovicino.log("[*] antikick");
- MC.player.connection.send(
- new CPlayerPacket.PositionPacket(pos.x, pos.y - this.antikick_magnitude.get(), pos.z, false)
- );
- MC.player.setPos(pos.x, pos.y - this.antikick_magnitude.get(), pos.z);
+
+ this.tick = ( this.tick + 1 ) % this.antikick_cycle.get();
+ Vector3d pos = MC.player.position();
+
+ if (this.tick == 0) {
+ switch (this.antikick.get()) {
+ case PACKET:
+ MC.player.connection.send(
+ new CPlayerPacket.PositionPacket(pos.x, pos.y - this.antikick_magnitude.get(), pos.z, false)
+ );
+ break;
+ case FORCED:
+ MC.player.setPos(pos.x, pos.y - this.antikick_magnitude.get(), pos.z);
+ break;
+ case NONE:
+ break;
}
- } else {
- this.tick = 0; // reset antikick counter
}
}