Skip to content

Commit

Permalink
Make Baritone optional and not bundled with Meteor (#4155)
Browse files Browse the repository at this point in the history
  • Loading branch information
MineGame159 authored Oct 22, 2023
1 parent 3fb57b6 commit 6576056
Show file tree
Hide file tree
Showing 30 changed files with 735 additions and 287 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 "meteordevelopment:baritone:${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,7 @@
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import meteordevelopment.meteorclient.commands.commands.*;
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 +24,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 +36,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 @@ -61,6 +61,7 @@ public static void init() {
add(new RotationCommand());
add(new WaypointCommand());
add(new InputCommand());
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,16 @@
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.commands.Command;
import meteordevelopment.meteorclient.events.packets.PacketEvent;
import meteordevelopment.meteorclient.pathing.BaritoneUtils;
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 @@ -143,10 +146,15 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
}));

builder.then(literal("stronghold").executes(s -> {
if (!BaritoneUtils.IS_AVAILABLE) {
error("Locating this structure requires Baritone.");
return SINGLE_SUCCESS;
}

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 All @@ -168,6 +176,11 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
}));

builder.then(literal("nether_fortress").executes(s -> {
if (!BaritoneUtils.IS_AVAILABLE) {
error("Locating this structure requires Baritone.");
return SINGLE_SUCCESS;
}

Vec3d coords = findByBlockList(netherFortressBlocks);
if (coords == null) {
error("No nether fortress found.");
Expand All @@ -181,6 +194,11 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
}));

builder.then(literal("monument").executes(s -> {
if (!BaritoneUtils.IS_AVAILABLE) {
error("Locating this structure requires Baritone.");
return SINGLE_SUCCESS;
}

ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() == Items.FILLED_MAP) {
NbtCompound tag = stack.getNbt();
Expand Down Expand Up @@ -271,7 +289,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 (PathManagers.get().getSettings().get().sizeGroups() > 0) {
add(new PathManagerTab());
}
}

public static void add(Tab tab) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.gui.tabs.builtin;

import baritone.api.BaritoneAPI;
import baritone.api.utils.SettingsUtil;
import meteordevelopment.meteorclient.gui.GuiTheme;
import meteordevelopment.meteorclient.gui.tabs.Tab;
import meteordevelopment.meteorclient.gui.tabs.TabScreen;
import meteordevelopment.meteorclient.gui.tabs.WindowTabScreen;
import meteordevelopment.meteorclient.gui.widgets.input.WTextBox;
import meteordevelopment.meteorclient.pathing.PathManagers;
import net.minecraft.client.gui.screen.Screen;

public class PathManagerTab extends Tab {
public PathManagerTab() {
super(PathManagers.get().getName());
}

@Override
public TabScreen createScreen(GuiTheme theme) {
return new PathManagerScreen(theme, this);
}

@Override
public boolean isScreen(Screen screen) {
return screen instanceof PathManagerScreen;
}

private static class PathManagerScreen extends WindowTabScreen {
public PathManagerScreen(GuiTheme theme, Tab tab) {
super(theme, tab);

PathManagers.get().getSettings().get().onActivated();
}

@Override
public void initWidgets() {
WTextBox filter = add(theme.textBox("")).minWidth(400).expandX().widget();
filter.setFocused(true);
filter.action = () -> {
clear();

add(filter);
add(theme.settings(PathManagers.get().getSettings().get(), filter.get().trim())).expandX();
};

add(theme.settings(PathManagers.get().getSettings().get(), filter.get().trim())).expandX();
}

@Override
protected void onClosed() {
SettingsUtil.save(BaritoneAPI.getSettings());
}
}
}
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 6576056

Please sign in to comment.