Upload files to "src/openonyx/features/combat"
This commit is contained in:
1 parent
47f8f294f5
commit
f0f8a88f49
5 files changed
+595
No files matched your search
@@ -0,0 +1,137 @@
|
||||
package openonyx.features.combat;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import meteordevelopment.orbit.EventHandler;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import openonyx.configuration.internal.MovementInputEvent;
|
||||
import openonyx.configuration.internal.RunTickEvent;
|
||||
import openonyx.configuration.internal.TickEndEvent;
|
||||
import openonyx.configuration.internal.VelocityEvent;
|
||||
import openonyx.configuration.internal.WorldChangeEvent;
|
||||
import openonyx.core.OnyxClient;
|
||||
import openonyx.events.Rotation;
|
||||
import openonyx.events.RotationFixMode;
|
||||
import openonyx.events.RotationManager;
|
||||
import openonyx.features.Module;
|
||||
import openonyx.features.ModuleCategory;
|
||||
import openonyx.features.player.Scaffold;
|
||||
import openonyx.history.Setting;
|
||||
import openonyx.history.internal.BooleanSetting;
|
||||
import openonyx.history.internal.MultiSelectSetting;
|
||||
import openonyx.history.internal.NumberSetting;
|
||||
import openonyx.utilities.MovementInputState;
|
||||
import openonyx.utilities.Timer;
|
||||
|
||||
public class JumpReset extends Module {
|
||||
private boolean g;
|
||||
public BooleanSetting requireMoving;
|
||||
public MultiSelectSetting<TargetScanner> targets;
|
||||
public NumberSetting fov;
|
||||
public NumberSetting range;
|
||||
public BooleanSetting reduce;
|
||||
private static final long l = 550L;
|
||||
private boolean I;
|
||||
private int d;
|
||||
private volatile boolean i;
|
||||
private static final int f = 3;
|
||||
public NumberSetting chance = new NumberSetting("Chance", 100.0, 0.0, 100.0, 1.0).withSuffix("%");
|
||||
private final Timer timer;
|
||||
|
||||
public boolean h() {
|
||||
if (mc.thePlayer == null) {
|
||||
return false;
|
||||
} else if (this.requireMoving.isEnabled() && !new MovementInputState(mc.thePlayer.movementInput).i()) {
|
||||
return false;
|
||||
} else if (ThreadLocalRandom.current().nextDouble(100.0) >= this.chance.getValue()) {
|
||||
return false;
|
||||
} else if (mc.thePlayer.isPotionActive(Potion.jump)) {
|
||||
return false;
|
||||
} else {
|
||||
return !this.i ? false : mc.thePlayer.isSprinting();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onTickEnd(TickEndEvent tickEndEvent) {
|
||||
if (this.d > 0) {
|
||||
this.d--;
|
||||
} else {
|
||||
if (this.g && this.timer.hasElapsed(550L)) {
|
||||
RotationManager.d();
|
||||
this.g = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void h() {
|
||||
this.I = false;
|
||||
this.d = 0;
|
||||
if (this.g) {
|
||||
RotationManager.d();
|
||||
this.g = false;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onWorldChange(WorldChangeEvent worldChangeEvent) {
|
||||
this.h();
|
||||
}
|
||||
|
||||
public JumpReset() {
|
||||
super("JumpReset", "Jump resets and reduces knockback in combat", ModuleCategory.COMBAT);
|
||||
this.fov = new NumberSetting("FOV", 180.0, 0.0, 360.0, 1.0).withSuffix("°").visibleWhen(Setting.BOOLEAN_SUPPLIER);
|
||||
this.range = new NumberSetting("Range", 5.0, 1.0, 8.0, 0.1);
|
||||
this.requireMoving = new BooleanSetting("Require moving", true);
|
||||
this.reduce = new BooleanSetting("Reduce", false)
|
||||
.describe("Silently faces the knockback source so the forced input runs into it")
|
||||
.visibleWhen(Setting.BOOLEAN_SUPPLIER);
|
||||
TargetScanner[] targetScanners = new TargetScanner[1];
|
||||
boolean bl = true;
|
||||
targetScanners[0] = TargetScanner.PLAYERS;
|
||||
this.targets = new MultiSelectSetting<>("Targets", TargetScanner.class, targetScanners);
|
||||
this.timer = new Timer();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onMovementInput(MovementInputEvent movementInputEvent) {
|
||||
JumpReset jumpReset1 = this;
|
||||
if (jumpReset1.I) {
|
||||
jumpReset1.I = false;
|
||||
MovementInputState movementInputState = movementInputEvent.getMovementInputState();
|
||||
movementInputEvent.L(new MovementInputState(true, false, movementInputState.left(), movementInputState.right()));
|
||||
movementInputEvent.L(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean I() {
|
||||
JumpReset jumpReset = OnyxClient.moduleManager == null ? null : OnyxClient.moduleManager.jumpReset;
|
||||
return jumpReset != null && jumpReset.isEnabled() && jumpReset.h();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onRunTick(RunTickEvent runTickEvent) {
|
||||
this.i = mc.thePlayer != null && TargetScanner.L(this.range.getValue(), this.fov.getFloat(), this.targets.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDisable() {
|
||||
this.h();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onVelocity(VelocityEvent velocityEvent) {
|
||||
if (!(velocityEvent.D() <= 0.0)) {
|
||||
if (this.h()) {
|
||||
this.I = true;
|
||||
this.d = 3;
|
||||
if (this.reduce.isEnabled() && !RotationManager.d() && !Scaffold.INSTANCE.isEnabled()) {
|
||||
float fx = (float)MathHelper.wrapAngleTo180_double(Math.toDegrees(Math.atan2(-velocityEvent.d(), velocityEvent.L())) - 180.0);
|
||||
RotationManager.setRotation(new Rotation(fx, mc.thePlayer.rotationPitch), RotationFixMode.SILENT);
|
||||
this.g = true;
|
||||
this.timer.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user