forked from RepoMirrors/seppuku
Refactor AutoGapple because im one blind fuck
This commit is contained in:
parent
e1786bf150
commit
7a8e426a88
|
@ -144,7 +144,6 @@ public final class ModuleManager {
|
|||
add(new LogoutSpotsModule());
|
||||
add(new ChatSuffixModule());
|
||||
add(new VisualRangeModule());
|
||||
add(new AutoGappleModule());
|
||||
|
||||
this.loadExternalModules();
|
||||
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
package me.rigamortis.seppuku.impl.module.combat;
|
||||
|
||||
import me.rigamortis.seppuku.api.event.player.EventUpdateWalkingPlayer;
|
||||
import me.rigamortis.seppuku.api.module.Module;
|
||||
import me.rigamortis.seppuku.api.util.Timer;
|
||||
import me.rigamortis.seppuku.api.value.Value;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
|
||||
|
||||
/**
|
||||
* @author jvyden420
|
||||
* 9/4/2019 @ 3:51 PM.
|
||||
*/
|
||||
|
||||
public final class AutoGappleModule extends Module {
|
||||
public final Value<Mode> mode = new Value<Mode>("Mode", new String[]{"Mode", "M"}, "The AutoGapple mode to use. Absorption is based off of how many absorption hearts you have, where as once will eat one gapple then return to whatever you were doing.", Mode.ONCE);
|
||||
public final Value<Integer> absorption = new Value<Integer>("AbsorptionThreshold", new String[]{"absorption", "a"}, "The threshold to eat a gapple in absorption mode. 1 = 0.5 hearts.", 8, 0, 16, 1);
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
private boolean eatingGapple = false;
|
||||
private int lastSlot = -1;
|
||||
private Timer timer = new Timer();
|
||||
public AutoGappleModule() {
|
||||
super("AutoGapple", new String[]{"AutoEat", "SilentGapple", "Gapple", "Eat", "EatGapple"}, "Automatically eats gapples for you", "NONE", -1, ModuleType.COMBAT);
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onWalkingUpdate(EventUpdateWalkingPlayer event) {
|
||||
// wait 50ms because isHandActive() doesn't update immediately
|
||||
// should be optimised since there's no way in hell you're eating something within 50ms
|
||||
if(eatingGapple && !mc.player.isHandActive() && timer.passed(50)) {
|
||||
if(lastSlot != -1) mc.player.inventory.currentItem = lastSlot;
|
||||
eatingGapple = false;
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false);
|
||||
if (mode.getValue() == Mode.ONCE) this.toggle();
|
||||
return;
|
||||
}
|
||||
if(eatingGapple) return;
|
||||
// Max: 16
|
||||
if(mode.getValue() == Mode.ONCE || (mode.getValue() == Mode.ABSORPTION && mc.player.getAbsorptionAmount() < absorption.getValue())) {
|
||||
lastSlot = mc.player.inventory.currentItem;
|
||||
final Item gapple = Item.getByNameOrId("GOLDEN_APPLE");
|
||||
final int slot = findStackHotbar(new ItemStack(gapple));
|
||||
if(slot != -1) {
|
||||
mc.player.inventory.currentItem = slot;
|
||||
mc.playerController.updateController();
|
||||
}
|
||||
if (hasStack(gapple)) {
|
||||
eatingGapple = true;
|
||||
// TODO: do this through a packet so we can do other things while we eat, possibly?
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), true);
|
||||
timer.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int findStackHotbar(ItemStack type) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
final ItemStack stack = Minecraft.getMinecraft().player.inventory.getStackInSlot(i);
|
||||
if(stack.getItem() == Items.GOLDEN_APPLE) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private boolean slotEqualsBlock (int slot, Block type) {
|
||||
if (mc.player.inventory.getStackInSlot(slot).getItem() instanceof ItemBlock) {
|
||||
final ItemBlock block = (ItemBlock) mc.player.inventory.getStackInSlot(slot).getItem();
|
||||
return block.getBlock() == type;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean hasStack(Item type) {
|
||||
if (mc.player.inventory.getCurrentItem().getItem() instanceof Item) {
|
||||
final Item item = (Item) mc.player.inventory.getCurrentItem().getItem();
|
||||
return item == type;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private enum Mode {
|
||||
ONCE, ABSORPTION
|
||||
}
|
||||
}
|
|
@ -18,16 +18,15 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
|
|||
*/
|
||||
public final class RegenModule extends Module {
|
||||
|
||||
public final Value<Mode> mode = new Value("Mode", new String[]{"Mode", "M"}, "The regen mode to use.", Mode.GAPPLE);
|
||||
|
||||
public final Value<Float> health = new Value("Health", new String[]{"Hp"}, "The minimum health required to heal.", 8.0f, 0.0f, 20.0f, 0.5f);
|
||||
|
||||
public final Value<Boolean> refill = new Value("Refill", new String[]{"ref"}, "Automatically refill the hotbar with gapples.", true);
|
||||
public final Value<Mode> mode = new Value<Mode>("Mode", new String[]{"Mode", "M"}, "The regen mode to use.", Mode.GAPPLE);
|
||||
public final Value<Float> health = new Value<Float>("Health", new String[]{"hp", "absorption"}, "The minimum health required to heal.", 8.0f, 0.0f, 20.0f, 0.5f);
|
||||
public final Value<Boolean> refill = new Value<Boolean>("Refill", new String[]{"ref"}, "Automatically refill the hotbar with gapples.", true);
|
||||
public final Value<Boolean> once = new Value<Boolean>("Once", new String[]{"o", "once"}, "Consume only 1 item, then toggle off", false);
|
||||
|
||||
private int gappleSlot = -1;
|
||||
|
||||
public RegenModule() {
|
||||
super("Regen", new String[]{"AutoHeal"}, "Automatically heals you once your health is low enough", "NONE", -1, ModuleType.COMBAT);
|
||||
super("Regen", new String[]{"AutoHeal", "AutoEat", "AutoGapple"}, "Automatically heals you once your health is low enough", "NONE", -1, ModuleType.COMBAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,6 +68,7 @@ public final class RegenModule extends Module {
|
|||
if (mc.player.getAbsorptionAmount() > 0) {
|
||||
mc.gameSettings.keyBindUseItem.pressed = false;
|
||||
gappleSlot = -1;
|
||||
if(this.once.getValue()) this.toggle();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -76,7 +76,7 @@ public final class RegenModule extends Module {
|
|||
if (this.refill.getValue()) {
|
||||
final int invSlot = findStackInventory(Items.GOLDEN_APPLE);
|
||||
if (invSlot != -1) {
|
||||
final int empty = findEmptyhotbar();
|
||||
final int empty = findEmptyHotbar();
|
||||
mc.playerController.windowClick(mc.player.inventoryContainer.windowId, invSlot, empty == -1 ? mc.player.inventory.currentItem : empty, ClickType.SWAP, mc.player);
|
||||
mc.playerController.updateController();
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public final class RegenModule extends Module {
|
|||
return -1;
|
||||
}
|
||||
|
||||
private int findEmptyhotbar() {
|
||||
private int findEmptyHotbar() {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
final ItemStack stack = Minecraft.getMinecraft().player.inventory.getStackInSlot(i);
|
||||
|
||||
|
|
Loading…
Reference in New Issue