Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions src/main/java/anticope/rejects/modules/AutoPot.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import anticope.rejects.MeteorRejectsAddon;
import baritone.api.BaritoneAPI;
import java.util.ArrayList;
import java.util.List;
import meteordevelopment.meteorclient.events.entity.player.ItemUseCrosshairTargetEvent;
import meteordevelopment.meteorclient.events.world.TickEvent;
import meteordevelopment.meteorclient.settings.*;
Expand All @@ -25,8 +27,6 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.alchemy.PotionContents;
import java.util.ArrayList;
import java.util.List;

public class AutoPot extends Module {
@SuppressWarnings("unchecked")
Expand All @@ -39,7 +39,8 @@ public class AutoPot extends Module {
.description("The potions to use.")
.defaultValue(
MobEffects.INSTANT_HEALTH.value(),
MobEffects.STRENGTH.value()
MobEffects.STRENGTH.value(),
MobEffects.BAD_OMEN.value()
)
.build()
);
Expand Down Expand Up @@ -176,23 +177,36 @@ private int potionSlot(MobEffect statusEffect) {
for (int i = 0; i < 9; i++) {
ItemStack stack = mc.player.getInventory().getItem(i);
if (stack.isEmpty()) continue;
if (stack.getItem() == Items.POTION || (stack.getItem() == Items.SPLASH_POTION && useSplashPots.get())) {
PotionContents effects = stack.getComponents().getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY);
for (MobEffectInstance effectInstance : effects.getAllEffects()) {
if (effectInstance.getDescriptionId().equals(statusEffect.getDescriptionId())) {
slot = i;
break;
}
if (isOminousBottle(stack)) {
if (statusEffect == MobEffects.BAD_OMEN.value()) {
slot = i;
break;
}
continue;
}

boolean isPotion = stack.getItem() == Items.POTION;
boolean isSplashPotion = stack.getItem() == Items.SPLASH_POTION;
if (!isPotion && !(isSplashPotion && useSplashPots.get())) continue;

PotionContents effects = stack.getComponents().getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY);
for (MobEffectInstance effectInstance : effects.getAllEffects()) {
if (effectInstance.getDescriptionId().equals(statusEffect.getDescriptionId())) {
slot = i;
break;
}
}
if (slot != -1) break;
}
return slot;
}

private void startPotionUse() {
prevSlot = mc.player.getInventory().getSelectedSlot();

if (useSplashPots.get()) {
ItemStack stack = mc.player.getInventory().getItem(slot);
boolean isSplashPotion = stack.getItem() == Items.SPLASH_POTION;
if (isSplashPotion && useSplashPots.get()) {
if (lookDown.get()) {
Rotations.rotate(mc.player.getYRot(), 90);
splash();
Expand Down Expand Up @@ -220,6 +234,10 @@ private void startPotionUse() {
}
}

private boolean isOminousBottle(ItemStack stack) {
return stack.getItem() == Items.OMINOUS_BOTTLE;
}

private boolean ShouldDrinkHealth() {
return trueHealth() < health.get();
}
Expand Down
Loading