Вопрос Как сделать нормальное отображение времени?

  • Автор темы Автор темы Kluykva
  • Дата начала Дата начала
Начинающий
Начинающий
Статус
Оффлайн
Регистрация
14 Апр 2025
Сообщения
6
Реакции
0

Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:

  • бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
  • маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
  • приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
  • обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.

Спасибо!

Привет! Я туплю пиздец, я понимаю что эксперты пастинга будут меня пинать, но надеюсь что мне кто-то поможет.
Короче у меня есть код который оформлен под мой худ а так же да, это база экспы 3.1. Мне нужна помощь с отображением времени, я не понимаю как сделать его нормальным, чтобы оно отображалось как в дельте: 00:00. Помогите вот код:

Java:
Expand Collapse Copy
package expensive.display.display.impl;

import com.mojang.blaze3d.matrix.MatrixStack;
import expensive.display.display.ElementRenderer;
import expensive.display.styles.Style;
import expensive.events.EventDisplay;
import expensive.main.Expensive;
import expensive.modules.impl.render.HUD;
import expensive.util.client.draggings.Dragging;
import expensive.util.math.main.Vector4i;
import expensive.util.visual.main.color.ColorUtils;
import expensive.util.visual.main.display.DisplayUtils;
import expensive.util.visual.main.fonts.Fonts;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.math.vector.Vector4f;

import java.util.ArrayList;
import java.util.List;

@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class CooldownRenderer implements ElementRenderer {
    final Dragging dragging;
    float width = 100;
    float height = 20;
    float yOff;
    final float ITEM_SCALE = 0.75f;
    final float ITEM_X_OFFSET = 8f;

    private static final Item[] TRACKED_ITEMS = {
            Items.ENDER_PEARL,
            Items.CHORUS_FRUIT,
            Items.SUGAR,
            Items.GOLDEN_APPLE,
            Items.ENCHANTED_GOLDEN_APPLE,
            Items.TOTEM_OF_UNDYING,
            Items.ENDER_EYE,
            Items.SNOWBALL,
            Items.DRIED_KELP,
            Items.NETHERITE_SCRAP,
            Items.TRIDENT,
            Items.BOW,
            Items.CROSSBOW
    };

    @Override
    public void render(EventDisplay eventDisplay) {
        MatrixStack matrix = eventDisplay.getMatrixStack();
        float x = dragging.getX();
        float y = dragging.getY();
        float round = 6;
        Style style = Expensive.getInstance().getStyleManager().getCurrentStyle();

        Vector4i colors = new Vector4i(
                style.getFirstColor().getRGB(),
                style.getFirstColor().getRGB(),
                style.getSecondColor().getRGB(),
                style.getSecondColor().getRGB()
        );

        int activeCooldowns = 0;
        float maxWidth = Fonts.sfui.getWidth("CooldownList", 8) + 20;
        List<Item> activeItems = new ArrayList<>();

        for (Item item : TRACKED_ITEMS) {
            if (hasCooldown(item)) {
                activeItems.add(item);
                String itemName = getReadableName(item);
                String timeLeft = formatTime(item);

                float totalWidth = 30 + Fonts.sfui.getWidth(itemName, 7)
                        + 15 + Fonts.sfui.getWidth(timeLeft, 7);

                maxWidth = Math.max(maxWidth, totalWidth);
                activeCooldowns++;
            }
        }

        height = 20 + (activeCooldowns > 0 ? activeCooldowns * 18 : 0);

        DisplayUtils.drawShadow(x, y, width, height, 10, ColorUtils.rgba(0, 0, 0, 255));
        DisplayUtils.drawRoundedRect(x, y, width, height, new Vector4f(round, round, round, round), colors);
        DisplayUtils.drawRoundedRect(x, y, width, height, new Vector4f(round - 0.7f, round - 0.7f, round - 0.7f, round - 0.7f),
                ColorUtils.rgba(21, 21, 21, 245));

        Fonts.sfui.drawText(matrix, "Cooldown",
                x + (width - Fonts.sfui.getWidth("CooldownList", 8)) / 2,
                y + 4.5f,
                ColorUtils.rgba(255, 255, 255, 255), 8);

        Fonts.sfui.drawText(matrix, "List",
                x + (width + Fonts.sfui.getWidth("Cooldown", 8) - Fonts.sfui.getWidth("List", 8)) / 2 + 1,
                y + 4.5f,
                ColorUtils.setAlpha(HUD.getColor(0), 240), 8);

        if (activeCooldowns > 0) {
            DisplayUtils.drawRectHorizontalW(x + 5, y + 18, width - 10, 1, 1,
                    ColorUtils.setAlpha(HUD.getColor(0), 180));

            ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
            float currentY = y + 20;

            for (Item item : activeItems) {
                String itemName = getReadableName(item);
                String timeLeft = formatTime(item);

                itemRenderer.renderItemAndEffectIntoGUI(
                        new ItemStack(item),
                        (int)(x + 8),
                        (int)currentY
                );

                Fonts.sfui.drawText(matrix, itemName,
                        x + 30,
                        currentY + 4,
                        ColorUtils.rgba(220, 220, 220, 255), 7);

                // Отрисовка времени
                float timeX = x + width - Fonts.sfui.getWidth(timeLeft, 7) - 5;
                Fonts.sfui.drawText(matrix, timeLeft,
                        timeX,
                        currentY + 4,
                        ColorUtils.setAlpha(HUD.getColor(0), 255), 7);

                currentY += 16;
            }
        }

        this.width = Math.max(maxWidth, 100);
        dragging.setWidth(width);
        dragging.setHeight(height);
    }

    private boolean hasCooldown(Item item) {
        return Minecraft.getInstance().player != null &&
                Minecraft.getInstance().player.getCooldownTracker().hasCooldown(item);
    }

    private String getReadableName(Item item) {
        if (item == Items.GOLDEN_APPLE) return "Гепл";
        if (item == Items.ENCHANTED_GOLDEN_APPLE) return "Чарка";
        if (item == Items.ENDER_PEARL) return "Пёрка";
        if (item == Items.CHORUS_FRUIT) return "Хорус";
        if (item == Items.NETHERITE_SCRAP) return "Трапка";
        if (item == Items.SUGAR) return "Явка";
        if (item == Items.CROSSBOW) return "Арбалет";
        if (item == Items.BOW) return "Лук";
        if (item == Items.TRIDENT) return "Трезубец";
        if (item == Items.DRIED_KELP) return "Пласт";
        if (item == Items.ENDER_EYE) return "Дезка";
        if (item == Items.TOTEM_OF_UNDYING) return "Тотем";
        if (item == Items.SNOWBALL) return "Снежок";
        return new ItemStack(item).getDisplayName().getString();
    }

    private String formatTime(Item item) {
        if (!hasCooldown(item)) return "0.0s";

        float cooldownProgress = Minecraft.getInstance().player.getCooldownTracker().getCooldown(item, 0);

        float secondsLeft = cooldownProgress;

        if (secondsLeft < 60f) {
            return String.format("%.1fs", secondsLeft);
        }
        else {
            int minutes = (int) (secondsLeft / 60);
            int seconds = (int) (secondsLeft % 60);
            return String.format("%02d:%02d", minutes, seconds);
        }
    }
}
 
