Search in sources :

Example 86 with LiteralText

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

the class ClientPlayerEntityMixin method onChatMessage.

@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
public void onChatMessage(String message, CallbackInfo callbackInfo) {
    if (ignoreChatMessage)
        return;
    if (!message.startsWith(KiwiClient.PREFIX) && !message.startsWith("/")) {
        SendChatMessageEvent event = new SendChatMessageEvent(message);
        KiwiClient.eventBus.post(event);
        if (!event.isCancelled()) {
            ignoreChatMessage = true;
            sendChatMessage(event.message);
            ignoreChatMessage = false;
        }
        callbackInfo.cancel();
        return;
    }
    if (message.startsWith(KiwiClient.PREFIX)) {
        try {
            KiwiClient.commandManager.dispatch(message.substring(KiwiClient.PREFIX.length()));
        } catch (CommandSyntaxException e) {
            Utils.mc.inGameHud.getChatHud().addMessage(new LiteralText(e.getMessage()));
        }
        callbackInfo.cancel();
    }
}
Also used : SendChatMessageEvent(com.tangykiwi.kiwiclient.event.SendChatMessageEvent) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) LiteralText(net.minecraft.text.LiteralText) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 87 with LiteralText

use of net.minecraft.text.LiteralText in project CITResewn by SHsuperCM.

the class CITResewnConfigScreenFactory method create.

public static Screen create(Screen parent) {
    CITResewnConfig currentConfig = CITResewnConfig.INSTANCE(), defaultConfig = new CITResewnConfig();
    ConfigBuilder builder = ConfigBuilder.create().setParentScreen(parent).setTitle(new TranslatableText("config.citresewn.title")).setSavingRunnable(currentConfig::write);
    ConfigCategory category = builder.getOrCreateCategory(new LiteralText(""));
    ConfigEntryBuilder entryBuilder = builder.entryBuilder();
    category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.enabled.title"), currentConfig.enabled).setTooltip(new TranslatableText("config.citresewn.enabled.tooltip")).setSaveConsumer(newConfig -> {
        if (currentConfig.enabled != newConfig) {
            currentConfig.enabled = newConfig;
            MinecraftClient.getInstance().reloadResources();
        }
    }).setDefaultValue(defaultConfig.enabled).build());
    category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.mute_errors.title"), currentConfig.mute_errors).setTooltip(new TranslatableText("config.citresewn.mute_errors.tooltip")).setSaveConsumer(newConfig -> currentConfig.mute_errors = newConfig).setDefaultValue(defaultConfig.mute_errors).build());
    category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.mute_warns.title"), currentConfig.mute_warns).setTooltip(new TranslatableText("config.citresewn.mute_warns.tooltip")).setSaveConsumer(newConfig -> currentConfig.mute_warns = newConfig).setDefaultValue(defaultConfig.mute_warns).build());
    category.addEntry(entryBuilder.startFloatField(new TranslatableText("config.citresewn.citenchantment_scroll_multiplier.title"), currentConfig.citenchantment_scroll_multiplier).setTooltip(new TranslatableText("config.citresewn.citenchantment_scroll_multiplier.tooltip")).setSaveConsumer(newConfig -> currentConfig.citenchantment_scroll_multiplier = newConfig).setDefaultValue(defaultConfig.citenchantment_scroll_multiplier).setMin(0f).build());
    category.addEntry(entryBuilder.startIntSlider(new TranslatableText("config.citresewn.cache_ms.title"), currentConfig.cache_ms / 50, 0, 5 * 20).setTooltip(new TranslatableText("config.citresewn.cache_ms.tooltip")).setSaveConsumer(newConfig -> currentConfig.cache_ms = newConfig * 50).setDefaultValue(currentConfig.cache_ms / 50).setTextGetter(ticks -> {
        if (ticks <= 1)
            return new TranslatableText("config.citresewn.cache_ms.ticks." + ticks).formatted(Formatting.AQUA);
        Formatting color = Formatting.DARK_RED;
        if (ticks <= 40)
            color = Formatting.RED;
        if (ticks <= 20)
            color = Formatting.GOLD;
        if (ticks <= 10)
            color = Formatting.DARK_GREEN;
        if (ticks <= 5)
            color = Formatting.GREEN;
        return new TranslatableText("config.citresewn.cache_ms.ticks.any", ticks).formatted(color);
    }).build());
    category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.broken_paths.title"), currentConfig.broken_paths).setTooltip(new TranslatableText("config.citresewn.broken_paths.tooltip")).setSaveConsumer(newConfig -> currentConfig.broken_paths = newConfig).setDefaultValue(defaultConfig.broken_paths).requireRestart().build());
    return builder.build();
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) LiteralText(net.minecraft.text.LiteralText) Formatting(net.minecraft.util.Formatting) Screen(net.minecraft.client.gui.screen.Screen) TranslatableText(net.minecraft.text.TranslatableText) MinecraftClient(net.minecraft.client.MinecraftClient) ConfigBuilder(me.shedaniel.clothconfig2.api.ConfigBuilder) ConfigCategory(me.shedaniel.clothconfig2.api.ConfigCategory) ConfigEntryBuilder(me.shedaniel.clothconfig2.api.ConfigEntryBuilder) ConfigCategory(me.shedaniel.clothconfig2.api.ConfigCategory) Formatting(net.minecraft.util.Formatting) ConfigBuilder(me.shedaniel.clothconfig2.api.ConfigBuilder) ConfigEntryBuilder(me.shedaniel.clothconfig2.api.ConfigEntryBuilder) LiteralText(net.minecraft.text.LiteralText)

