forked from RepoMirrors/kami-blue
fixed automend and closed #242
This commit is contained in:
parent
042c1c060a
commit
9fff15529c
|
@ -9,22 +9,25 @@ import me.zeroeightsix.kami.setting.Setting;
|
||||||
import me.zeroeightsix.kami.setting.Settings;
|
import me.zeroeightsix.kami.setting.Settings;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
|
|
||||||
|
import static me.zeroeightsix.kami.util.InfoCalculator.reverseNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created 17 October 2019 by hub
|
* Created 17 October 2019 by hub
|
||||||
* Updated 21 November 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")
|
@Module.Info(name = "AutoMend", category = Module.Category.COMBAT, description = "Automatically mends armour")
|
||||||
public class AutoExp extends Module {
|
public class AutoMend extends Module {
|
||||||
|
|
||||||
private Setting<Boolean> autoThrow = register(Settings.b("Auto Throw", true));
|
private Setting<Boolean> autoThrow = register(Settings.b("Auto Throw", true));
|
||||||
private Setting<Boolean> autoSwitch = register(Settings.b("Auto Switch", 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;
|
private int initHotbarSlot = -1;
|
||||||
|
|
||||||
@EventHandler
|
@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)) {
|
if (mc.player != null && (mc.player.getHeldItemMainhand().getItem() == Items.EXPERIENCE_BOTTLE)) {
|
||||||
mc.rightClickDelayTimer = 0;
|
mc.rightClickDelayTimer = 0;
|
||||||
}
|
}
|
||||||
|
@ -32,10 +35,7 @@ public class AutoExp extends Module {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onEnable() {
|
protected void onEnable() {
|
||||||
|
if (mc.player == null) return;
|
||||||
if (mc.player == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (autoSwitch.getValue()) {
|
if (autoSwitch.getValue()) {
|
||||||
initHotbarSlot = mc.player.inventory.currentItem;
|
initHotbarSlot = mc.player.inventory.currentItem;
|
||||||
|
@ -45,10 +45,7 @@ public class AutoExp extends Module {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDisable() {
|
protected void onDisable() {
|
||||||
|
if (mc.player == null) return;
|
||||||
if (mc.player == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (autoSwitch.getValue()) {
|
if (autoSwitch.getValue()) {
|
||||||
if (initHotbarSlot != -1 && initHotbarSlot != mc.player.inventory.currentItem) {
|
if (initHotbarSlot != -1 && initHotbarSlot != mc.player.inventory.currentItem) {
|
||||||
|
@ -60,25 +57,25 @@ public class AutoExp extends Module {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
|
if (mc.player == null) return;
|
||||||
|
|
||||||
if (mc.player == null) {
|
if (shouldMend(0) || shouldMend(1) || shouldMend(2) || shouldMend(3)) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (autoSwitch.getValue() && (mc.player.getHeldItemMainhand().getItem() != Items.EXPERIENCE_BOTTLE)) {
|
if (autoSwitch.getValue() && (mc.player.getHeldItemMainhand().getItem() != Items.EXPERIENCE_BOTTLE)) {
|
||||||
int xpSlot = findXpPots();
|
int xpSlot = findXpPots();
|
||||||
if (xpSlot == -1) {
|
if (xpSlot == -1) {
|
||||||
if (autoDisable.getValue()) {
|
if (autoDisable.getValue()) {
|
||||||
Command.sendWarningMessage(getChatName() + " No XP in hotbar, disabling");
|
Command.sendWarningMessage(getChatName() + " No XP in hotbar, disabling");
|
||||||
disable();
|
disable();
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
mc.player.inventory.currentItem = xpSlot;
|
||||||
}
|
}
|
||||||
mc.player.inventory.currentItem = xpSlot;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (autoThrow.getValue() && mc.player.getHeldItemMainhand().getItem() == Items.EXPERIENCE_BOTTLE) {
|
if (autoThrow.getValue() && mc.player.getHeldItemMainhand().getItem() == Items.EXPERIENCE_BOTTLE) {
|
||||||
mc.rightClickMouse();
|
mc.rightClickMouse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,4 +91,11 @@ public class AutoExp extends Module {
|
||||||
return slot;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue