Skip to content

Commit c370261

Browse files
authored
Updated Autopot to work with Ominous Bottle (#512)
1 parent 6caa886 commit c370261

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

src/main/java/anticope/rejects/modules/AutoPot.java

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import anticope.rejects.MeteorRejectsAddon;
66
import baritone.api.BaritoneAPI;
7+
import java.util.ArrayList;
8+
import java.util.List;
79
import meteordevelopment.meteorclient.events.entity.player.ItemUseCrosshairTargetEvent;
810
import meteordevelopment.meteorclient.events.world.TickEvent;
911
import meteordevelopment.meteorclient.settings.*;
@@ -25,8 +27,6 @@
2527
import net.minecraft.world.item.ItemStack;
2628
import net.minecraft.world.item.Items;
2729
import net.minecraft.world.item.alchemy.PotionContents;
28-
import java.util.ArrayList;
29-
import java.util.List;
3030

3131
public class AutoPot extends Module {
3232
@SuppressWarnings("unchecked")
@@ -39,7 +39,8 @@ public class AutoPot extends Module {
3939
.description("The potions to use.")
4040
.defaultValue(
4141
MobEffects.INSTANT_HEALTH.value(),
42-
MobEffects.STRENGTH.value()
42+
MobEffects.STRENGTH.value(),
43+
MobEffects.BAD_OMEN.value()
4344
)
4445
.build()
4546
);
@@ -176,23 +177,36 @@ private int potionSlot(MobEffect statusEffect) {
176177
for (int i = 0; i < 9; i++) {
177178
ItemStack stack = mc.player.getInventory().getItem(i);
178179
if (stack.isEmpty()) continue;
179-
if (stack.getItem() == Items.POTION || (stack.getItem() == Items.SPLASH_POTION && useSplashPots.get())) {
180-
PotionContents effects = stack.getComponents().getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY);
181-
for (MobEffectInstance effectInstance : effects.getAllEffects()) {
182-
if (effectInstance.getDescriptionId().equals(statusEffect.getDescriptionId())) {
183-
slot = i;
184-
break;
185-
}
180+
if (isOminousBottle(stack)) {
181+
if (statusEffect == MobEffects.BAD_OMEN.value()) {
182+
slot = i;
183+
break;
186184
}
185+
continue;
187186
}
187+
188+
boolean isPotion = stack.getItem() == Items.POTION;
189+
boolean isSplashPotion = stack.getItem() == Items.SPLASH_POTION;
190+
if (!isPotion && !(isSplashPotion && useSplashPots.get())) continue;
191+
192+
PotionContents effects = stack.getComponents().getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY);
193+
for (MobEffectInstance effectInstance : effects.getAllEffects()) {
194+
if (effectInstance.getDescriptionId().equals(statusEffect.getDescriptionId())) {
195+
slot = i;
196+
break;
197+
}
198+
}
199+
if (slot != -1) break;
188200
}
189201
return slot;
190202
}
191203

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

195-
if (useSplashPots.get()) {
207+
ItemStack stack = mc.player.getInventory().getItem(slot);
208+
boolean isSplashPotion = stack.getItem() == Items.SPLASH_POTION;
209+
if (isSplashPotion && useSplashPots.get()) {
196210
if (lookDown.get()) {
197211
Rotations.rotate(mc.player.getYRot(), 90);
198212
splash();
@@ -220,6 +234,10 @@ private void startPotionUse() {
220234
}
221235
}
222236

237+
private boolean isOminousBottle(ItemStack stack) {
238+
return stack.getItem() == Items.OMINOUS_BOTTLE;
239+
}
240+
223241
private boolean ShouldDrinkHealth() {
224242
return trueHealth() < health.get();
225243
}

0 commit comments

Comments
 (0)