use of net.minecraft.text.BaseText in project Client by MatHax.
the class ModulesCommand method getModuleText.
private BaseText getModuleText(Module module) {
// Hover tooltip
BaseText tooltip = new LiteralText("");
tooltip.append(new LiteralText(module.title).formatted(Formatting.RED, Formatting.BOLD)).append("\n");
tooltip.append(new LiteralText(module.title).formatted(Formatting.GRAY)).append("\n\n");
tooltip.append(new LiteralText(module.description).formatted(Formatting.WHITE));
BaseText finalModule = new LiteralText(module.title);
if (!module.equals(Modules.get().getGroup(module.category).get(Modules.get().getGroup(module.category).size() - 1)))
finalModule.append(new LiteralText(", ").formatted(Formatting.GRAY));
finalModule.setStyle(finalModule.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, tooltip)));
return finalModule;
}
use of net.minecraft.text.BaseText in project Client by MatHax.
the class CommandsCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
info("--- Commands ((highlight)%d(default)) ---", Commands.get().getCount());
BaseText commands = new LiteralText("");
Commands.get().getAll().forEach(command -> commands.append(getCommandText(command)));
ChatUtils.sendMsg(commands);
return SINGLE_SUCCESS;
});
}
use of net.minecraft.text.BaseText in project Client by MatHax.
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.getNbt(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 + "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 net.minecraft.text.BaseText in project Hypnotic-Client by Hypnotic-Development.
the class NBT 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.getNbt();
if (tag != null && source != null) {
stack.getNbt().copyFrom(tag);
setStack(stack);
} else {
error("Some of the NBT data could not be found, try using: " + CommandManager.INSTANCE.getPrefix() + "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 ? "none" : 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.getNbt();
if (tag == null)
error("No NBT data on this item.");
else {
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 " + count);
}
return SINGLE_SUCCESS;
})));
}
use of net.minecraft.text.BaseText in project Hypnotic-Client by Hypnotic-Development.
the class ChatUtils method sendMsg.
public static void sendMsg(int id, @Nullable String prefixTitle, @Nullable Formatting prefixColor, String messageContent, Formatting messageColor) {
BaseText message = new LiteralText(messageContent);
message.setStyle(message.getStyle().withFormatting(messageColor));
sendMsg(id, prefixTitle, prefixColor, message);
}
Aggregations