use of net.minecraft.text.LiteralText in project meteor-client by MeteorDevelopment.
the class ModulesCommand method getModuleText.
private BaseText getModuleText(Module module) {
// Hover tooltip
BaseText tooltip = new LiteralText("");
tooltip.append(new LiteralText(module.title).formatted(Formatting.BLUE, Formatting.BOLD)).append("\n");
tooltip.append(new LiteralText(module.name).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.LiteralText in project meteor-client by MeteorDevelopment.
the class CommandsCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
ChatUtils.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.LiteralText in project meteor-client by MeteorDevelopment.
the class AutoLog method onTick.
@EventHandler
private void onTick(TickEvent.Post event) {
if (mc.player.getHealth() <= 0) {
this.toggle();
return;
}
if (mc.player.getHealth() <= health.get()) {
mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(new LiteralText("[AutoLog] Health was lower than " + health.get() + ".")));
if (smartToggle.get()) {
this.toggle();
enableHealthListener();
}
}
if (smart.get() && mc.player.getHealth() + mc.player.getAbsorptionAmount() - PlayerUtils.possibleHealthReductions() < health.get()) {
mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(new LiteralText("[AutoLog] Health was going to be lower than " + health.get() + ".")));
if (toggleOff.get())
this.toggle();
}
for (Entity entity : mc.world.getEntities()) {
if (entity instanceof PlayerEntity && entity.getUuid() != mc.player.getUuid()) {
if (onlyTrusted.get() && entity != mc.player && !Friends.get().isFriend((PlayerEntity) entity)) {
mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(new LiteralText("[AutoLog] A non-trusted player appeared in your render distance.")));
if (toggleOff.get())
this.toggle();
break;
}
if (mc.player.distanceTo(entity) < 8 && instantDeath.get() && DamageUtils.getSwordDamage((PlayerEntity) entity, true) > mc.player.getHealth() + mc.player.getAbsorptionAmount()) {
mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(new LiteralText("[AutoLog] Anti-32k measures.")));
if (toggleOff.get())
this.toggle();
break;
}
}
if (entity instanceof EndCrystalEntity && mc.player.distanceTo(entity) < range.get() && crystalLog.get()) {
mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(new LiteralText("[AutoLog] End Crystal appeared within specified range.")));
if (toggleOff.get())
this.toggle();
}
}
}
use of net.minecraft.text.LiteralText in project meteor-client by MeteorDevelopment.
the class BetterTab method getPlayerName.
public Text getPlayerName(PlayerListEntry playerListEntry) {
Text name;
Color color = null;
name = playerListEntry.getDisplayName();
if (name == null)
name = new LiteralText(playerListEntry.getProfile().getName());
if (playerListEntry.getProfile().getId().toString().equals(mc.player.getGameProfile().getId().toString()) && self.get()) {
color = selfColor.get();
} else if (friends.get() && Friends.get().get(playerListEntry.getProfile().getName()) != null) {
Friend friend = Friends.get().get(playerListEntry.getProfile().getName());
if (friend != null)
color = Friends.get().color;
}
if (color != null) {
String nameString = name.getString();
for (Formatting format : Formatting.values()) {
if (format.isColor())
nameString = nameString.replace(format.toString(), "");
}
name = new LiteralText(nameString).setStyle(name.getStyle().withColor(new TextColor(color.getPacked())));
}
return name;
}
use of net.minecraft.text.LiteralText in project meteor-client by MeteorDevelopment.
the class BookBot method onTick.
@EventHandler
private void onTick(TickEvent.Post event) {
FindItemResult writableBook = InvUtils.find(Items.WRITABLE_BOOK);
// Check if there is a book to write
if (!writableBook.found()) {
toggle();
return;
}
// Move the book into hand
if (!writableBook.isMainHand()) {
InvUtils.move().from(writableBook.slot()).toHotbar(mc.player.getInventory().selectedSlot);
return;
}
// If somehow it failed, just dont do anything until it tries again
FindItemResult finalBook = InvUtils.findInHotbar(Items.WRITABLE_BOOK);
if (!finalBook.isMainHand())
return;
// Check delay
if (delayTimer > 0) {
delayTimer--;
return;
}
// Reset delay
delayTimer = delay.get();
if (mode.get() == Mode.Random) {
int origin = onlyAscii.get() ? 0x21 : 0x0800;
int bound = onlyAscii.get() ? 0x7E : 0x10FFFF;
writeBook(// Generate a random load of ints to use as random characters
random.ints(origin, bound).filter(i -> !Character.isWhitespace(i) && i != '\r' && i != '\n').iterator());
} else if (mode.get() == Mode.File) {
// Ignore if somehow the file got deleted
if ((file == null || !file.exists()) && mode.get() == Mode.File) {
info("No file selected, please select a file in the GUI.");
toggle();
return;
}
// Handle the file being empty
if (file.length() == 0) {
MutableText message = new LiteralText("");
message.append(new LiteralText("The bookbot file is empty! ").formatted(Formatting.RED));
message.append(new LiteralText("Click here to edit it.").setStyle(Style.EMPTY.withFormatting(Formatting.UNDERLINE, Formatting.RED).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, file.getAbsolutePath()))));
info(message);
toggle();
return;
}
// Read each line of the file and construct a string with the needed line breaks
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
StringBuilder file = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
file.append(line).append('\n');
}
reader.close();
// Write the file string to a book
writeBook(file.toString().chars().iterator());
} catch (IOException ignored) {
error("Failed to read the file.");
}
}
}
Aggregations