mirror of
https://github.com/seppukudevelopment/seppuku
synced 2025-03-03 19:27:42 +00:00
Revert to latest AutoGap with spelling changes
This commit is contained in:
parent
9327d0c820
commit
ad7a2cc64c
@ -7,10 +7,12 @@ import me.rigamortis.seppuku.api.event.world.EventLoadWorld;
|
||||
import me.rigamortis.seppuku.api.module.Module;
|
||||
import me.rigamortis.seppuku.api.value.Value;
|
||||
import me.rigamortis.seppuku.impl.module.combat.AutoTotemModule;
|
||||
import me.rigamortis.seppuku.impl.module.combat.MultitaskModule;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
|
||||
|
||||
/**
|
||||
@ -20,11 +22,15 @@ public final class AutoGappleModule extends Module {
|
||||
|
||||
public final Value<Float> health = new Value<Float>("Health", new String[]{"Hp", "h"}, "The amount of health needed to acquire a notch apple", 15.0f, 0.0f, 20.0f, 0.5f);
|
||||
public final Value<Integer> forcedSlot = new Value<Integer>("Slot", new String[]{"s"}, "The hot-bar slot to put the notch apple into (45 for offhand)", 44, 0, 44, 1);
|
||||
public final Value<Boolean> enchantedOnly = new Value<Boolean>("EnchantedOnly", new String[]{"Enchanted", "Enchant", "EnchantOnly", "Notch", "NotchOnly", "NO", "EO"}, "Only allow enchanted golden apples to be used", true);
|
||||
|
||||
private int previousHeldItem = -1;
|
||||
private int notchAppleSlot = -1;
|
||||
private boolean activeMainHand;
|
||||
private boolean activeOffHand;
|
||||
|
||||
private AutoTotemModule autoTotemModule;
|
||||
private MultitaskModule multitaskModule;
|
||||
|
||||
public AutoGappleModule() {
|
||||
super("AutoGapple", new String[]{"Gapple", "AutoApple"}, "Automatically swaps & eats a (notch) apple when health is below the set threshold", "NONE", -1, ModuleType.PLAYER);
|
||||
@ -39,6 +45,7 @@ public final class AutoGappleModule extends Module {
|
||||
public void onLoadWorld(EventLoadWorld event) {
|
||||
if (event.getWorld() != null) {
|
||||
this.autoTotemModule = (AutoTotemModule) Seppuku.INSTANCE.getModuleManager().find(AutoTotemModule.class);
|
||||
this.multitaskModule = (MultitaskModule) Seppuku.INSTANCE.getModuleManager().find(MultitaskModule.class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,6 +69,9 @@ public final class AutoGappleModule extends Module {
|
||||
|
||||
if (mc.player.getHealth() < this.health.getValue() && mc.player.getAbsorptionAmount() == 0) {
|
||||
this.notchAppleSlot = this.findNotchApple();
|
||||
} else {
|
||||
this.setActiveMainHand(false);
|
||||
this.setActiveOffHand(false);
|
||||
}
|
||||
|
||||
if (this.notchAppleSlot != -1) {
|
||||
@ -71,15 +81,18 @@ public final class AutoGappleModule extends Module {
|
||||
}
|
||||
|
||||
if (this.notchAppleSlot < 36) {
|
||||
this.setActiveMainHand(true);
|
||||
mc.playerController.windowClick(0, this.forcedSlot.getValue(), 0, ClickType.QUICK_MOVE, mc.player); // last hotbar slot
|
||||
mc.playerController.windowClick(0, this.notchAppleSlot, 0, ClickType.PICKUP, mc.player);
|
||||
mc.playerController.windowClick(0, this.forcedSlot.getValue(), 0, ClickType.PICKUP, mc.player);
|
||||
mc.player.inventory.currentItem = this.forcedSlot.getValue() - 36;
|
||||
} else {
|
||||
this.setActiveMainHand(true);
|
||||
mc.player.inventory.currentItem = this.notchAppleSlot - 36; // in the hotbar, so remove the inventory offset
|
||||
}
|
||||
} else { // we need this notch apple in the offhand
|
||||
if (mc.player.getHeldItemOffhand().getItem() != Items.GOLDEN_APPLE) {
|
||||
this.setActiveOffHand(true);
|
||||
mc.playerController.windowClick(0, 45, 0, ClickType.QUICK_MOVE, mc.player); // offhand slot
|
||||
mc.playerController.windowClick(0, this.notchAppleSlot, 0, ClickType.PICKUP, mc.player);
|
||||
mc.playerController.windowClick(0, 45, 0, ClickType.PICKUP, mc.player);
|
||||
@ -87,23 +100,57 @@ public final class AutoGappleModule extends Module {
|
||||
}
|
||||
|
||||
if (mc.player.getHealth() >= this.health.getValue() && mc.player.getAbsorptionAmount() > 0) {
|
||||
mc.gameSettings.keyBindUseItem.pressed = false;
|
||||
if (this.previousHeldItem != -1) {
|
||||
mc.player.inventory.currentItem = this.previousHeldItem;
|
||||
}
|
||||
this.notchAppleSlot = -1;
|
||||
this.previousHeldItem = -1;
|
||||
this.stop();
|
||||
} else {
|
||||
mc.gameSettings.keyBindUseItem.pressed = true;
|
||||
if (this.forcedSlot.getValue() != 45) {
|
||||
this.setActiveMainHand(true);
|
||||
if (this.multitaskModule != null) {
|
||||
if (this.multitaskModule.isEnabled()) {
|
||||
mc.playerController.processRightClick(mc.player, mc.world, EnumHand.MAIN_HAND);
|
||||
} else {
|
||||
mc.gameSettings.keyBindUseItem.pressed = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.setActiveOffHand(true);
|
||||
if (this.multitaskModule != null) {
|
||||
if (this.multitaskModule.isEnabled()) {
|
||||
mc.playerController.processRightClick(mc.player, mc.world, EnumHand.OFF_HAND);
|
||||
} else {
|
||||
mc.gameSettings.keyBindUseItem.pressed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.multitaskModule == null) {
|
||||
mc.gameSettings.keyBindUseItem.pressed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
Minecraft.getMinecraft().gameSettings.keyBindUseItem.pressed = false;
|
||||
if (this.previousHeldItem != -1) {
|
||||
Minecraft.getMinecraft().player.inventory.currentItem = this.previousHeldItem;
|
||||
}
|
||||
this.notchAppleSlot = -1;
|
||||
this.previousHeldItem = -1;
|
||||
this.setActiveMainHand(false);
|
||||
this.setActiveOffHand(false);
|
||||
}
|
||||
|
||||
private int findNotchApple() {
|
||||
for (int slot = 44; slot > 8; slot--) {
|
||||
ItemStack itemStack = Minecraft.getMinecraft().player.inventoryContainer.getSlot(slot).getStack();
|
||||
if (itemStack.isEmpty() || itemStack.getItemDamage() == 0)
|
||||
if (itemStack.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.enchantedOnly.getValue()) {
|
||||
if (itemStack.getItemDamage() == 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemStack.getItem() == Items.GOLDEN_APPLE) {
|
||||
return slot;
|
||||
@ -120,11 +167,34 @@ public final class AutoGappleModule extends Module {
|
||||
|
||||
for (int i = 0; i < 45; i++) {
|
||||
final ItemStack stack = Minecraft.getMinecraft().player.inventory.getStackInSlot(i);
|
||||
if (stack.getItem() == Items.GOLDEN_APPLE && stack.getItemDamage() != 0) {
|
||||
gapples += stack.getCount();
|
||||
if (stack.getItem() != Items.GOLDEN_APPLE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.enchantedOnly.getValue()) {
|
||||
if (stack.getItemDamage() == 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
gapples += stack.getCount();
|
||||
}
|
||||
|
||||
return gapples;
|
||||
}
|
||||
|
||||
public boolean isActiveMainHand() {
|
||||
return activeMainHand;
|
||||
}
|
||||
|
||||
public void setActiveMainHand(boolean activeMainHand) {
|
||||
this.activeMainHand = activeMainHand;
|
||||
}
|
||||
|
||||
public boolean isActiveOffHand() {
|
||||
return activeOffHand;
|
||||
}
|
||||
|
||||
public void setActiveOffHand(boolean activeOffHand) {
|
||||
this.activeOffHand = activeOffHand;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user