Search in sources :

Example 81 with LiteralText

use of net.minecraft.text.LiteralText in project KiwiClient by TangyKiwi.

the class BetterChat method onMessageRecieve.

@Subscribe
@AllowConcurrentEvents
public void onMessageRecieve(AddMessageEvent event) {
    ((ChatHudAccessor) mc.inGameHud.getChatHud()).getVisibleMessages().removeIf((message) -> message.getId() == event.id && event.id != 0);
    ((ChatHudAccessor) mc.inGameHud.getChatHud()).getMessages().removeIf((message) -> message.getId() == event.id && event.id != 0);
    Text message = event.message;
    // Timestamps
    if (getSetting(2).asToggle().state) {
        Matcher matcher = Pattern.compile("^(<[0-9]{2}:[0-9]{2}:[0-9]{2}>\\s)").matcher(message.getString());
        if (matcher.matches())
            message.getSiblings().subList(0, 8).clear();
        Text timestamp = new LiteralText("[" + dateFormat.format(new Date()) + "] ").formatted(Formatting.GRAY);
        message = new LiteralText("").append(timestamp).append(message);
    }
    // Player Heads
    if (getSetting(3).asToggle().state) {
        message = new LiteralText("   ").append(message);
    }
    event.setCancelled(true);
    ((IChatHUD) mc.inGameHud.getChatHud()).add(message, event.id, mc.inGameHud.getTicks(), false);
}
Also used : Matcher(java.util.regex.Matcher) LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) IChatHUD(com.tangykiwi.kiwiclient.mixininterface.IChatHUD) Date(java.util.Date) LiteralText(net.minecraft.text.LiteralText) AllowConcurrentEvents(com.google.common.eventbus.AllowConcurrentEvents) Subscribe(com.google.common.eventbus.Subscribe)

Example 82 with LiteralText

use of net.minecraft.text.LiteralText in project KiwiClient by TangyKiwi.

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 (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(TextColor.fromRgb(color.getRGB())));
    }
    return name;
}
Also used : TextColor(net.minecraft.text.TextColor) Formatting(net.minecraft.util.Formatting) LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) LiteralText(net.minecraft.text.LiteralText)

Example 83 with LiteralText

use of net.minecraft.text.LiteralText in project KiwiClient by TangyKiwi.

the class Tooltips method appendTooltip.

@Subscribe
@AllowConcurrentEvents
public void appendTooltip(ItemStackTooltipEvent event) {
    // Stew
    if (getSetting(0).asToggle().state) {
        if (event.itemStack.getItem() == Items.SUSPICIOUS_STEW) {
            NbtCompound tag = event.itemStack.getNbt();
            if (tag != null) {
                NbtList effects = tag.getList("Effects", 10);
                if (effects != null) {
                    for (int i = 0; i < effects.size(); i++) {
                        NbtCompound effectTag = effects.getCompound(i);
                        byte effectId = effectTag.getByte("EffectId");
                        int effectDuration = effectTag.contains("EffectDuration") ? effectTag.getInt("EffectDuration") : 160;
                        StatusEffectInstance effect = new StatusEffectInstance(StatusEffect.byRawId(effectId), effectDuration, 0);
                        event.list.add(1, getStatusText(effect));
                    }
                }
            }
        } else if (event.itemStack.getItem().isFood()) {
            FoodComponent food = event.itemStack.getItem().getFoodComponent();
            if (food != null) {
                food.getStatusEffects().forEach((e) -> {
                    StatusEffectInstance effect = e.getFirst();
                    event.list.add(1, getStatusText(effect));
                });
            }
        }
    }
    // Bees
    if (getSetting(1).asToggle().state) {
        if (event.itemStack.getItem() == Items.BEEHIVE || event.itemStack.getItem() == Items.BEE_NEST) {
            NbtCompound tag = event.itemStack.getNbt();
            if (tag != null) {
                NbtCompound blockStateTag = tag.getCompound("BlockStateTag");
                if (blockStateTag != null) {
                    int level = blockStateTag.getInt("honey_level");
                    event.list.add(1, new LiteralText(String.format("%sHoney Level: %s%d%s", Formatting.GRAY, Formatting.YELLOW, level, Formatting.GRAY)));
                }
                NbtCompound blockEntityTag = tag.getCompound("BlockEntityTag");
                if (blockEntityTag != null) {
                    NbtList beesTag = blockEntityTag.getList("Bees", 10);
                    event.list.add(1, new LiteralText(String.format("%sBees: %s%d%s", Formatting.GRAY, Formatting.YELLOW, beesTag.size(), Formatting.GRAY)));
                }
            }
        }
    }
// Fish handled in EntityBucketItemMixin
}
Also used : LiteralText(net.minecraft.text.LiteralText) NbtList(net.minecraft.nbt.NbtList) EChestMemory(com.tangykiwi.kiwiclient.util.tooltip.EChestMemory) TranslatableText(net.minecraft.text.TranslatableText) Module(com.tangykiwi.kiwiclient.modules.Module) DefaultedList(net.minecraft.util.collection.DefaultedList) Block(net.minecraft.block.Block) AllowConcurrentEvents(com.google.common.eventbus.AllowConcurrentEvents) Inventories(net.minecraft.inventory.Inventories) MutableText(net.minecraft.text.MutableText) ToggleSetting(com.tangykiwi.kiwiclient.modules.settings.ToggleSetting) Subscribe(com.google.common.eventbus.Subscribe) Object2IntOpenHashMap(it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap) ItemStackTooltipEvent(com.tangykiwi.kiwiclient.event.ItemStackTooltipEvent) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) Category(com.tangykiwi.kiwiclient.modules.Category) ContainerTooltipComponent(com.tangykiwi.kiwiclient.util.tooltip.ContainerTooltipComponent) net.minecraft.item(net.minecraft.item) Blocks(net.minecraft.block.Blocks) java.awt(java.awt) TooltipDataEvent(com.tangykiwi.kiwiclient.event.TooltipDataEvent) NbtCompound(net.minecraft.nbt.NbtCompound) StatusEffect(net.minecraft.entity.effect.StatusEffect) Formatting(net.minecraft.util.Formatting) List(java.util.List) StatusEffectUtil(net.minecraft.entity.effect.StatusEffectUtil) Object2IntMap(it.unimi.dsi.fastutil.objects.Object2IntMap) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) DyeColor(net.minecraft.util.DyeColor) Text(net.minecraft.text.Text) Comparator(java.util.Comparator) NbtCompound(net.minecraft.nbt.NbtCompound) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) NbtList(net.minecraft.nbt.NbtList) LiteralText(net.minecraft.text.LiteralText) AllowConcurrentEvents(com.google.common.eventbus.AllowConcurrentEvents) Subscribe(com.google.common.eventbus.Subscribe)