руками
Привет! Я туплю пиздец, я понимаю что эксперты пастинга будут меня пинать, но надеюсь что мне кто-то поможет.
Короче у меня есть код который оформлен под мой худ а так же да, это база экспы 3.1. Мне нужна помощь с отображением времени, я не понимаю как сделать его нормальным, чтобы оно отображалось как в дельте: 00:00. Помогите вот код:

Java:
Expand Collapse Copy
package expensive.display.display.impl;

import com.mojang.blaze3d.matrix.MatrixStack;
import expensive.display.display.ElementRenderer;
import expensive.display.styles.Style;
import expensive.events.EventDisplay;
import expensive.main.Expensive;
import expensive.modules.impl.render.HUD;
import expensive.util.client.draggings.Dragging;
import expensive.util.math.main.Vector4i;
import expensive.util.visual.main.color.ColorUtils;
import expensive.util.visual.main.display.DisplayUtils;
import expensive.util.visual.main.fonts.Fonts;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.math.vector.Vector4f;

import java.util.ArrayList;
import java.util.List;

@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class CooldownRenderer implements ElementRenderer {
    final Dragging dragging;
    float width = 100;
    float height = 20;
    float yOff;
    final float ITEM_SCALE = 0.75f;
    final float ITEM_X_OFFSET = 8f;

    private static final Item[] TRACKED_ITEMS = {
            Items.ENDER_PEARL,
            Items.CHORUS_FRUIT,
            Items.SUGAR,
            Items.GOLDEN_APPLE,
            Items.ENCHANTED_GOLDEN_APPLE,
            Items.TOTEM_OF_UNDYING,
            Items.ENDER_EYE,
            Items.SNOWBALL,
            Items.DRIED_KELP,
            Items.NETHERITE_SCRAP,
            Items.TRIDENT,
            Items.BOW,
            Items.CROSSBOW
    };

    @Override
    public void render(EventDisplay eventDisplay) {
        MatrixStack matrix = eventDisplay.getMatrixStack();
        float x = dragging.getX();
        float y = dragging.getY();
        float round = 6;
        Style style = Expensive.getInstance().getStyleManager().getCurrentStyle();

        Vector4i colors = new Vector4i(
                style.getFirstColor().getRGB(),
                style.getFirstColor().getRGB(),
                style.getSecondColor().getRGB(),
                style.getSecondColor().getRGB()
        );

        int activeCooldowns = 0;
        float maxWidth = Fonts.sfui.getWidth("CooldownList", 8) + 20;
        List<Item> activeItems = new ArrayList<>();

        for (Item item : TRACKED_ITEMS) {
            if (hasCooldown(item)) {
                activeItems.add(item);
                String itemName = getReadableName(item);
                String timeLeft = formatTime(item);

                float totalWidth = 30 + Fonts.sfui.getWidth(itemName, 7)
                        + 15 + Fonts.sfui.getWidth(timeLeft, 7);

                maxWidth = Math.max(maxWidth, totalWidth);
                activeCooldowns++;
            }
        }

        height = 20 + (activeCooldowns > 0 ? activeCooldowns * 18 : 0);

        DisplayUtils.drawShadow(x, y, width, height, 10, ColorUtils.rgba(0, 0, 0, 255));
        DisplayUtils.drawRoundedRect(x, y, width, height, new Vector4f(round, round, round, round), colors);
        DisplayUtils.drawRoundedRect(x, y, width, height, new Vector4f(round - 0.7f, round - 0.7f, round - 0.7f, round - 0.7f),
                ColorUtils.rgba(21, 21, 21, 245));

        Fonts.sfui.drawText(matrix, "Cooldown",
                x + (width - Fonts.sfui.getWidth("CooldownList", 8)) / 2,
                y + 4.5f,
                ColorUtils.rgba(255, 255, 255, 255), 8);

        Fonts.sfui.drawText(matrix, "List",
                x + (width + Fonts.sfui.getWidth("Cooldown", 8) - Fonts.sfui.getWidth("List", 8)) / 2 + 1,
                y + 4.5f,
                ColorUtils.setAlpha(HUD.getColor(0), 240), 8);

        if (activeCooldowns > 0) {
            DisplayUtils.drawRectHorizontalW(x + 5, y + 18, width - 10, 1, 1,
                    ColorUtils.setAlpha(HUD.getColor(0), 180));

            ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
            float currentY = y + 20;

            for (Item item : activeItems) {
                String itemName = getReadableName(item);
                String timeLeft = formatTime(item);

                itemRenderer.renderItemAndEffectIntoGUI(
                        new ItemStack(item),
                        (int)(x + 8),
                        (int)currentY
                );

                Fonts.sfui.drawText(matrix, itemName,
                        x + 30,
                        currentY + 4,
                        ColorUtils.rgba(220, 220, 220, 255), 7);

                // Отрисовка времени
                float timeX = x + width - Fonts.sfui.getWidth(timeLeft, 7) - 5;
                Fonts.sfui.drawText(matrix, timeLeft,
                        timeX,
                        currentY + 4,
                        ColorUtils.setAlpha(HUD.getColor(0), 255), 7);

                currentY += 16;
            }
        }

        this.width = Math.max(maxWidth, 100);
        dragging.setWidth(width);
        dragging.setHeight(height);
    }

    private boolean hasCooldown(Item item) {
        return Minecraft.getInstance().player != null &&
                Minecraft.getInstance().player.getCooldownTracker().hasCooldown(item);
    }

    private String getReadableName(Item item) {
        if (item == Items.GOLDEN_APPLE) return "Гепл";
        if (item == Items.ENCHANTED_GOLDEN_APPLE) return "Чарка";
        if (item == Items.ENDER_PEARL) return "Пёрка";
        if (item == Items.CHORUS_FRUIT) return "Хорус";
        if (item == Items.NETHERITE_SCRAP) return "Трапка";
        if (item == Items.SUGAR) return "Явка";
        if (item == Items.CROSSBOW) return "Арбалет";
        if (item == Items.BOW) return "Лук";
        if (item == Items.TRIDENT) return "Трезубец";
        if (item == Items.DRIED_KELP) return "Пласт";
        if (item == Items.ENDER_EYE) return "Дезка";
        if (item == Items.TOTEM_OF_UNDYING) return "Тотем";
        if (item == Items.SNOWBALL) return "Снежок";
        return new ItemStack(item).getDisplayName().getString();
    }

    private String formatTime(Item item) {
        if (!hasCooldown(item)) return "0.0s";

        float cooldownProgress = Minecraft.getInstance().player.getCooldownTracker().getCooldown(item, 0);

        float secondsLeft = cooldownProgress;

        if (secondsLeft < 60f) {
            return String.format("%.1fs", secondsLeft);
        }
        else {
            int minutes = (int) (secondsLeft / 60);
            int seconds = (int) (secondsLeft % 60);
            return String.format("%02d:%02d", minutes, seconds);
        }
    }
}
 
Блять либо сделать лист с предметами и их кд либо сделай логику вычисления например сравнивай сколько тиков прошло между старым и новым кд с этого значения спокойно гетаешь время
 
Назад
Сверху Снизу