Improve CrystalAura, AutoGapple, AutoTotem

This commit is contained in:
noil 2021-01-15 14:17:10 -05:00
parent 4985694ba0
commit 1e18c8fbbe
3 changed files with 57 additions and 12 deletions

View File

@ -18,7 +18,8 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
*/
public final class AutoTotemModule extends Module {
public final Value<Float> health = new Value("Health", new String[]{"Hp"}, "The amount of health needed to acquire a totem.", 16.0f, 0.0f, 20.0f, 0.5f);
public final Value<Float> 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<Boolean> crystals = new Value<>("Crystals", new String[]{"cry", "c"}, "Go back to crystals in offhand after health is replenished.", false);
public AutoTotemModule() {
super("AutoTotem", new String[]{"Totem"}, "Automatically places a totem of undying in your offhand", "NONE", -1, ModuleType.COMBAT);
@ -35,19 +36,32 @@ public final class AutoTotemModule extends Module {
final Minecraft mc = Minecraft.getMinecraft();
if (mc.currentScreen == null || mc.currentScreen instanceof GuiInventory) {
if (mc.player.getHealth() <= this.health.getValue()) {
final ItemStack offHand = mc.player.getHeldItemOffhand();
final ItemStack offHand = mc.player.getHeldItemOffhand();
if (mc.player.getHealth() <= this.health.getValue()) {
if (offHand.getItem() == Items.TOTEM_OF_UNDYING) {
return;
}
final int slot = this.getTotemSlot();
final int totemSlot = this.getTotemSlot();
if (slot != -1) {
mc.playerController.windowClick(mc.player.inventoryContainer.windowId, slot, 0, ClickType.PICKUP, mc.player);
if (totemSlot != -1) {
mc.playerController.windowClick(mc.player.inventoryContainer.windowId, totemSlot, 0, ClickType.PICKUP, mc.player);
mc.playerController.windowClick(mc.player.inventoryContainer.windowId, 45, 0, ClickType.PICKUP, mc.player);
mc.playerController.windowClick(mc.player.inventoryContainer.windowId, slot, 0, ClickType.PICKUP, mc.player);
mc.playerController.windowClick(mc.player.inventoryContainer.windowId, totemSlot, 0, ClickType.PICKUP, mc.player);
mc.playerController.updateController();
}
} else if (this.crystals.getValue()) {
if (offHand.getItem() == Items.END_CRYSTAL) {
return;
}
final int crystalSlot = this.getCrystalSlot();
if (crystalSlot != -1) {
mc.playerController.windowClick(mc.player.inventoryContainer.windowId, crystalSlot, 0, ClickType.PICKUP, mc.player);
mc.playerController.windowClick(mc.player.inventoryContainer.windowId, 45, 0, ClickType.PICKUP, mc.player);
mc.playerController.windowClick(mc.player.inventoryContainer.windowId, crystalSlot, 0, ClickType.PICKUP, mc.player);
mc.playerController.updateController();
}
}
@ -55,6 +69,19 @@ public final class AutoTotemModule extends Module {
}
}
private int getCrystalSlot() {
for (int i = 0; i < 36; i++) {
final Item item = Minecraft.getMinecraft().player.inventory.getStackInSlot(i).getItem();
if (item == Items.END_CRYSTAL) {
if (i < 9) {
i += 36;
}
return i;
}
}
return -1;
}
private int getTotemSlot() {
for (int i = 0; i < 36; i++) {
final Item item = Minecraft.getMinecraft().player.inventory.getStackInSlot(i).getItem();
@ -68,7 +95,7 @@ public final class AutoTotemModule extends Module {
return -1;
}
private int getTotemCount() {
public int getTotemCount() {
int totems = 0;
if (Minecraft.getMinecraft().player == null)

View File

@ -318,10 +318,7 @@ public final class CrystalAuraModule extends Module {
private float scaleExplosionDamage(EntityLivingBase entity, Explosion explosion, float damage) {
damage = CombatRules.getDamageAfterAbsorb(damage, (float) entity.getTotalArmorValue(), (float) entity.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).getAttributeValue());
damage *= (1.0F - MathHelper.clamp(EnchantmentHelper.getEnchantmentModifierDamage(entity.getArmorInventoryList(), DamageSource.causeExplosionDamage(explosion)), 0.0F, 20.0F) / 25.0F);
damage = Math.max(damage - entity.getAbsorptionAmount(), 0.0F);
return damage;
}

View File

@ -1,9 +1,12 @@
package me.rigamortis.seppuku.impl.module.player;
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.combat.AutoTotemModule;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Items;
import net.minecraft.inventory.ClickType;
@ -15,12 +18,14 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
*/
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.", 8.0f, 0.0f, 20.0f, 0.5f);
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);
private int previousHeldItem = -1;
private int notchAppleSlot = -1;
private AutoTotemModule autoTotemModule;
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);
}
@ -30,6 +35,13 @@ public final class AutoGappleModule extends Module {
return "" + this.getNotchAppleCount();
}
@Listener
public void onLoadWorld(EventLoadWorld event) {
if (event.getWorld() != null) {
this.autoTotemModule = (AutoTotemModule) Seppuku.INSTANCE.getModuleManager().find(AutoTotemModule.class);
}
}
@Listener
public void onPlayerUpdate(EventPlayerUpdate event) {
if (event.getStage() != EventStageable.EventStage.PRE)
@ -39,6 +51,15 @@ public final class AutoGappleModule extends Module {
if (mc.player == null)
return;
if (this.autoTotemModule != null) {
if (this.autoTotemModule.isEnabled()) {
if (this.autoTotemModule.getTotemCount() > 0) {
if (mc.player.getHealth() <= this.autoTotemModule.health.getValue() && !mc.player.getHeldItemOffhand().getItem().equals(Items.TOTEM_OF_UNDYING))
return;
}
}
}
if (mc.player.getHealth() < this.health.getValue() && mc.player.getAbsorptionAmount() == 0) {
this.notchAppleSlot = this.findNotchApple();
}