Search in sources :

Example 1 with BaseText

use of net.minecraft.text.BaseText in project meteor-rejects by AntiCope.

the class CoordLogger method formatMessage.

public BaseText formatMessage(String message, Vec3d coords) {
    BaseText text = new LiteralText(message);
    text.append(ChatUtils.formatCoords(coords));
    text.append(Formatting.GRAY.toString() + ".");
    return text;
}
Also used : BaseText(net.minecraft.text.BaseText) LiteralText(net.minecraft.text.LiteralText)

Example 2 with BaseText

use of net.minecraft.text.BaseText in project meteor-rejects by AntiCope.

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)

Example 3 with BaseText

use of net.minecraft.text.BaseText in project meteor-rejects by AntiCope.

the class LocateCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("lodestone").executes(ctx -> {
        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(argument("feature", EnumArgumentType.enumArgument(WorldGenUtils.Feature.stronghold)).executes(ctx -> {
        WorldGenUtils.Feature feature = EnumArgumentType.getEnum(ctx, "feature", WorldGenUtils.Feature.stronghold);
        BlockPos pos = WorldGenUtils.locateFeature(feature, mc.player.getBlockPos());
        if (pos != null) {
            BaseText text = new LiteralText(String.format("%s located at ", Utils.nameToTitle(feature.toString().replaceAll("_", "-"))));
            Vec3d coords = new Vec3d(pos.getX(), pos.getY(), pos.getZ());
            text.append(ChatUtils.formatCoords(coords));
            text.append(".");
            info(text);
            return SINGLE_SUCCESS;
        }
        if (feature == WorldGenUtils.Feature.stronghold) {
            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");
            }
        }
        throw NOT_FOUND.create(feature);
    }));
    builder.then(literal("cancel").executes(s -> {
        cancel();
        return SINGLE_SUCCESS;
    }));
}
Also used : EntityType(net.minecraft.entity.EntityType) LiteralText(net.minecraft.text.LiteralText) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) ItemStack(net.minecraft.item.ItemStack) PlaySoundS2CPacket(net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket) BaseText(net.minecraft.text.BaseText) Command(meteordevelopment.meteorclient.systems.commands.Command) SoundEvents(net.minecraft.sound.SoundEvents) Vec3d(net.minecraft.util.math.Vec3d) EnumArgumentType(anticope.rejects.arguments.EnumArgumentType) FindItemResult(meteordevelopment.meteorclient.utils.player.FindItemResult) InvUtils(meteordevelopment.meteorclient.utils.player.InvUtils) ChatUtils(meteordevelopment.meteorclient.utils.player.ChatUtils) Utils(meteordevelopment.meteorclient.utils.Utils) EntitySpawnS2CPacket(net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket) BaritoneAPI(baritone.api.BaritoneAPI) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) PacketEvent(meteordevelopment.meteorclient.events.packets.PacketEvent) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) CommandSource(net.minecraft.command.CommandSource) NbtCompound(net.minecraft.nbt.NbtCompound) DynamicCommandExceptionType(com.mojang.brigadier.exceptions.DynamicCommandExceptionType) MeteorClient(meteordevelopment.meteorclient.MeteorClient) WorldGenUtils(anticope.rejects.utils.WorldGenUtils) EventHandler(meteordevelopment.orbit.EventHandler) BaseText(net.minecraft.text.BaseText) NbtCompound(net.minecraft.nbt.NbtCompound) FindItemResult(meteordevelopment.meteorclient.utils.player.FindItemResult) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d) LiteralText(net.minecraft.text.LiteralText)

Example 4 with BaseText

use of net.minecraft.text.BaseText in project meteor-rejects by AntiCope.