Example 88 with LiteralText

use of net.minecraft.text.LiteralText in project BedrockIfy by juancarloscp52.

the class Overlay method renderPositionText.

private void renderPositionText(MatrixStack matrixStack) {
    BedrockifySettings settings = Bedrockify.getInstance().settings;
    int screenBorder = settings.getScreenSafeArea();
    int posY = settings.getPositionHUDHeight();
    if (!settings.isShowPositionHUDEnabled())
        return;
    BlockPos blockPos = Objects.requireNonNull(this.client.getCameraEntity(), "Camera Entity cannot be null.").getBlockPos();
    MutableText position = new TranslatableText("bedrockify.hud.position").append(new LiteralText(" " + blockPos.getX() + ", " + blockPos.getY() + ", " + blockPos.getZ()));
    if (settings.getFPSHUDoption() == 1)
        position.append(" ").append(fps);
    int positionWidth = client.textRenderer.getWidth(position);
    fill(matrixStack, textPosX + screenBorder, posY + screenBorder, textPosX + positionWidth + 6 + screenBorder, posY + 10 + screenBorder, MathHelper.ceil((255.0D * client.options.textBackgroundOpacity)) << 24);
    client.textRenderer.drawWithShadow(matrixStack, position, textPosX + 3 + screenBorder, posY + 1 + screenBorder, 16777215);
}
Also used : MutableText(net.minecraft.text.MutableText) TranslatableText(net.minecraft.text.TranslatableText) BedrockifySettings(me.juancarloscp52.bedrockify.BedrockifySettings) BlockPos(net.minecraft.util.math.BlockPos) LiteralText(net.minecraft.text.LiteralText)

Example 89 with LiteralText

use of net.minecraft.text.LiteralText in project ImmersivePortalsMod by qouteall.

the class MyCommandClient method reportResourceConsumption.

private static int reportResourceConsumption(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
    StringBuilder str = new StringBuilder();
    str.append("Client Chunk:\n");
    CGlobal.clientWorldLoader.clientWorldMap.values().forEach(world -> {
        str.append(String.format("%s %s\n", world.dimension.getType(), ((MyClientChunkManager) world.getChunkManager()).getChunkNum()));
    });
    str.append("Chunk Renderers:\n");
    CGlobal.clientWorldLoader.worldRendererMap.forEach((dimension, worldRenderer) -> {
        str.append(String.format("%s %s\n", dimension, ((IEChunkRenderDispatcher) ((IEWorldRenderer) worldRenderer).getChunkRenderDispatcher()).getEmployedRendererNum()));
    });
    str.append("Server Chunks:\n");
    McHelper.getServer().getWorlds().forEach(world -> {
        str.append(String.format("%s %s\n", world.dimension.getType(), world.getForcedChunks().size()));
    });
    String result = str.toString();
    Helper.log(str);
    context.getSource().getPlayer().sendMessage(new LiteralText(result));
    return 0;
}
Also used : MyClientChunkManager(com.qouteall.immersive_portals.chunk_loading.MyClientChunkManager) LiteralText(net.minecraft.text.LiteralText)

Example 90 with LiteralText

use of net.minecraft.text.LiteralText in project pingspam by BasiqueEvangelist.

the class ServerPlayerEntityMixin method tick.

@Inject(method = "tick", at = @At("TAIL"))
private void tick(CallbackInfo ci) {
    if (pings.size() > 0 && PingSpam.CONFIG.getConfig().showUnreadMessagesInActionbar) {
        actionbarTime--;
        if (actionbarTime <= 0) {
            actionbarTime = ACTIONBAR_TIME;
            networkHandler.sendPacket(new TitleS2CPacket(TitleS2CPacket.Action.ACTIONBAR, new LiteralText("You have " + pings.size() + " unread message" + (pings.size() != 1 ? "s" : "") + ".")));
        }
    } else {
        actionbarTime = 0;
    }
}
Also used : TitleS2CPacket(net.minecraft.network.packet.s2c.play.TitleS2CPacket) LiteralText(net.minecraft.text.LiteralText) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

LiteralText (net.minecraft.text.LiteralText)316 Text (net.minecraft.text.Text)75 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)67 ServerCommandSource (net.minecraft.server.command.ServerCommandSource)43 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)39 ItemStack (net.minecraft.item.ItemStack)39 TranslatableText (net.minecraft.text.TranslatableText)39 Screen (net.minecraft.client.gui.screen.Screen)36 MutableText (net.minecraft.text.MutableText)35 MatrixStack (net.minecraft.client.util.math.MatrixStack)33 HoverEvent (net.minecraft.text.HoverEvent)29 BaseText (net.minecraft.text.BaseText)26 Formatting (net.minecraft.util.Formatting)25 NbtCompound (net.minecraft.nbt.NbtCompound)24 ClickEvent (net.minecraft.text.ClickEvent)24 Inject (org.spongepowered.asm.mixin.injection.Inject)23 TextFieldWidget (net.minecraft.client.gui.widget.TextFieldWidget)19 Items (net.minecraft.item.Items)19 ArrayList (java.util.ArrayList)18 MinecraftClient (net.minecraft.client.MinecraftClient)18