Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ dependencies {
modImplementation "com.github.MeteorDevelopment:baritone:${project.baritone_version}"
include "com.github.MeteorDevelopment:baritone:${project.baritone_version}"

// Seed .locate features
modImplementation 'com.github.hube12:SEED:master-SNAPSHOT'
include 'com.github.hube12:SEED:master-SNAPSHOT'

// Other dependencies
dependency "com.github.MeteorDevelopment:orbit:${project.orbit_version}"
dependency "com.github.MeteorDevelopment:starscript:${project.starscript_version}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ public void initWidgets(Profile ogProfile, List<String> list) {
waypointsBool.action = () -> newProfile.waypoints = waypointsBool.checked;
table.row();

// Seeds
table.add(theme.label("Seeds:"));
WCheckbox seedsBool = table.add(theme.checkbox(ogProfile.seeds)).widget();
seedsBool.action = () -> newProfile.seeds = seedsBool.checked;
table.row();

table.add(theme.horizontalSeparator()).expandX();
table.row();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.profiles.Profiles;
import meteordevelopment.meteorclient.systems.proxies.Proxies;
import meteordevelopment.meteorclient.systems.seeds.Seeds;
import meteordevelopment.meteorclient.systems.waypoints.Waypoints;

import java.io.File;
Expand Down Expand Up @@ -42,6 +43,7 @@ public static void init() {
add(new Waypoints());
add(new Profiles());
add(new Proxies());
add(new Seeds());

for (System<?> system : systems.values()) {
if (system != config) system.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void init() {
add(new ReloadCommand());
add(new ResetCommand());
add(new SayCommand());
add(new SeedCommand());
add(new ServerCommand());
add(new SwarmCommand());
add(new ToggleCommand());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package meteordevelopment.meteorclient.systems.commands.arguments;

import java.util.Arrays;
import java.util.concurrent.CompletableFuture;

import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import java.lang.reflect.InvocationTargetException;

import net.minecraft.command.CommandSource;
import net.minecraft.text.LiteralText;

public class EnumArgumentType<T extends Enum<?>> implements ArgumentType<T> {
private static final DynamicCommandExceptionType NO_SUCH_TYPE = new DynamicCommandExceptionType(o ->
new LiteralText(o + " is not a valid argument."));

private T[] values;

public EnumArgumentType(T defaultValue) {
super();

try {
values = (T[]) defaultValue.getClass().getMethod("values").invoke(null);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
}
}

public static <T extends Enum<?>> EnumArgumentType<T> enumArgument(T defaultValue) {
return new EnumArgumentType<T>(defaultValue);
}

public static <T extends Enum<?>> T getEnum(CommandContext<?> context, String name, T defaultValue) {
return (T) context.getArgument(name, defaultValue.getClass());
}

@Override
public T parse(StringReader reader) throws CommandSyntaxException {
String argument = reader.readString();
for (T t : values) {
if (t.toString().equals(argument)) return t;
}
throw NO_SUCH_TYPE.create(argument);
}


@Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
return CommandSource.suggestMatching(Arrays.stream(values).map(T::toString), builder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import meteordevelopment.meteorclient.systems.commands.Command;
import meteordevelopment.meteorclient.utils.player.SlotUtils;
import net.minecraft.command.CommandSource;
import net.minecraft.command.argument.ItemStackArgumentType;
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket;
import net.minecraft.text.LiteralText;

import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@

import baritone.api.BaritoneAPI;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.events.packets.PacketEvent;
import meteordevelopment.meteorclient.systems.commands.Command;
import meteordevelopment.meteorclient.systems.commands.arguments.EnumArgumentType;
import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.utils.player.ChatUtils;
import meteordevelopment.meteorclient.utils.player.FindItemResult;
import meteordevelopment.meteorclient.utils.player.InvUtils;
import meteordevelopment.meteorclient.utils.world.WorldGenUtils;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
Expand All @@ -37,61 +41,28 @@

public class LocateCommand extends Command {

private final static DynamicCommandExceptionType NOT_FOUND = new DynamicCommandExceptionType(o -> {
if (o instanceof WorldGenUtils.Feature) {
return new LiteralText(String.format(
"%s not found.",
Utils.nameToTitle(o.toString().replaceAll("_", "-")))
);
}
return new LiteralText("Not found.");
});

private Vec3d firstStart;
private Vec3d firstEnd;
private Vec3d secondStart;
private Vec3d secondEnd;

private final List<Block> netherFortressBlocks = Arrays.asList(
Blocks.NETHER_BRICKS,
Blocks.NETHER_BRICK_FENCE,
Blocks.NETHER_WART
);

private final List<Block> monumentBlocks = Arrays.asList(
Blocks.PRISMARINE_BRICKS,
Blocks.SEA_LANTERN,
Blocks.DARK_PRISMARINE
);

private final List<Block> strongholdBlocks = Arrays.asList(
Blocks.END_PORTAL_FRAME
);

public LocateCommand() {
super("locate", "Locates structures", "loc");
}

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("buried_treasure").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() != Items.FILLED_MAP) {
error("You need to hold a treasure map first");
return SINGLE_SUCCESS;
}
NbtCompound tag = stack.getTag();
NbtList nbt1 = (NbtList) tag.get("Decorations");
if (nbt1 == null) {
error("Couldn't locate the cross. Are you holding a (highlight)treasure map(default)?");
return SINGLE_SUCCESS;
}

NbtCompound iconNBT = nbt1.getCompound(0);
if (iconNBT == null) {
error("Couldn't locate the cross. Are you holding a (highlight)treasure map(default)?");
return SINGLE_SUCCESS;
}

Vec3d coords = new Vec3d(iconNBT.getDouble("x"),iconNBT.getDouble("y"),iconNBT.getDouble("z"));
BaseText text = new LiteralText("Buried Treasure located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));

builder.then(literal("lodestone").executes(s -> {
builder.then(literal("lodestone").executes(ctx -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() != Items.COMPASS) {
error("You need to hold a lodestone compass");
Expand All @@ -116,98 +87,33 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
return SINGLE_SUCCESS;
}));

builder.then(literal("mansion").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() != Items.FILLED_MAP) {
error("You need to hold a woodland explorer map first");
return SINGLE_SUCCESS;
}
NbtCompound tag = stack.getTag();
NbtList nbt1 = (NbtList) tag.get("Decorations");
if (nbt1 == null) {
error("Couldn't locate the mansion. Are you holding a (highlight)woodland explorer map(default)?");
return SINGLE_SUCCESS;
}

NbtCompound iconNBT = nbt1.getCompound(0);
if (iconNBT == null) {
error("Couldn't locate the mansion. Are you holding a (highlight)woodland explorer map(default)?");
return SINGLE_SUCCESS;
}

Vec3d coords = new Vec3d(iconNBT.getDouble("x"),iconNBT.getDouble("y"),iconNBT.getDouble("z"));
BaseText text = new LiteralText("Mansion located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));

builder.then(literal("stronghold").executes(s -> {
FindItemResult eye = InvUtils.findInHotbar(Items.ENDER_EYE);

if (eye.found()) {
BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("follow entity minecraft:eye_of_ender");
firstStart = null;
firstEnd = null;
secondStart = null;
secondEnd = null;
MeteorClient.EVENT_BUS.subscribe(this);
info("Please throw the first Eye of Ender");
} else {
Vec3d coords = findByBlockList(strongholdBlocks);
if (coords == null) {
error("No stronghold found nearby. You can use (highlight)Ender Eyes(default) for more success.");
return SINGLE_SUCCESS;
}
BaseText text = new LiteralText("Stronghold located at ");
builder.then(argument("feature", EnumArgumentType.enumArgument(WorldGenUtils.Feature.stronghold)).executes(ctx -> {
WorldGenUtils.Feature feature = EnumArgumentType.getEnum(ctx, "feature", WorldGenUtils.Feature.stronghold);
BlockPos pos = WorldGenUtils.locateFeature(feature, mc.player.getBlockPos());
if (pos != null) {
BaseText text = new LiteralText(String.format(
"%s located at ",
Utils.nameToTitle(feature.toString().replaceAll("_", "-"))
));
Vec3d coords = new Vec3d(pos.getX(), pos.getY(), pos.getZ());
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
}
return SINGLE_SUCCESS;
}));

builder.then(literal("nether_fortress").executes(s -> {
Vec3d coords = findByBlockList(netherFortressBlocks);
if (coords == null ) {
error("No nether fortress found.");
return SINGLE_SUCCESS;
}
BaseText text = new LiteralText("Fortress located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));

builder.then(literal("monument").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() == Items.FILLED_MAP) {
NbtCompound tag = stack.getTag();
NbtList nbt1 = (NbtList) tag.get("Decorations");
if (nbt1 != null) {
NbtCompound iconNBT = nbt1.getCompound(0);
if (iconNBT != null) {
Vec3d coords = new Vec3d(iconNBT.getDouble("x"),iconNBT.getDouble("y"),iconNBT.getDouble("z"));
BaseText text = new LiteralText("Monument located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}
if (feature == WorldGenUtils.Feature.stronghold) {
FindItemResult eye = InvUtils.findInHotbar(Items.ENDER_EYE);
if (eye.found()) {
BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("follow entity minecraft:eye_of_ender");
firstStart = null;
firstEnd = null;
secondStart = null;
secondEnd = null;
MeteorClient.EVENT_BUS.subscribe(this);
info("Please throw the first Eye of Ender");
}
}
Vec3d coords = findByBlockList(monumentBlocks);
if (coords == null ) {
error("No monument found. You can try using a (highlight)Ocean explorer map(default) for more success.");
return SINGLE_SUCCESS;
}
BaseText text = new LiteralText("Monument located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
throw NOT_FOUND.create(feature);
}));

builder.then(literal("cancel").executes(s -> {
Expand All @@ -221,18 +127,6 @@ private void cancel() {
MeteorClient.EVENT_BUS.unsubscribe(this);
}

private Vec3d findByBlockList(List<Block> blockList) {
List<BlockPos> posList = BaritoneAPI.getProvider().getWorldScanner().scanChunkRadius(BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext(),
blockList,64,10,32);
if (posList.isEmpty()) {
return null;
}
if (posList.size() < 3) {
warning("Only %d block(s) found. This search might be a false positive.", posList.size());
}
return new Vec3d(posList.get(0).getX(),posList.get(0).getY(),posList.get(0).getZ());
}

@EventHandler
private void onReadPacket(PacketEvent.Receive event) {
if (event.packet instanceof EntitySpawnS2CPacket) {
Expand Down
Loading