Skip to content

Commit d9d434c

Browse files
committed
random command
1 parent 1c40154 commit d9d434c

4 files changed

Lines changed: 80 additions & 4 deletions

File tree

src/main/java/com/nerds/addon/NerdAddon.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.mojang.logging.LogUtils;
44

5+
import com.nerds.addon.commands.Coords;
56
import com.nerds.addon.modules.*;
67
import meteordevelopment.meteorclient.addons.GithubRepo;
78
import meteordevelopment.meteorclient.addons.MeteorAddon;
@@ -28,7 +29,8 @@ public void onInitialize() {
2829
Modules.get().add(new AutoEmoji());
2930
Modules.get().add(new FastSwim());
3031

31-
// Commands
32+
33+
Commands.add(new Coords());
3234

3335
// HUD
3436
}
@@ -47,4 +49,4 @@ public String getPackage() {
4749
public GithubRepo getRepo() {
4850
return new GithubRepo("Frko5000", "nerd-addon");
4951
}
50-
}
52+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.nerds.addon.commands;
2+
3+
import com.mojang.brigadier.arguments.StringArgumentType;
4+
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
5+
import com.mojang.brigadier.suggestion.SuggestionProvider;
6+
import meteordevelopment.meteorclient.commands.Command;
7+
import net.minecraft.client.network.AbstractClientPlayerEntity;
8+
import net.minecraft.command.CommandSource;
9+
10+
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
11+
import static meteordevelopment.meteorclient.MeteorClient.mc;
12+
13+
public class Coords extends Command {
14+
15+
private static final SuggestionProvider<CommandSource> PLAYER_SUGGESTIONS = (context, builder) -> {
16+
if (mc.world == null) return builder.buildFuture();
17+
18+
String remaining = builder.getRemaining().toLowerCase();
19+
20+
for (AbstractClientPlayerEntity player : mc.world.getPlayers()) {
21+
String name = player.getGameProfile().name();
22+
if (name.toLowerCase().startsWith(remaining)) {
23+
builder.suggest(name);
24+
}
25+
}
26+
27+
return builder.buildFuture();
28+
};
29+
30+
public Coords() {
31+
super("coords", "copies your (or another player's) coordinates to your clipboard.");
32+
}
33+
34+
@Override
35+
public void build(LiteralArgumentBuilder<CommandSource> builder) {
36+
builder.executes(context -> {
37+
if (mc.player == null) return SINGLE_SUCCESS;
38+
copyCoords(mc.player.getGameProfile().name(), mc.player.getX(), mc.player.getY(), mc.player.getZ());
39+
return SINGLE_SUCCESS;
40+
});
41+
42+
builder.then(argument("player", StringArgumentType.word())
43+
.suggests(PLAYER_SUGGESTIONS)
44+
.executes(context -> {
45+
if (mc.world == null) return SINGLE_SUCCESS;
46+
47+
String targetName = StringArgumentType.getString(context, "player");
48+
AbstractClientPlayerEntity target = null;
49+
50+
for (AbstractClientPlayerEntity player : mc.world.getPlayers()) {
51+
if (player.getGameProfile().name().equalsIgnoreCase(targetName)) {
52+
target = player;
53+
break;
54+
}
55+
}
56+
57+
if (target == null) {
58+
error("player \"" + targetName + "\" not found.");
59+
return SINGLE_SUCCESS;
60+
}
61+
62+
copyCoords(target.getGameProfile().name(), target.getX(), target.getY(), target.getZ());
63+
return SINGLE_SUCCESS;
64+
})
65+
);
66+
}
67+
68+
private void copyCoords(String name, double x, double y, double z) {
69+
String text = "x: " + (int) Math.floor(x) + " y: " + (int) Math.floor(y) + " z: " + (int) Math.floor(z);
70+
mc.keyboard.setClipboard(text);
71+
boolean isSelf = mc.player != null && name.equals(mc.player.getGameProfile().name());
72+
info("successfully copied " + (isSelf ? "your" : name + "'s") + " coordinates: \n" + text);
73+
}
74+
}

src/main/java/com/nerds/addon/modules/AutoEmoji.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class AutoEmoji extends Module {
1818
private static final Map<String, String> EMOJIS = new HashMap<>();
1919

2020
public AutoEmoji() {
21-
super(NerdAddon.CATEGORY, "auto-emoji", "adds discord emojis like :sob: and other ones to format in chat");
21+
super(NerdAddon.CATEGORY, "auto-emoji", "converts text shortcuts like :sob: into emojis in chat");
2222
loadEmojiMappings();
2323
}
2424

src/main/java/com/nerds/addon/modules/Loadouts.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
public class Loadouts extends Module {
3131
public Loadouts() {
32-
super(NerdAddon.CATEGORY, "Loadouts", "add button in inv to move item where you saved mastersigma");
32+
super(NerdAddon.CATEGORY, "Loadouts", "save & auto-restore inventory loadouts");
3333
}
3434

3535
public static final String LOADOUTS_FILE = "meteor-client/loadouts.json";

0 commit comments

Comments
 (0)