the class SeedCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.executes(ctx -> {
        Seed seed = Seeds.get().getSeed();
        if (seed == null)
            throw NO_SEED.create();
        info(seed.toText());
        return SINGLE_SUCCESS;
    });
    builder.then(literal("list").executes(ctx -> {
        Seeds.get().seeds.forEach((name, seed) -> {
            BaseText text = new LiteralText(name + " ");
            text.append(seed.toText());
            info(text);
        });
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("delete").executes(ctx -> {
        Seed seed = Seeds.get().getSeed();
        if (seed != null) {
            BaseText text = new LiteralText("Deleted ");
            text.append(seed.toText());
            info(text);
        }
        Seeds.get().seeds.remove(Utils.getWorldName());
        return SINGLE_SUCCESS;
    }));
    builder.then(argument("seed", StringArgumentType.string()).executes(ctx -> {
        Seeds.get().setSeed(StringArgumentType.getString(ctx, "seed"));
        return SINGLE_SUCCESS;
    }));
    builder.then(argument("seed", StringArgumentType.string()).then(argument("version", EnumArgumentType.enumArgument(MCVersion.latest())).executes(ctx -> {
        Seeds.get().setSeed(StringArgumentType.getString(ctx, "seed"), EnumArgumentType.getEnum(ctx, "version", MCVersion.latest()));
        return SINGLE_SUCCESS;
    })));
}
Also used : LiteralText(net.minecraft.text.LiteralText) MCVersion(com.seedfinding.mccore.version.MCVersion) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) CommandSource(net.minecraft.command.CommandSource) Seed(anticope.rejects.utils.seeds.Seed) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) BaseText(net.minecraft.text.BaseText) Command(meteordevelopment.meteorclient.systems.commands.Command) EnumArgumentType(anticope.rejects.arguments.EnumArgumentType) Seeds(anticope.rejects.utils.seeds.Seeds) Utils(meteordevelopment.meteorclient.utils.Utils) BaseText(net.minecraft.text.BaseText) Seed(anticope.rejects.utils.seeds.Seed) LiteralText(net.minecraft.text.LiteralText)

Example 5 with BaseText

use of net.minecraft.text.BaseText in project orion by AntiCope.

the class ChatTweaks method getPrefix.

public LiteralText getPrefix() {
    BaseText logo = new LiteralText("");
    LiteralText prefix = new LiteralText("");
    String logoT = "Orion";
    if (customPrefix.get())
        logoT = prefixText.get();
    if (customPrefixColor.get() && !chromaPrefix.get())
        logo.append(new LiteralText(logoT).setStyle(logo.getStyle().withColor(TextColor.fromRgb(prefixColor.get().getPacked()))));
    if (chromaPrefix.get() && !customPrefixColor.get()) {
        prefixChroma.setSpeed(chromaSpeed.get() / 100);
        for (int i = 0, n = logoT.length(); i < n; i++) logo.append(new LiteralText(String.valueOf(logoT.charAt(i)))).setStyle(logo.getStyle().withColor(TextColor.fromRgb(prefixChroma.getNext().getPacked())));
    }
    if (!customPrefixColor.get() && !chromaPrefix.get()) {
        if (customPrefix.get()) {
            logo.append(prefixText.get());
        } else {
            logo.append("Orion");
        }
        logo.setStyle(logo.getStyle().withFormatting(Formatting.RED));
    }
    if (themeBrackets.get()) {
        if (customPrefixColor.get() && !chromaPrefix.get())
            prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(prefixColor.get().getPacked())));
        if (chromaPrefix.get() && !customPrefixColor.get()) {
            prefixChroma.setSpeed(chromaSpeed.get() / 100);
            prefix.setStyle(prefix.getStyle().withColor(TextColor.fromRgb(prefixChroma.getNext().getPacked())));
        }
        if (customBrackets.get()) {
            prefix.append(leftBracket.get());
            prefix.append(logo);
            prefix.append(rightBracket.get() + " ");
        } else {
            prefix.append("[");
            prefix.append(logo);
            prefix.append("] ");
        }
    } else {
        prefix.setStyle(prefix.getStyle().withFormatting(Formatting.GRAY));
        prefix.append("[");
        prefix.append(logo);
        prefix.append("] ");
    }
    return prefix;
}
Also used : BaseText(net.minecraft.text.BaseText) 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