Skip to content

Commit

Permalink
Make Baritone optional and not bundled with Meteor
Browse files Browse the repository at this point in the history
  • Loading branch information
MineGame159 committed Oct 18, 2023
1 parent 1b705d1 commit b3f82ab
Show file tree
Hide file tree
Showing 28 changed files with 562 additions and 221 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ dependencies {
modCompileOnly("maven.modrinth:indium:${project.indium_version}") { transitive = false }

// Baritone (https://github.com/MeteorDevelopment/baritone)
modInclude "baritone:fabric:${project.minecraft_version}-SNAPSHOT"
modCompileOnly "baritone:fabric:${project.minecraft_version}-SNAPSHOT"

// Libraries
library "meteordevelopment:orbit:${project.orbit_version}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import meteordevelopment.meteorclient.commands.commands.*;
import meteordevelopment.meteorclient.pathing.BaritoneUtils;
import meteordevelopment.meteorclient.pathing.PathManagers;
import meteordevelopment.meteorclient.utils.PostInit;
import net.minecraft.client.network.ClientCommandSource;
import net.minecraft.command.CommandSource;
Expand All @@ -23,7 +25,7 @@ public class Commands {
public static final CommandSource COMMAND_SOURCE = new ClientCommandSource(null, mc);
public static final List<Command> COMMANDS = new ArrayList<>();

@PostInit
@PostInit(dependencies = PathManagers.class)
public static void init() {
add(new VClipCommand());
add(new HClipCommand());
Expand All @@ -35,7 +37,6 @@ public static void init() {
add(new FriendsCommand());
add(new CommandsCommand());
add(new InventoryCommand());
add(new LocateCommand());
add(new NbtCommand());
add(new NotebotCommand());
add(new PeekCommand());
Expand All @@ -62,6 +63,10 @@ public static void init() {
add(new WaypointCommand());
add(new InputCommand());

if (BaritoneUtils.IS_AVAILABLE) {
add(new LocateCommand());
}

COMMANDS.sort(Comparator.comparing(Command::getName));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.commands.Command;
import meteordevelopment.meteorclient.events.packets.PacketEvent;
import meteordevelopment.meteorclient.pathing.PathManagers;
import meteordevelopment.meteorclient.utils.player.ChatUtils;
import meteordevelopment.meteorclient.utils.player.InvUtils;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EyeOfEnderEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
Expand Down Expand Up @@ -146,7 +148,7 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
boolean foundEye = InvUtils.testInHotbar(Items.ENDER_EYE);

if (foundEye) {
BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("follow entity minecraft:eye_of_ender");
PathManagers.get().follow(entity -> entity instanceof EyeOfEnderEntity);
firstStart = null;
firstEnd = null;
secondStart = null;
Expand Down Expand Up @@ -271,7 +273,8 @@ private void lastPosition(double x, double y, double z) {
}

private void findStronghold() {
BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("stop");
PathManagers.get().stop();

if (this.firstStart == null || this.firstEnd == null || this.secondStart == null || this.secondEnd == null) {
error("Missing position data");
cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

package meteordevelopment.meteorclient.commands.commands;

import baritone.api.BaritoneAPI;
import baritone.api.pathing.goals.GoalXZ;
import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
Expand All @@ -15,6 +13,7 @@
import meteordevelopment.meteorclient.commands.Command;
import meteordevelopment.meteorclient.commands.arguments.ModuleArgumentType;
import meteordevelopment.meteorclient.commands.arguments.PlayerArgumentType;
import meteordevelopment.meteorclient.pathing.PathManagers;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.misc.swarm.Swarm;
Expand All @@ -27,6 +26,7 @@
import net.minecraft.command.argument.BlockStateArgumentType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;

import java.util.List;
import java.util.Random;
Expand Down Expand Up @@ -124,7 +124,7 @@ else if (swarm.isWorker()) {
swarm.host.sendMessage(context.getInput());
}
else if (swarm.isWorker() && playerEntity != null) {
BaritoneAPI.getProvider().getPrimaryBaritone().getFollowProcess().follow(entity -> entity.getEntityName().equalsIgnoreCase(playerEntity.getEntityName()));
PathManagers.get().follow(entity -> entity.getEntityName().equalsIgnoreCase(playerEntity.getEntityName()));
}
}
else {
Expand All @@ -146,7 +146,7 @@ else if (swarm.isWorker()) {
int x = IntegerArgumentType.getInteger(context, "x");
int z = IntegerArgumentType.getInteger(context, "z");

BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(x, z));
PathManagers.get().moveTo(new BlockPos(x, 0, z), true);
}
}
else {
Expand Down Expand Up @@ -330,7 +330,7 @@ else if (swarm.isWorker()) {
if (swarm.isHost()) {
swarm.host.sendMessage(context.getInput());
} else if (swarm.isWorker()) {
BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything();
PathManagers.get().stop();
}
} else {
throw SWARM_NOT_ACTIVE.create();
Expand Down Expand Up @@ -362,11 +362,13 @@ private void runInfinityMiner() {

private void scatter(int radius) {
Random random = new Random();

double a = random.nextDouble() * 2 * Math.PI;
double r = radius * Math.sqrt(random.nextDouble());
double x = mc.player.getX() + r * Math.cos(a);
double z = mc.player.getZ() + r * Math.sin(a);
BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything();
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ((int) x, (int) z));

PathManagers.get().stop();
PathManagers.get().moveTo(new BlockPos((int) x, 0, (int) z), true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
package meteordevelopment.meteorclient.gui.tabs;

import meteordevelopment.meteorclient.gui.tabs.builtin.*;
import meteordevelopment.meteorclient.pathing.BaritoneUtils;
import meteordevelopment.meteorclient.pathing.PathManagers;
import meteordevelopment.meteorclient.utils.PreInit;

import java.util.ArrayList;
Expand All @@ -14,7 +16,7 @@
public class Tabs {
private static final List<Tab> tabs = new ArrayList<>();

@PreInit
@PreInit(dependencies = PathManagers.class)
public static void init() {
add(new ModulesTab());
add(new ConfigTab());
Expand All @@ -23,7 +25,10 @@ public static void init() {
add(new FriendsTab());
add(new MacrosTab());
add(new ProfilesTab());
add(new BaritoneTab());

if (BaritoneUtils.IS_AVAILABLE) {
add(new BaritoneTab());
}
}

public static void add(Tab tab) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import meteordevelopment.meteorclient.events.packets.PlaySoundPacketEvent;
import meteordevelopment.meteorclient.events.world.ChunkDataEvent;
import meteordevelopment.meteorclient.mixininterface.IExplosionS2CPacket;
import meteordevelopment.meteorclient.pathing.BaritoneUtils;
import meteordevelopment.meteorclient.systems.config.Config;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.movement.Velocity;
Expand Down Expand Up @@ -140,7 +141,7 @@ private void onItemPickupAnimation(ItemPickupAnimationS2CPacket packet, Callback
private void onSendChatMessage(String message, CallbackInfo ci) {
if (ignoreChatMessage) return;

if (!message.startsWith(Config.get().prefix.get()) && !message.startsWith(BaritoneAPI.getSettings().prefix.value)) {
if (!message.startsWith(Config.get().prefix.get()) && (BaritoneUtils.IS_AVAILABLE || !message.startsWith(BaritoneUtils.getPrefix()))) {
SendMessageEvent event = MeteorClient.EVENT_BUS.post(SendMessageEvent.get(message));

if (!event.isCancelled()) {
Expand Down
Loading

0 comments on commit b3f82ab

Please sign in to comment.