add max health check to autototem

This commit is contained in:
Bella 2020-03-15 18:01:21 -04:00
parent 0aaefc26a4
commit 833c7945d0
No known key found for this signature in database
GPG Key ID: 03B01AC937D1C89C
1 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package me.zeroeightsix.kami.module.modules.combat;
import me.zeroeightsix.kami.command.Command;
import me.zeroeightsix.kami.module.Module;
import me.zeroeightsix.kami.setting.Setting;
import me.zeroeightsix.kami.setting.Settings;
@ -15,6 +16,7 @@ import net.minecraft.item.ItemStack;
@Module.Info(name = "AutoTotem", category = Module.Category.COMBAT, description = "Refills your offhand with totems")
public class AutoTotem extends Module {
private Setting<Mode> modeSetting = register(Settings.e("Mode", Mode.REPLACE_OFFHAND));
private Setting<Double> healthSetting = register(Settings.doubleBuilder("Max replace health").withValue(20.0).withVisibility(v -> modeSetting.getValue().equals(Mode.REPLACE_OFFHAND)));
private enum Mode {
NEITHER, REPLACE_OFFHAND, INVENTORY
@ -26,6 +28,7 @@ public class AutoTotem extends Module {
@Override
public void onUpdate() {
if (!passHealthCheck()) return;
if (!modeSetting.getValue().equals(Mode.INVENTORY) && mc.currentScreen instanceof GuiContainer)
return; // this stops autototem from running if you're in a chest or something
if (returnI) {
@ -73,6 +76,13 @@ public class AutoTotem extends Module {
}
}
private boolean passHealthCheck() {
if (modeSetting.getValue().equals(Mode.REPLACE_OFFHAND)) {
return mc.player.getHealth() + mc.player.getAbsorptionAmount() <= healthSetting.getValue();
}
return true;
}
@Override
public String getHudInfo() {
return String.valueOf(totems);