Example 84 with LiteralText

use of net.minecraft.text.LiteralText in project KiwiClient by TangyKiwi.

the class Dupe method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.executes(context -> {
        HitResult hr = MinecraftClient.getInstance().crosshairTarget;
        if (hr instanceof BlockHitResult) {
            BlockHitResult bhr = (BlockHitResult) hr;
            BlockState bs = MinecraftClient.getInstance().world.getBlockState(bhr.getBlockPos());
            if (bs.getBlock() instanceof ShulkerBoxBlock) {
                MinecraftClient.getInstance().interactionManager.interactBlock(MinecraftClient.getInstance().player, MinecraftClient.getInstance().world, Hand.MAIN_HAND, bhr);
                preDoDupe = true;
            }
        } else {
            Utils.mc.inGameHud.getChatHud().addMessage(new LiteralText("Please look at a shulker box"));
        }
        return SINGLE_SUCCESS;
    });
}
Also used : BlockHitResult(net.minecraft.util.hit.BlockHitResult) HitResult(net.minecraft.util.hit.HitResult) BlockState(net.minecraft.block.BlockState) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) BlockHitResult(net.minecraft.util.hit.BlockHitResult) LiteralText(net.minecraft.text.LiteralText)

Example 85 with LiteralText

use of net.minecraft.text.LiteralText in project KiwiClient by TangyKiwi.

the class Server method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.executes(context -> {
        boolean sp = Utils.mc.isIntegratedServerRunning();
        if (!sp && Utils.mc.getCurrentServerEntry() == null) {
            Utils.mc.inGameHud.getChatHud().addMessage(new LiteralText("Error getting server info."));
            return SINGLE_SUCCESS;
        }
        Utils.mc.inGameHud.getChatHud().addMessage(new LiteralText("\u00a77" + "------ Server Info ------"));
        Utils.mc.inGameHud.getChatHud().addMessage(createText("Address", getAddress(sp)));
        Utils.mc.inGameHud.getChatHud().addMessage(createText("Brand", getBrand(sp)));
        Utils.mc.inGameHud.getChatHud().addMessage(createText("Day", getDay()));
        Utils.mc.inGameHud.getChatHud().addMessage(createText("Difficulty", getDifficulty()));
        Utils.mc.inGameHud.getChatHud().addMessage(createText("IP", getIP(sp)));
        Utils.mc.inGameHud.getChatHud().addMessage(createText("MOTD", getMotd(sp)));
        Utils.mc.inGameHud.getChatHud().addMessage(createText("Ping", getPing()));
        Utils.mc.inGameHud.getChatHud().addMessage(createText("Permission Level", getPerms()));
        Utils.mc.inGameHud.getChatHud().addMessage(createText("Protocol", getProtocol(sp)));
        Utils.mc.inGameHud.getChatHud().addMessage(createText("Version", getVersion(sp)));
        return SINGLE_SUCCESS;
    });
}
Also used : LiteralText(net.minecraft.text.LiteralText)

Aggregations

LiteralText (net.minecraft.text.LiteralText)249 Text (net.minecraft.text.Text)63 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)51 ItemStack (net.minecraft.item.ItemStack)37 ServerCommandSource (net.minecraft.server.command.ServerCommandSource)34 TranslatableText (net.minecraft.text.TranslatableText)32 MutableText (net.minecraft.text.MutableText)28 BaseText (net.minecraft.text.BaseText)26 NbtCompound (net.minecraft.nbt.NbtCompound)24 HoverEvent (net.minecraft.text.HoverEvent)24 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)23 Screen (net.minecraft.client.gui.screen.Screen)21 ClickEvent (net.minecraft.text.ClickEvent)20 MatrixStack (net.minecraft.client.util.math.MatrixStack)19 Formatting (net.minecraft.util.Formatting)19 Items (net.minecraft.item.Items)18 Inject (org.spongepowered.asm.mixin.injection.Inject)18 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)17 List (java.util.List)16 Identifier (net.minecraft.util.Identifier)15