fixed automend and closed #242

This commit is contained in:
Bella 2020-04-07 10:26:24 -04:00
parent 042c1c060a
commit 9fff15529c
No known key found for this signature in database
GPG Key ID: DBD4A6030080C8B3
1 changed files with 31 additions and 27 deletions

View File

@ -9,22 +9,25 @@ import me.zeroeightsix.kami.setting.Setting;
import me.zeroeightsix.kami.setting.Settings;
import net.minecraft.init.Items;
import static me.zeroeightsix.kami.util.InfoCalculator.reverseNumber;
/**
* Created 17 October 2019 by hub
* Updated 21 November 2019 by hub
* Updated by S-B99 on 07/04/20
*/
@Module.Info(name = "AutoExp", category = Module.Category.COMBAT, description = "Automatically mends armour")
public class AutoExp extends Module {
@Module.Info(name = "AutoMend", category = Module.Category.COMBAT, description = "Automatically mends armour")
public class AutoMend extends Module {
private Setting<Boolean> autoThrow = register(Settings.b("Auto Throw", true));
private Setting<Boolean> autoSwitch = register(Settings.b("Auto Switch", true));
private Setting<Boolean> autoDisable = register(Settings.booleanBuilder("Auto Disable").withValue(true).withVisibility(o -> autoSwitch.getValue()).build());
private Setting<Boolean> autoDisable = register(Settings.booleanBuilder("Auto Disable").withValue(false).withVisibility(o -> autoSwitch.getValue()).build());
private Setting<Integer> threshold = register(Settings.integerBuilder("Repair %").withMinimum(1).withMaximum(100).withValue(75));
private int initHotbarSlot = -1;
@EventHandler
private Listener<PacketEvent.Receive> receiveListener = new Listener<>(event ->
{
private Listener<PacketEvent.Receive> receiveListener = new Listener<>(event -> {
if (mc.player != null && (mc.player.getHeldItemMainhand().getItem() == Items.EXPERIENCE_BOTTLE)) {
mc.rightClickDelayTimer = 0;
}
@ -32,10 +35,7 @@ public class AutoExp extends Module {
@Override
protected void onEnable() {
if (mc.player == null) {
return;
}
if (mc.player == null) return;
if (autoSwitch.getValue()) {
initHotbarSlot = mc.player.inventory.currentItem;
@ -45,10 +45,7 @@ public class AutoExp extends Module {
@Override
protected void onDisable() {
if (mc.player == null) {
return;
}
if (mc.player == null) return;
if (autoSwitch.getValue()) {
if (initHotbarSlot != -1 && initHotbarSlot != mc.player.inventory.currentItem) {
@ -60,10 +57,9 @@ public class AutoExp extends Module {
@Override
public void onUpdate() {
if (mc.player == null) return;
if (mc.player == null) {
return;
}
if (shouldMend(0) || shouldMend(1) || shouldMend(2) || shouldMend(3)) {
if (autoSwitch.getValue() && (mc.player.getHeldItemMainhand().getItem() != Items.EXPERIENCE_BOTTLE)) {
int xpSlot = findXpPots();
@ -80,6 +76,7 @@ public class AutoExp extends Module {
if (autoThrow.getValue() && mc.player.getHeldItemMainhand().getItem() == Items.EXPERIENCE_BOTTLE) {
mc.rightClickMouse();
}
}
}
@ -94,4 +91,11 @@ public class AutoExp extends Module {
return slot;
}
private boolean shouldMend(int i) { // (100 * damage / max damage) >= (100 - 70)
if (mc.player.inventory.armorInventory.get(i).getMaxDamage() == 0) return false;
return (100 * mc.player.inventory.armorInventory.get(i).getItemDamage())
/ mc.player.inventory.armorInventory.get(i).getMaxDamage()
> reverseNumber(threshold.getValue(), 1, 100);
}
}