feat: better antikick for VanillaFlight
This commit is contained in:
parent
a9a232838d
commit
fbee153272
1 changed files with 29 additions and 19 deletions
|
@ -1,7 +1,6 @@
|
||||||
package ftbsc.bscv.modules.motion;
|
package ftbsc.bscv.modules.motion;
|
||||||
|
|
||||||
import com.google.auto.service.AutoService;
|
import com.google.auto.service.AutoService;
|
||||||
import ftbsc.bscv.Boscovicino;
|
|
||||||
import ftbsc.bscv.ICommons;
|
import ftbsc.bscv.ICommons;
|
||||||
import ftbsc.bscv.api.ILoadable;
|
import ftbsc.bscv.api.ILoadable;
|
||||||
import ftbsc.bscv.modules.QuickModule;
|
import ftbsc.bscv.modules.QuickModule;
|
||||||
|
@ -22,9 +21,15 @@ public class VanillaFlight extends QuickModule implements ICommons {
|
||||||
return UNBOUND;
|
return UNBOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private enum AntikickMode {
|
||||||
|
NONE,
|
||||||
|
PACKET,
|
||||||
|
FORCED
|
||||||
|
}
|
||||||
|
|
||||||
public final ForgeConfigSpec.ConfigValue<Boolean> force;
|
public final ForgeConfigSpec.ConfigValue<Boolean> force;
|
||||||
public final ForgeConfigSpec.ConfigValue<Double> speed;
|
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<Double> antikick_magnitude;
|
||||||
public final ForgeConfigSpec.ConfigValue<Integer> antikick_cycle;
|
public final ForgeConfigSpec.ConfigValue<Integer> antikick_cycle;
|
||||||
|
|
||||||
|
@ -46,23 +51,23 @@ public class VanillaFlight extends QuickModule implements ICommons {
|
||||||
.comment("flight speed to set")
|
.comment("flight speed to set")
|
||||||
.build(this);
|
.build(this);
|
||||||
|
|
||||||
this.antikick = Setting.Bool.builder()
|
this.antikick = Setting.Switch.builder(AntikickMode.class)
|
||||||
.fallback(false)
|
.fallback(AntikickMode.NONE)
|
||||||
.name("antikick")
|
.name("antikick")
|
||||||
.comment("prevent vanilla flight kick by descending")
|
.comment("prevent vanilla flight kick by descending")
|
||||||
.build(this);
|
.build(this);
|
||||||
|
|
||||||
this.antikick_magnitude = Setting.Decimal.builder()
|
this.antikick_magnitude = Setting.Decimal.builder()
|
||||||
.min(0.)
|
.min(0.)
|
||||||
.fallback(1.)
|
.fallback(0.032)
|
||||||
.name("magnitude")
|
.name("magnitude")
|
||||||
.comment("magnitude of antikick push")
|
.comment("magnitude of antikick push")
|
||||||
.build(this);
|
.build(this);
|
||||||
|
|
||||||
this.antikick_cycle = Setting.Number.builder()
|
this.antikick_cycle = Setting.Number.builder()
|
||||||
.min(0)
|
.min(1)
|
||||||
.max(79)
|
.max(80)
|
||||||
.fallback(0)
|
.fallback(70)
|
||||||
.name("cycle")
|
.name("cycle")
|
||||||
.comment("how often to run antikick routine")
|
.comment("how often to run antikick routine")
|
||||||
.build(this);
|
.build(this);
|
||||||
|
@ -81,18 +86,23 @@ public class VanillaFlight extends QuickModule implements ICommons {
|
||||||
if (this.force.get()) {
|
if (this.force.get()) {
|
||||||
MC.player.abilities.flying = true;
|
MC.player.abilities.flying = true;
|
||||||
}
|
}
|
||||||
if (this.antikick.get() && MC.player.abilities.flying) {
|
|
||||||
this.tick = ( this.tick + 1 ) % this.antikick_cycle.get();
|
this.tick = ( this.tick + 1 ) % this.antikick_cycle.get();
|
||||||
if (this.tick == 0) {
|
Vector3d pos = MC.player.position();
|
||||||
Vector3d pos = MC.player.position();
|
|
||||||
Boscovicino.log("[*] antikick");
|
if (this.tick == 0) {
|
||||||
MC.player.connection.send(
|
switch (this.antikick.get()) {
|
||||||
new CPlayerPacket.PositionPacket(pos.x, pos.y - this.antikick_magnitude.get(), pos.z, false)
|
case PACKET:
|
||||||
);
|
MC.player.connection.send(
|
||||||
MC.player.setPos(pos.x, pos.y - this.antikick_magnitude.get(), pos.z);
|
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue