Auto Soup

This commit is contained in:
ThebestkillerTBK
2022-10-13 16:46:41 +08:00
committed by Cloudburst
parent 97d42528bc
commit 5a7f7b4c25
4 changed files with 171 additions and 2 deletions

View File

@@ -38,6 +38,7 @@
- AutoCraft (More generalized version of [AutoBedCraft](https://github.com/Anticope/orion/blob/main/src/main/java/me/ghosttypes/orion/modules/main/AutoBedCraft.java) from orion) - AutoCraft (More generalized version of [AutoBedCraft](https://github.com/Anticope/orion/blob/main/src/main/java/me/ghosttypes/orion/modules/main/AutoBedCraft.java) from orion)
- AutoExtinguish - AutoExtinguish
- AutoPot (Taken from an [unmerged PR](https://github.com/MeteorDevelopment/meteor-client/pull/274)) - AutoPot (Taken from an [unmerged PR](https://github.com/MeteorDevelopment/meteor-client/pull/274))
- AutoSoup (Ported from [Wurst](https://github.com/Wurst-Imperium/Wurst7/tree))
- AutoTNT - AutoTNT
- AutoWither (Taken from an [unmerged PR](https://github.com/MeteorDevelopment/meteor-client/pull/1070)) - AutoWither (Taken from an [unmerged PR](https://github.com/MeteorDevelopment/meteor-client/pull/1070))
- BlockIn - BlockIn

View File

@@ -39,6 +39,7 @@ public class MeteorRejectsAddon extends MeteorAddon {
modules.add(new AutoCraft()); modules.add(new AutoCraft());
modules.add(new AutoExtinguish()); modules.add(new AutoExtinguish());
modules.add(new AutoPot()); modules.add(new AutoPot());
modules.add(new AutoSoup());
modules.add(new AutoTNT()); modules.add(new AutoTNT());
modules.add(new AutoWither()); modules.add(new AutoWither());
modules.add(new BoatGlitch()); modules.add(new BoatGlitch());

View File

@@ -0,0 +1,167 @@
package anticope.rejects.modules;
import anticope.rejects.MeteorRejectsAddon;
import meteordevelopment.meteorclient.events.world.TickEvent;
import meteordevelopment.meteorclient.settings.DoubleSetting;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.utils.player.InvUtils;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.block.Block;
import net.minecraft.block.BlockWithEntity;
import net.minecraft.block.CraftingTableBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.StewItem;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
public class AutoSoup extends Module {
private static final String desc = "Automatically eats soup when your health is low.\nNote: This hack ignores hunger and assumes that eating soup directly refills your health. If the server you are playing on is not configured to do that, use AutoEat instead.";
public AutoSoup() {
super(MeteorRejectsAddon.CATEGORY, "auto-soup", desc);
}
private final SettingGroup sgGeneral = settings.getDefaultGroup();
public final Setting<Double> health = sgGeneral.add(new DoubleSetting.Builder()
.name("health")
.description("Eats a soup when your health\n"
+ "reaches this value or falls below it.")
.defaultValue(6.5)
.min(0.5)
.sliderMin(0.5)
.sliderMax(9.5)
.build()
);
private int oldSlot = -1;
@Override
public void onDeactivate() {
stopIfEating();
}
@EventHandler
private void onTick(TickEvent.Post event) {
// sort empty bowls
for (int i = 0; i < 36; i++) {
// filter out non-bowl items and empty bowl slot
ItemStack stack = mc.player.getInventory().getStack(i);
if (stack == null || stack.getItem() != Items.BOWL || i == 9)
continue;
// check if empty bowl slot contains a non-bowl item
ItemStack emptyBowlStack = mc.player.getInventory().getStack(9);
boolean swap = !emptyBowlStack.isEmpty()
&& emptyBowlStack.getItem() != Items.BOWL;
// place bowl in empty bowl slot
InvUtils.click().slot(i < 9 ? 36 + i : i);
InvUtils.click().slot(9);
// place non-bowl item from empty bowl slot in current slot
if (swap)
InvUtils.click().slot(i < 9 ? 36 + i : i);
}
// search soup in hotbar
int soupInHotbar = findSoup(0, 9);
// check if any soup was found
if (soupInHotbar != -1) {
// check if player should eat soup
if (!shouldEatSoup()) {
stopIfEating();
return;
}
// save old slot
if (oldSlot == -1)
oldSlot = mc.player.getInventory().selectedSlot;
// set slot
mc.player.getInventory().selectedSlot = soupInHotbar;
// eat soup
mc.options.useKey.setPressed(true);
mc.interactionManager.interactItem(mc.player, Hand.MAIN_HAND);
return;
}
stopIfEating();
// search soup in inventory
int soupInInventory = findSoup(9, 36);
// move soup in inventory to hotbar
if (soupInInventory != -1)
InvUtils.quickMove().slot(soupInInventory);
}
private int findSoup(int startSlot, int endSlot) {
for (int i = startSlot; i < endSlot; i++) {
ItemStack stack = mc.player.getInventory().getStack(i);
if (stack != null && stack.getItem() instanceof StewItem)
return i;
}
return -1;
}
private boolean shouldEatSoup() {
// check health
if (mc.player.getHealth() > health.get() * 2F)
return false;
// check for clickable objects
return !isClickable(mc.crosshairTarget);
}
private boolean isClickable(HitResult hitResult) {
if (hitResult == null)
return false;
if (hitResult instanceof EntityHitResult) {
Entity entity = ((EntityHitResult) mc.crosshairTarget).getEntity();
return entity instanceof VillagerEntity
|| entity instanceof TameableEntity;
}
if (hitResult instanceof BlockHitResult) {
BlockPos pos = ((BlockHitResult) mc.crosshairTarget).getBlockPos();
if (pos == null)
return false;
Block block = mc.world.getBlockState(pos).getBlock();
return block instanceof BlockWithEntity
|| block instanceof CraftingTableBlock;
}
return false;
}
private void stopIfEating() {
// check if eating
if (oldSlot == -1)
return;
// stop eating
mc.options.useKey.setPressed(false);
// reset slot
mc.player.getInventory().selectedSlot = oldSlot;
oldSlot = -1;
}
}

View File

@@ -19,7 +19,7 @@ public class ItemGenerator extends Module {
private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgGeneral = settings.getDefaultGroup();
private final Setting<Integer> speed = sgGeneral.add(new IntSetting.Builder() private final Setting<Integer> speed = sgGeneral.add(new IntSetting.Builder()
.name("speed") .name("speed")
.description("\u00a74\u00a7lWARNING:\u00a7r High speeds will cause a ton\n" .description("WARNING: High speeds will cause a ton\n"
+ "of lag and can easily crash the game!") + "of lag and can easily crash the game!")
.defaultValue(1) .defaultValue(1)
.min(1) .min(1)
@@ -42,7 +42,7 @@ public class ItemGenerator extends Module {
private final Random random = Random.create(); private final Random random = Random.create();
public ItemGenerator() { public ItemGenerator() {
super(MeteorRejectsAddon.CATEGORY, "item-generator", "Spawns a lot of unwanted items"); super(MeteorRejectsAddon.CATEGORY, "item-generator", "Generates random items and drops them on the ground.\nCreative mode only.");
} }
@Override @Override