diff --git a/build.gradle b/build.gradle index 41d3ea6..0d5b062 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ apply plugin: 'net.minecraftforge.gradle.forge' apply plugin: "com.github.johnrengelman.shadow" -version = "3.1.7" +version = "3.1.8" group = "me.rigamortis" archivesBaseName = "seppuku" def buildmode = "IDE" diff --git a/src/main/java/me/rigamortis/seppuku/api/task/hand/HandSwapContext.java b/src/main/java/me/rigamortis/seppuku/api/task/hand/HandSwapContext.java index 991e2f7..0a93fc1 100644 --- a/src/main/java/me/rigamortis/seppuku/api/task/hand/HandSwapContext.java +++ b/src/main/java/me/rigamortis/seppuku/api/task/hand/HandSwapContext.java @@ -6,10 +6,10 @@ import net.minecraft.client.Minecraft; * @author Daniel E */ public final class HandSwapContext { - private final int oldSlot; - private final int newSlot; + private int oldSlot; + private int newSlot; - public HandSwapContext(final int oldSlot, final int newSlot) { + public HandSwapContext(int oldSlot, int newSlot) { this.oldSlot = oldSlot; this.newSlot = newSlot; } @@ -22,6 +22,14 @@ public final class HandSwapContext { return newSlot; } + public void setOldSlot(int oldSlot) { + this.oldSlot = oldSlot; + } + + public void setNewSlot(int newSlot) { + this.newSlot = newSlot; + } + public void handleHandSwap(final boolean restore, final Minecraft minecraft) { minecraft.player.inventory.currentItem = diff --git a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/BattleInfoComponent.java b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/BattleInfoComponent.java index be2c29b..efd82fc 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/BattleInfoComponent.java +++ b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/BattleInfoComponent.java @@ -31,7 +31,7 @@ public final class BattleInfoComponent extends DraggableHudComponent { this.setW(117); this.setH(48); - this.donorsTexture = new Texture("seppuku_sky.jpg"); + this.donorsTexture = new Texture("john.jpg"); } @Override diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/combat/AutoTotemModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/combat/AutoTotemModule.java index 1c320eb..edbe72f 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/combat/AutoTotemModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/combat/AutoTotemModule.java @@ -1,9 +1,12 @@ package me.rigamortis.seppuku.impl.module.combat; +import me.rigamortis.seppuku.Seppuku; import me.rigamortis.seppuku.api.event.EventStageable; import me.rigamortis.seppuku.api.event.player.EventPlayerUpdate; +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.player.AutoGappleModule; import net.minecraft.client.Minecraft; import net.minecraft.init.Items; import net.minecraft.inventory.ClickType; @@ -19,12 +22,22 @@ public final class AutoTotemModule extends Module { public final Value health = new Value<>("Health", new String[]{"Hp", "h"}, "The amount of health needed to acquire a totem.", 7.0f, 0.0f, 20.0f, 0.5f); public final Value crystals = new Value<>("Crystals", new String[]{"cry", "c"}, "Go back to crystals in offhand after health is replenished.", false); + //public final Value force = new Value<>("Force", new String[]{"f"}, "Prioritize AutoTotem over AutoGapple, etc.", true); public final Value checkScreen = new Value<>("CheckScreen", new String[]{"screen", "check", "cs"}, "Checks if a screen is not opened to begin (usually disabled).", false); + private AutoGappleModule autoGappleModule; + public AutoTotemModule() { super("AutoTotem", new String[]{"Totem"}, "Automatically places a totem of undying in your offhand", "NONE", -1, ModuleType.COMBAT); } + @Listener + public void onLoadWorld(EventLoadWorld event) { + if (event.getWorld() != null) { + this.autoGappleModule = (AutoGappleModule) Seppuku.INSTANCE.getModuleManager().find(AutoGappleModule.class); + } + } + @Override public String getMetaData() { return "" + this.getTotemCount(); @@ -57,6 +70,14 @@ public final class AutoTotemModule extends Module { } } else { if (mc.player.getHealth() > this.health.getValue() && this.crystals.getValue()) { + if (this.autoGappleModule != null) { + if (this.autoGappleModule.isEnabled()) { + if (this.autoGappleModule.isActiveOffHand()) { + return; + } + } + } + if (offHand.getItem() == Items.END_CRYSTAL) { return; } diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/player/AutoGappleModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/player/AutoGappleModule.java index 1421a77..09aebe3 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/player/AutoGappleModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/player/AutoGappleModule.java @@ -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 health = new Value("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 forcedSlot = new Value("Slot", new String[]{"s"}, "The hot-bar slot to put the notch apple into. (45 for offhand)", 44, 0, 44, 1); + public final Value enchantedOnly = new Value("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; + } } diff --git a/src/main/resources/assets/seppukumod/textures/john.jpg b/src/main/resources/assets/seppukumod/textures/john.jpg new file mode 100644 index 0000000..aace332 Binary files /dev/null and b/src/main/resources/assets/seppukumod/textures/john.jpg differ