use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project meteor-client by MeteorDevelopment.
the class NbtCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("add").then(argument("nbt_data", CompoundNbtTagArgumentType.nbtTag()).executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (validBasic(stack)) {
NbtCompound tag = CompoundNbtTagArgumentType.getTag(s, "nbt_data");
NbtCompound source = stack.getOrCreateNbt();
if (tag != null) {
source.copyFrom(tag);
setStack(stack);
} else {
error("Some of the NBT data could not be found, try using: " + Config.get().prefix.get() + "nbt set {nbt}");
}
}
return SINGLE_SUCCESS;
})));
builder.then(literal("set").then(argument("nbt_data", CompoundNbtTagArgumentType.nbtTag()).executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (validBasic(stack)) {
NbtCompound tag = s.getArgument("nbt_data", NbtCompound.class);
stack.setNbt(tag);
setStack(stack);
}
return SINGLE_SUCCESS;
})));
builder.then(literal("remove").then(argument("nbt_path", NbtPathArgumentType.nbtPath()).executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (validBasic(stack)) {
NbtPathArgumentType.NbtPath path = s.getArgument("nbt_path", NbtPathArgumentType.NbtPath.class);
path.remove(stack.getNbt());
}
return SINGLE_SUCCESS;
})));
builder.then(literal("get").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack == null) {
error("You must hold an item in your main hand.");
} else {
NbtCompound tag = stack.getNbt();
String nbt = tag == null ? "{}" : tag.asString();
BaseText copyButton = new LiteralText("NBT");
copyButton.setStyle(copyButton.getStyle().withFormatting(Formatting.UNDERLINE).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, this.toString("copy"))).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("Copy the NBT data to your clipboard."))));
BaseText text = new LiteralText("");
text.append(copyButton);
text.append(new LiteralText(": " + nbt));
info(text);
}
return SINGLE_SUCCESS;
}));
builder.then(literal("copy").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack == null) {
error("You must hold an item in your main hand.");
} else {
NbtCompound tag = stack.getOrCreateNbt();
mc.keyboard.setClipboard(tag.toString());
BaseText nbt = new LiteralText("NBT");
nbt.setStyle(nbt.getStyle().withFormatting(Formatting.UNDERLINE).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(tag.toString()))));
BaseText text = new LiteralText("");
text.append(nbt);
text.append(new LiteralText(" data copied!"));
info(text);
}
return SINGLE_SUCCESS;
}));
builder.then(literal("count").then(argument("count", IntegerArgumentType.integer(-127, 127)).executes(context -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (validBasic(stack)) {
int count = IntegerArgumentType.getInteger(context, "count");
stack.setCount(count);
setStack(stack);
info("Set mainhand stack count to %s.", count);
}
return SINGLE_SUCCESS;
})));
}
use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project meteor-client by MeteorDevelopment.
the class ResetCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("settings").then(argument("module", ModuleArgumentType.module()).executes(context -> {
Module module = context.getArgument("module", Module.class);
module.settings.forEach(group -> group.forEach(Setting::reset));
module.info("Reset all settings.");
return SINGLE_SUCCESS;
})).then(literal("all").executes(context -> {
Modules.get().getAll().forEach(module -> module.settings.forEach(group -> group.forEach(Setting::reset)));
ChatUtils.info("Modules", "Reset all module settings");
return SINGLE_SUCCESS;
}))).then(literal("gui").executes(context -> {
GuiThemes.get().clearWindowConfigs();
ChatUtils.info("Reset GUI positioning.");
return SINGLE_SUCCESS;
})).then(literal("bind").then(argument("module", ModuleArgumentType.module()).executes(context -> {
Module module = context.getArgument("module", Module.class);
module.keybind.set(true, -1);
module.info("Reset bind.");
return SINGLE_SUCCESS;
})).then(literal("all").executes(context -> {
Modules.get().getAll().forEach(module -> module.keybind.set(true, -1));
ChatUtils.info("Modules", "Reset all binds.");
return SINGLE_SUCCESS;
}))).then(literal("hud").executes(context -> {
Systems.get(HUD.class).reset.run();
ChatUtils.info("HUD", "Reset all elements.");
return SINGLE_SUCCESS;
}));
}
use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project meteor-client by MeteorDevelopment.
the class LocateCommand method build.
@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.getNbt();
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 -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() != Items.COMPASS) {
error("You need to hold a lodestone compass");
return SINGLE_SUCCESS;
}
NbtCompound tag = stack.getNbt();
if (tag == null) {
error("Couldn't get the NBT data. Are you holding a (highlight)lodestone(default) compass?");
return SINGLE_SUCCESS;
}
NbtCompound nbt1 = tag.getCompound("LodestonePos");
if (nbt1 == null) {
error("Couldn't get the NBT data. Are you holding a (highlight)lodestone(default) compass?");
return SINGLE_SUCCESS;
}
Vec3d coords = new Vec3d(nbt1.getDouble("X"), nbt1.getDouble("Y"), nbt1.getDouble("Z"));
BaseText text = new LiteralText("Lodestone located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
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.getNbt();
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 ");
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.getNbt();
if (tag != null) {
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;
}
}
}
}
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;
}));
builder.then(literal("cancel").executes(s -> {
cancel();
return SINGLE_SUCCESS;
}));
}
use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project meteor-client by MeteorDevelopment.
the class BindsCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
// Modules
List<Module> modules = Modules.get().getAll().stream().filter(module -> module.keybind.isSet()).collect(Collectors.toList());
ChatUtils.info("--- Bound Modules ((highlight)%d(default)) ---", modules.size());
for (Module module : modules) {
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, getTooltip(module));
MutableText text = new LiteralText(module.title).formatted(Formatting.WHITE);
text.setStyle(text.getStyle().withHoverEvent(hoverEvent));
MutableText sep = new LiteralText(" - ");
sep.setStyle(sep.getStyle().withHoverEvent(hoverEvent));
text.append(sep.formatted(Formatting.GRAY));
MutableText key = new LiteralText(module.keybind.toString());
key.setStyle(key.getStyle().withHoverEvent(hoverEvent));
text.append(key.formatted(Formatting.GRAY));
ChatUtils.sendMsg(text);
}
return SINGLE_SUCCESS;
});
}
use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project meteor-client by MeteorDevelopment.
the class ToggleCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("all").then(literal("on").executes(context -> {
new ArrayList<>(Modules.get().getAll()).forEach(module -> {
if (!module.isActive())
module.toggle();
});
HUD.get().active = true;
return SINGLE_SUCCESS;
})).then(literal("off").executes(context -> {
new ArrayList<>(Modules.get().getActive()).forEach(Module::toggle);
HUD.get().active = false;
return SINGLE_SUCCESS;
}))).then(argument("module", ModuleArgumentType.module()).executes(context -> {
Module m = ModuleArgumentType.getModule(context, "module");
m.toggle();
return SINGLE_SUCCESS;
}).then(literal("on").executes(context -> {
Module m = ModuleArgumentType.getModule(context, "module");
if (!m.isActive())
m.toggle();
return SINGLE_SUCCESS;
})).then(literal("off").executes(context -> {
Module m = ModuleArgumentType.getModule(context, "module");
if (m.isActive())
m.toggle();
return SINGLE_SUCCESS;
})));
}
Aggregations