Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AutoWeapon.java #5073

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
import meteordevelopment.meteorclient.utils.player.InvUtils;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.AxeItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.AxeItem;
import net.minecraft.item.SwordItem;
import net.minecraft.item.MaceItem;
import net.minecraft.item.TridentItem;
import java.lang.Math;

public class AutoWeapon extends Module {
private final SettingGroup sgGeneral = settings.getDefaultGroup();
Expand Down Expand Up @@ -55,37 +58,64 @@ private void onAttack(AttackEntityEvent event) {
private int getBestWeapon(LivingEntity target) {
int slotS = mc.player.getInventory().selectedSlot;
int slotA = mc.player.getInventory().selectedSlot;
int slotT = mc.player.getInventory().selectedSlot;
int slotM = mc.player.getInventory().selectedSlot;
double damageS = 0;
double damageA = 0;
double damageT = 0;
double damageM = 0;
double currentDamageS;
double currentDamageA;
double currentDamageT;
double currentDamageM;
for (int i = 0; i < 9; i++) {
ItemStack stack = mc.player.getInventory().getStack(i);
if (stack.getItem() instanceof SwordItem
&& (!antiBreak.get() || (stack.getMaxDamage() - stack.getDamage()) > 10)) {
&& (!antiBreak.get() || (stack.getMaxDamage() - stack.getDamage()) > 10)) {
currentDamageS = DamageUtils.getAttackDamage(mc.player, target, stack);
if (currentDamageS > damageS) {
damageS = currentDamageS;
slotS = i;
}
} else if (stack.getItem() instanceof AxeItem
&& (!antiBreak.get() || (stack.getMaxDamage() - stack.getDamage()) > 10)) {
&& (!antiBreak.get() || (stack.getMaxDamage() - stack.getDamage()) > 10)) {
currentDamageA = DamageUtils.getAttackDamage(mc.player, target, stack);
if (currentDamageA > damageA) {
damageA = currentDamageA;
slotA = i;
}
} else if (stack.getItem() instanceof TridentItem
&& (!antiBreak.get() || (stack.getMaxDamage() - stack.getDamage()) > 10)) {
currentDamageT = DamageUtils.getAttackDamage(mc.player, target, stack);
if (currentDamageT > damageT) {
damageT = currentDamageT;
slotT = i;
}
} else if (stack.getItem() instanceof MaceItem
&& (!antiBreak.get() || (stack.getMaxDamage() - stack.getDamage()) > 10)) {
currentDamageM = DamageUtils.getAttackDamage(mc.player, target, stack);
if (currentDamageM > damageM) {
damageM = currentDamageM;
slotM = i;
}
}
}
if (weapon.get() == Weapon.Sword && threshold.get() > damageA - damageS) return slotS;
else if (weapon.get() == Weapon.Axe && threshold.get() > damageS - damageA) return slotA;
else if (weapon.get() == Weapon.Sword && threshold.get() < damageA - damageS) return slotA;
else if (weapon.get() == Weapon.Axe && threshold.get() < damageS - damageA) return slotS;
else return mc.player.getInventory().selectedSlot;
if (weapon.get() != Weapon.Sword) damageS -= threshold.get();
if (weapon.get() != Weapon.Axe) damageA -= threshold.get();
if (weapon.get() != Weapon.Trident) damageT -= threshold.get();
if (weapon.get() != Weapon.Mace) damageM -= threshold.get();
double max = Math.max(Math.max(damageS, damageA), Math.max(damageT, damageM));
if (max == damageS) return slotS;
else if (max == damageA) return slotA;
else if (max == damageT) return slotT;
else if (max == damageM) return slotT;
else return mc.player.getInventory().selectedSlot;
}

public enum Weapon {
Sword,
Axe
Axe,
Trident,
Mace
}
}