Upload files to "src/openonyx/features/combat"

This commit is contained in:
winterflyt committed 2026-11-30 05:48:52 +02:00
1 parent 47f8f294f5
commit f0f8a88f49
5 files changed
+595

No files matched your search

@@ -0,0 +1,16 @@
package openonyx.features.combat;
public enum HitCheck {
RAYCAST,
OFF,
ANGLE;
private static HitCheck[] L() {
HitCheck[] hitChecks = new HitCheck[3];
boolean bl = true;
hitChecks[0] = OFF;
hitChecks[1] = ANGLE;
hitChecks[2] = RAYCAST;
return hitChecks;
}
}
+137
View File
@@ -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();
}
}
}
}
}
+387
View File
@@ -0,0 +1,387 @@
package openonyx.features.combat;
import java.util.Iterator;
import java.util.Random;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S19PacketEntityStatus;
import openonyx.configuration.internal.PacketDirection;
import openonyx.configuration.internal.PacketEvent;
import openonyx.configuration.internal.TickEndEvent;
import openonyx.configuration.internal.TickEvent;
import openonyx.configuration.internal.WorldChangeEvent;
import openonyx.core.OnyxClient;
import openonyx.events.AimController;
import openonyx.events.EntityRelationUtils;
import openonyx.events.GeometryUtils;
import openonyx.events.Rotation;
import openonyx.events.RotationManager;
import openonyx.events.RotationSettings;
import openonyx.features.Module;
import openonyx.features.ModuleCategory;
import openonyx.features.player.Scaffold;
import openonyx.history.internal.BooleanSetting;
import openonyx.history.internal.EnumSetting;
import openonyx.history.internal.KeybindSetting;
import openonyx.history.internal.MultiSelectSetting;
import openonyx.history.internal.NumberSetting;
import openonyx.utilities.Timer;
public class KillAura extends Module {
private static final long MIN_ATTACK_INTERVAL_MS = 25L;
private EntityLivingBase previousTarget;
public BooleanSetting onlySword;
private final Random random;
public NumberSetting minCps;
private EntityLivingBase target;
public RotationSettings rotationSettings;
private long lastAttackAt;
private final CombatController combatController;
private final AimController aimController;
public EnumSetting<AutoBlockMode> autoBlockMode;
public NumberSetting maxCps;
public EnumSetting<HitCheck> hitCheck;
private final Timer attackTimer;
private boolean toggleAutoBlock;
private int targetTicks;
public NumberSetting targetDistance = new NumberSetting("Distance", 3.0, 3.0, 6.0, 0.05);
private boolean autoBlockKeyDown;
public KeybindSetting autoBlockKey;
public EnumSetting<AutoBlockTrigger> autoBlockTrigger;
public NumberSetting hitAngle;
public NumberSetting switchDelay;
public BooleanSetting throughWalls;
public MultiSelectSetting<TargetFilter> targetFilters;
private double distanceToEntity(Entity entity) {
return GeometryUtils.L(entity);
}
@EventHandler
public void onPacket(PacketEvent packetEvent) {
if (packetEvent.getPacketDirection() == PacketDirection.OUTGOING) {
this.combatController.L(packetEvent);
} else if (this.shouldBlock()) {
Packet packet;
if ((packet = packetEvent.getPacket()) instanceof S19PacketEntityStatus) {
S19PacketEntityStatus s19PacketEntityStatus;
if ((s19PacketEntityStatus = (S19PacketEntityStatus)packet).getOpCode() == 2) {
if (mc.thePlayer != null && s19PacketEntityStatus.getEntityId() == mc.thePlayer.getEntityId()) {
this.combatController.F();
}
}
}
}
}
private boolean shouldAttack() {
if (this.onlySword.isEnabled() && !CombatController.isHoldingSword()) {
return false;
} else if (this.targetTicks < this.switchDelay.getInt()) {
return false;
} else {
return !this.canSeeEntity(this.target) ? false : this.passesHitCheck(RotationManager.L());
}
}
public static boolean isAttackReady() {
KillAura killAura = OnyxClient.moduleManager == null ? null : OnyxClient.moduleManager.killAura;
return killAura == null || killAura.combatController.L();
}
private boolean passesHitCheck(Rotation rotation) {
switch ((HitCheck)this.hitCheck.getValue()) {
case RAYCAST:
while (false) {
}
return true;
case OFF:
if (this.aimController.L(rotation) <= this.hitAngle.getFloat()) {
return true;
}
return false;
case ANGLE:
return this.aimController.L(this.target, rotation, this.targetDistance.getValue());
default:
throw new MatchException(null, null);
}
}
private boolean shouldBlock() {
if (!this.autoBlockMode.is(AutoBlockMode.WATCHDOG)) {
return false;
}
switch ((AutoBlockTrigger)this.autoBlockTrigger.getValue()) {
case TOGGLE:
while (false) {
}
return true;
case ALWAYS:
if (this.autoBlockKey.isBound() && this.autoBlockKeyDown) {
return true;
}
return false;
case HOLD:
if (this.autoBlockKey.isBound() && !this.toggleAutoBlock) {
return false;
}
return true;
default:
throw new MatchException(null, null);
}
}
@Override
protected void onDisable() {
this.target = null;
this.previousTarget = null;
this.targetTicks = 0;
this.lastAttackAt = 0L;
this.toggleAutoBlock = false;
this.autoBlockKeyDown = false;
this.combatController.L(true);
this.aimController.reset();
}
public static boolean isActive() {
KillAura killAura = OnyxClient.moduleManager == null ? null : OnyxClient.moduleManager.killAura;
return killAura != null && killAura.isEnabled() && killAura.combatController.d();
}
private boolean isValidTarget(EntityLivingBase entityLivingBase) {
if (entityLivingBase instanceof EntityPlayer) {
EntityPlayer entityPlayer;
if (AntiBot.L(entityPlayer = (EntityPlayer)entityLivingBase)) {
return false;
}
boolean bl1 = entityLivingBase.getTotalArmorValue() == 0;
boolean bl2 = entityLivingBase.isInvisible();
boolean bl = this.targetFilters.contains(TargetFilter.PLAYERS);
if (bl1 && this.targetFilters.contains(TargetFilter.NAKED)) {
bl = true;
}
if (bl2 && this.targetFilters.contains(TargetFilter.INVISIBLE)) {
bl = true;
}
if (bl1 && bl2 && this.targetFilters.contains(TargetFilter.NAKED_INVISIBLE)) {
bl = true;
}
return targetSelectionAllowed(EntityRelationUtils.L(mc.thePlayer, entityPlayer), this.targetFilters.contains(TargetFilter.TEAMMATES), bl);
} else if (entityLivingBase instanceof EntityAnimal) {
return this.targetFilters.contains(TargetFilter.ANIMALS);
} else {
return entityLivingBase instanceof EntityLiving ? this.targetFilters.contains(TargetFilter.MOBS) : false;
}
}
private void attackIfReady() {
if (this.lastAttackAt == 0L || this.attackTimer.hasReached(this.lastAttackAt - 25L)) {
if (this.shouldAttack()) {
this.k();
this.lastAttackAt = this.nextAttackDelayMillis();
this.attackTimer.reset();
}
}
}
private void resetCombatState() {
this.previousTarget = this.target = null;
this.targetTicks = 0;
this.toggleAutoBlock = false;
this.autoBlockKeyDown = false;
this.combatController.L(true);
this.aimController.reset();
}
public EntityLivingBase getTarget() {
return this.target;
}
private boolean canSeeEntity(Entity entity) {
return this.throughWalls.isEnabled() || mc.thePlayer.canEntityBeSeen(entity);
}
@EventHandler
public void onTickEnd(TickEndEvent tickEndEvent) {
this.combatController.e();
}
private EntityLivingBase findTarget() {
KillAura killAura1 = this;
EntityLivingBase entityLivingBase = null;
double d = killAura1.targetDistance.getValue() * killAura1.targetDistance.getValue();
Iterator iterator = mc.theWorld.loadedEntityList.iterator();
label45:
while (true) {
Iterator iterator1 = iterator;
while (iterator1.hasNext()) {
Entity entity;
if (!((entity = (Entity)iterator.next()) instanceof EntityLivingBase)) {
continue label45;
}
if ((entity = entity) == mc.thePlayer) {
iterator1 = iterator;
} else if (!entity.isEntityAlive()) {
iterator1 = iterator;
} else if (entity instanceof EntityArmorStand) {
iterator1 = iterator;
} else {
EntityPlayer entityPlayer;
if (entity instanceof EntityPlayer && (entityPlayer = entity).isSpectator()) {
iterator1 = iterator;
} else if (!killAura1.isValidTarget(entity)) {
iterator1 = iterator;
} else if (!killAura1.canSeeEntity(entity)) {
iterator1 = iterator;
} else {
double e;
if ((e = killAura1.distanceToEntity(entity)) > d) {
iterator1 = iterator;
} else {
entityLivingBase = entity;
d = e;
iterator1 = iterator;
}
}
}
}
return entityLivingBase;
}
}
public KillAura() {
super("KillAura", "Automatically aims and kills enemies", ModuleCategory.COMBAT);
TargetFilter[] targetFiltersx = new TargetFilter[4];
boolean bl = true;
targetFiltersx[0] = TargetFilter.PLAYERS;
targetFiltersx[1] = TargetFilter.NAKED;
targetFiltersx[2] = TargetFilter.NAKED_INVISIBLE;
targetFiltersx[3] = TargetFilter.INVISIBLE;
this.targetFilters = new MultiSelectSetting<>("Targets", TargetFilter.class, targetFiltersx)
.describe("Teammates are excluded unless explicitly selected");
this.throughWalls = new BooleanSetting("Through walls", false).describe("Allows targeting and attacking entities behind blocks");
this.hitCheck = new EnumSetting<>("Hit check", HitCheck.RAYCAST).describe("Holds the attack until the sent rotation actually covers the target");
this.hitAngle = new NumberSetting("Hit angle", 8.0, 1.0, 45.0, 1.0).withSuffix("°").visibleWhen(() -> this.hitCheck.is(HitCheck.ANGLE));
this.switchDelay = new NumberSetting("Switch delay", 0.0, 0.0, 20.0, 1.0)
.withSuffix("t")
.describe("Extra ticks to hold the attack after the target changes");
this.minCps = new NumberSetting("CPS min", 7.0, 1.0, 20.0, 1.0);
this.maxCps = new NumberSetting("CPS max", 10.0, 1.0, 20.0, 1.0);
this.onlySword = new BooleanSetting("Only sword", false).describe("Only attacks while a sword is held in hand");
this.autoBlockMode = new EnumSetting<>("Autoblock", AutoBlockMode.OFF).describe("Automatically blocks sword");
this.autoBlockTrigger = new EnumSetting<>("Autoblock trigger", AutoBlockTrigger.ALWAYS)
.describe("Whether the autoblock runs on its own, only while a key is held, or on a key that toggles it")
.visibleWhen(this.autoBlockMode, autoBlockMode -> autoBlockModex != AutoBlockMode.OFF);
this.autoBlockKey = new KeybindSetting("Autoblock key")
.describe("The key the hold and toggle triggers watch")
.visibleWhen(() -> !this.autoBlockMode.is(AutoBlockMode.OFF) && !this.autoBlockTrigger.is(AutoBlockTrigger.ALWAYS));
this.rotationSettings = new RotationSettings();
this.aimController = new AimController(this.rotationSettings);
this.random = new Random();
this.combatController = new CombatController();
this.attackTimer = new Timer();
}
private long nextAttackDelayMillis() {
KillAura killAura1 = this;
float f = Math.min(killAura1.minCps.getFloat(), killAura1.maxCps.getFloat());
float g = Math.max(killAura1.minCps.getFloat(), killAura1.maxCps.getFloat());
return (long)(1000.0 / (f + killAura1.random.nextFloat() * (g - f)));
}
private void updateAutoBlockKey() {
KillAura killAura1 = this;
boolean bl = mc.currentScreen == null && killAura1.autoBlockKey.isBound() && killAura1.autoBlockKey.isPressed();
if (bl && !killAura1.autoBlockKeyDown && killAura1.autoBlockTrigger.is(AutoBlockTrigger.TOGGLE)) {
killAura1.toggleAutoBlock = !killAura1.toggleAutoBlock;
}
killAura1.autoBlockKeyDown = bl;
}
@EventHandler
public void onTick(TickEvent tickEvent) {
if (mc.thePlayer != null && mc.theWorld != null) {
this.updateAutoBlockKey();
this.combatController.i();
if (!mc.thePlayer.isEntityAlive()) {
this.resetCombatState();
} else if (Scaffold.INSTANCE.isEnabled()) {
this.resetCombatState();
} else {
BedBreaker bedBreaker = OnyxClient.moduleManager.bedBreaker;
if (OnyxClient.moduleManager.bedBreaker.isEnabled() && !bedBreaker.prioritizeKillAura.isEnabled() && bedBreaker.getBlockPos3() != null) {
this.resetCombatState();
} else {
EntityLivingBase entityLivingBase = this.target;
this.previousTarget = this.findTarget();
this.target = this.previousTarget;
if (this.target != null && (!this.onlySword.isEnabled() || CombatController.isHoldingSword())) {
this.targetTicks = this.target == entityLivingBase ? this.targetTicks + 1 : 0;
boolean bl = false;
boolean bl1;
if (this.shouldBlock() && CombatController.isHoldingSword()) {
bl1 = this.combatController.L(this.target, () -> {
mc.thePlayer.swingItem();
mc.playerController.attackEntity(mc.thePlayer, this.target);
});
} else {
this.combatController.L(true);
bl1 = bl;
}
if (!bl1) {
this.attackIfReady();
}
this.aimController.L(this.target, this.targetDistance.getValue());
} else {
this.target = null;
this.targetTicks = 0;
this.combatController.L(true);
this.aimController.reset();
}
}
}
}
}
static boolean targetSelectionAllowed(boolean bl, boolean bl1, boolean bl2) {
return bl ? bl1 : bl2;
}
@EventHandler
public void onWorldChange(WorldChangeEvent worldChangeEvent) {
this.combatController.l();
this.resetCombatState();
}
public static boolean h() {
KillAura killAura = OnyxClient.moduleManager == null ? null : OnyxClient.moduleManager.killAura;
return killAura != null && killAura.isEnabled() && killAura.combatController.i();
}
public EntityLivingBase getPreviousTarget() {
return this.previousTarget;
}
}
@@ -0,0 +1,31 @@
package openonyx.features.combat;
import openonyx.history.DisplayNamed;
public enum PlacementOrder implements DisplayNamed {
PATTERN("Pattern"),
NEAREST("Nearest"),
FURTHEST("Furthest"),
BOTTOM_UP("Bottom Up");
private final String d;
@Override
public String getDisplayName() {
return this.d;
}
PlacementOrder(String string1) {
this.d = string1;
}
private static PlacementOrder[] L() {
PlacementOrder[] placementOrders = new PlacementOrder[4];
boolean bl = true;
placementOrders[0] = BOTTOM_UP;
placementOrders[1] = FURTHEST;
placementOrders[2] = NEAREST;
placementOrders[3] = PATTERN;
return placementOrders;
}
}
@@ -0,0 +1,24 @@
package openonyx.features.combat;
public enum TargetFilter {
MOBS,
INVISIBLE,
TEAMMATES,
ANIMALS,
PLAYERS,
NAKED_INVISIBLE,
NAKED;
private static TargetFilter[] L() {
TargetFilter[] targetFilters = new TargetFilter[7];
boolean bl = true;
targetFilters[0] = PLAYERS;
targetFilters[1] = TEAMMATES;
targetFilters[2] = NAKED;
targetFilters[3] = NAKED_INVISIBLE;
targetFilters[4] = INVISIBLE;
targetFilters[5] = MOBS;
targetFilters[6] = ANIMALS;
return targetFilters;
}
}