Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
xia-mc committed Jul 12, 2024
2 parents d6ff2ec + 417ae79 commit 0ac9d4c
Showing 1 changed file with 42 additions and 36 deletions.
78 changes: 42 additions & 36 deletions src/main/java/keystrokesmod/module/impl/player/AutoHeal.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import keystrokesmod.module.setting.utils.ModeOnly;
import keystrokesmod.utility.ContainerUtils;
import keystrokesmod.utility.Utils;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.item.ItemSkull;
import net.minecraft.item.ItemSoup;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
Expand All @@ -24,55 +23,62 @@ public class AutoHeal extends Module {
private long lastHeal = -1;
private long lastSwitchTo = -1;
private long lastDoneUse = -1;
private int originalSlot = -1;
public AutoHeal() {
super("AutoHeal", category.player);
this.registerSetting(new DescriptionSetting("help you win by auto use healing item."));
this.registerSetting(item = new ModeSetting("Item", new String[]{"Golden head", "Soup"}, 0));
this.registerSetting(autoThrow = new ButtonSetting("Auto throw", false, new ModeOnly(item, 1)));
this.registerSetting(minHealth = new SliderSetting("Min health", 10, 0, 20, 1));
this.registerSetting(healDelay = new SliderSetting("Heal delay", 500, 0, 1500, 1));
this.registerSetting(startDelay = new SliderSetting("Start delay", 30, 0, 300, 1));
this.registerSetting(startDelay = new SliderSetting("Start delay", 0, 0, 300, 1));
}

@SubscribeEvent
public void onRender(TickEvent.RenderTickEvent event) {
if (!Utils.nullCheck() || mc.thePlayer.isDead) return;
if (System.currentTimeMillis() - lastHeal < healDelay.getInput()) return;
if (!Utils.nullCheck() || mc.thePlayer.isDead) return;
if (System.currentTimeMillis() - lastHeal < healDelay.getInput()) return;

if (mc.thePlayer.getHealth() <= minHealth.getInput()) {
if (lastSwitchTo == -1) {
int toSlot;
switch ((int) item.getInput()) {
default:
case 0:
toSlot = ContainerUtils.getSlot(ItemSkull.class);
break;
case 1:
toSlot = ContainerUtils.getSlot(ItemSoup.class);
break;
}
if (mc.thePlayer.getHealth() <= minHealth.getInput()) {
if (lastSwitchTo == -1) {
int toSlot;
switch ((int) item.getInput()) {
default:
case 0:
toSlot = ContainerUtils.getSlot(ItemSkull.class);
break;
case 1:
toSlot = ContainerUtils.getSlot(ItemSoup.class);
break;
}

if (toSlot == -1) return;
if (toSlot == -1) return;

SlotHandler.setCurrentSlot(toSlot);
lastSwitchTo = System.currentTimeMillis();
}
}
originalSlot = mc.thePlayer.inventory.currentItem;
SlotHandler.setCurrentSlot(toSlot);
lastSwitchTo = System.currentTimeMillis();
}
}

if (lastSwitchTo != -1) {
if (lastDoneUse == -1) {
if (System.currentTimeMillis() - lastSwitchTo < startDelay.getInput()) return;
mc.playerController.sendUseItem(mc.thePlayer, mc.theWorld, SlotHandler.getHeldItem());
lastDoneUse = System.currentTimeMillis();
} else {
if (item.getInput() == 1 && autoThrow.isToggled()) {
mc.playerController.sendPacketDropItem(SlotHandler.getHeldItem());
}
if (lastSwitchTo != -1) {
if (lastDoneUse == -1) {
if (System.currentTimeMillis() - lastSwitchTo < startDelay.getInput()) return;
mc.playerController.sendUseItem(mc.thePlayer, mc.theWorld, SlotHandler.getHeldItem());
lastDoneUse = System.currentTimeMillis();
} else {
if (item.getInput() == 1 && autoThrow.isToggled()) {
mc.playerController.sendPacketDropItem(SlotHandler.getHeldItem());
}

lastSwitchTo = -1;
lastDoneUse = -1;
lastHeal = System.currentTimeMillis();
}
}
if (originalSlot != -1) {
SlotHandler.setCurrentSlot(originalSlot);
originalSlot = -1;
}

lastSwitchTo = -1;
lastDoneUse = -1;
lastHeal = System.currentTimeMillis();
}
}
}
}
}

0 comments on commit 0ac9d4c

Please sign in to comment.