Search in sources :

Example 11 with BaseText

use of net.minecraft.text.BaseText in project Client by MatHax.

the class LocateCommand method findStronghold.

private void findStronghold() {
    if (this.firstStart == null || this.firstEnd == null || this.secondStart == null || this.secondEnd == null) {
        error("Missing position data");
        cancel();
        return;
    }
    final double[] start = new double[] { this.secondStart.x, this.secondStart.z, this.secondEnd.x, this.secondEnd.z };
    final double[] end = new double[] { this.firstStart.x, this.firstStart.z, this.firstEnd.x, this.firstEnd.z };
    final double[] intersection = calcIntersection(start, end);
    if (Double.isNaN(intersection[0]) || Double.isNaN(intersection[1]) || Double.isInfinite(intersection[0]) || Double.isInfinite(intersection[1])) {
        error("Lines are parallel");
        cancel();
        return;
    }
    BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("stop");
    MatHax.EVENT_BUS.unsubscribe(this);
    Vec3d coords = new Vec3d(intersection[0], 0, intersection[1]);
    BaseText text = new LiteralText("Stronghold roughly located at ");
    text.append(ChatUtils.formatCoords(coords));
    text.append(".");
    info(text);
}
Also used : BaseText(net.minecraft.text.BaseText) Vec3d(net.minecraft.util.math.Vec3d) LiteralText(net.minecraft.text.LiteralText)

Example 12 with BaseText

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, Text msg) {
    if (mc.world == null)
        return;
    BaseText message = new LiteralText("");
    message.append(CommandManager.INSTANCE.getPrefix());
    if (prefixTitle != null)
        message.append(CommandManager.INSTANCE.getPrefix());
    message.append(msg);
    id = 0;
    ((ChatHudAccessor) mc.inGameHud.getChatHud()).add(message, id);
}
Also used : BaseText(net.minecraft.text.BaseText) ChatHudAccessor(dev.hypnotic.mixin.ChatHudAccessor) LiteralText(net.minecraft.text.LiteralText)

Example 13 with BaseText

use of net.minecraft.text.BaseText in project tweakermore by Fallen-Breath.

the class SafeAfkHelper method onHealthUpdate.

public static void onHealthUpdate(MinecraftClient mc) {
    if (TweakerMoreConfigs.TWEAKM_SAFE_AFK.getBooleanValue()) {
        if (mc.player != null && mc.world != null && hasRecord()) {
            float health = mc.player.getHealth();
            float maxHealth = mc.player.getMaximumHealth();
            if (maxHealth > 0 && health < TweakerMoreConfigs.SAFE_AFK_HEALTH_THRESHOLD.getDoubleValue()) {
                String title = TweakerMoreMod.MOD_NAME + " " + TweakerMoreConfigs.TWEAKM_SAFE_AFK.getPrettyName();
                BaseText reason = new TranslatableText("tweakermore.config.tweakmSafeAfk.received_damage", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), String.format("%.1f / %.1f (%.0f%%)", health, maxHealth, health / maxHealth * 100));
                resetHurtTime();
                mc.execute(() -> {
                    mc.world.disconnect();
                    mc.disconnect();
                    mc.openScreen(new DisconnectedScreen(new MultiplayerScreen(new TitleScreen()), title, reason));
                });
            }
        }
    }
}
Also used : BaseText(net.minecraft.text.BaseText) TranslatableText(net.minecraft.text.TranslatableText) MultiplayerScreen(net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen) DisconnectedScreen(net.minecraft.client.gui.screen.DisconnectedScreen) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) TitleScreen(net.minecraft.client.gui.screen.TitleScreen)

Example 14 with BaseText

use of net.minecraft.text.BaseText 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;
    })));
}
Also used : LiteralText(net.minecraft.text.LiteralText) CompoundNbtTagArgumentType(meteordevelopment.meteorclient.systems.commands.arguments.CompoundNbtTagArgumentType) CreativeInventoryActionC2SPacket(net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket) Config(meteordevelopment.meteorclient.systems.config.Config) HoverEvent(net.minecraft.text.HoverEvent) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) ItemStack(net.minecraft.item.ItemStack) NbtCompound(net.minecraft.nbt.NbtCompound) BaseText(net.minecraft.text.BaseText) Formatting(net.minecraft.util.Formatting) NbtPathArgumentType(net.minecraft.command.argument.NbtPathArgumentType) Command(meteordevelopment.meteorclient.systems.commands.Command) ClickEvent(net.minecraft.text.ClickEvent) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) BaseText(net.minecraft.text.BaseText) HoverEvent(net.minecraft.text.HoverEvent) NbtCompound(net.minecraft.nbt.NbtCompound) NbtPathArgumentType(net.minecraft.command.argument.NbtPathArgumentType) ClickEvent(net.minecraft.text.ClickEvent) ItemStack(net.minecraft.item.ItemStack) LiteralText(net.minecraft.text.LiteralText)

Example 15 with BaseText

use of net.minecraft.text.BaseText in project meteor-client by MeteorDevelopment.

the class LocateCommand method findStronghold.

private void findStronghold() {
    if (this.firstStart == null || this.firstEnd == null || this.secondStart == null || this.secondEnd == null) {
        error("Missing position data");
        cancel();
        return;
    }
    final double[] start = new double[] { this.secondStart.x, this.secondStart.z, this.secondEnd.x, this.secondEnd.z };
    final double[] end = new double[] { this.firstStart.x, this.firstStart.z, this.firstEnd.x, this.firstEnd.z };
    final double[] intersection = calcIntersection(start, end);
    if (Double.isNaN(intersection[0]) || Double.isNaN(intersection[1]) || Double.isInfinite(intersection[0]) || Double.isInfinite(intersection[1])) {
        error("Lines are parallel");
        cancel();
        return;
    }
    BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("stop");
    MeteorClient.EVENT_BUS.unsubscribe(this);
    Vec3d coords = new Vec3d(intersection[0], 0, intersection[1]);
    BaseText text = new LiteralText("Stronghold roughly located at ");
    text.append(ChatUtils.formatCoords(coords));
    text.append(".");
    info(text);
}
Also used : BaseText(net.minecraft.text.BaseText) Vec3d(net.minecraft.util.math.Vec3d) LiteralText(net.minecraft.text.LiteralText)

Aggregations

BaseText (net.minecraft.text.BaseText)25 LiteralText (net.minecraft.text.LiteralText)24 HoverEvent (net.minecraft.text.HoverEvent)9 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)7 CommandSource (net.minecraft.command.CommandSource)7 SINGLE_SUCCESS (com.mojang.brigadier.Command.SINGLE_SUCCESS)6 ItemStack (net.minecraft.item.ItemStack)6 NbtCompound (net.minecraft.nbt.NbtCompound)6 ClickEvent (net.minecraft.text.ClickEvent)6 Vec3d (net.minecraft.util.math.Vec3d)6 Command (meteordevelopment.meteorclient.systems.commands.Command)4 BaritoneAPI (baritone.api.BaritoneAPI)3 IntegerArgumentType (com.mojang.brigadier.arguments.IntegerArgumentType)3 NbtPathArgumentType (net.minecraft.command.argument.NbtPathArgumentType)3 EntityType (net.minecraft.entity.EntityType)3 Items (net.minecraft.item.Items)3 CreativeInventoryActionC2SPacket (net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket)3 EntitySpawnS2CPacket (net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket)3 PlaySoundS2CPacket (net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket)3 SoundEvents (net.minecraft.sound.SoundEvents)3