• Ищем качественного (не новичок) разработчиков Xenforo для этого форума! В идеале, чтобы ты был фулл стек программистом. Если у тебя есть что показать, то свяжись с нами по контактным данным: https://t.me/DREDD

Вопрос Не показывает время в кулдаунах

  • Автор темы Автор темы patrikx
  • Дата начала Дата начала
Начинающий
Начинающий
Статус
Оффлайн
Регистрация
15 Мар 2025
Сообщения
4
Реакции
0
напастил жоские кулдауны время показывает 0 секунд
Java:
Expand Collapse Copy
[USER=1367676]@override[/USER]
    public void render(EventDisplay eventDisplay) {
        MatrixStack ms = eventDisplay.getMatrixStack();
        float posX = dragging.getX();
        float posY = dragging.getY();
        float fontSize = 8;
        float padding = 5;
        int iconcolor = ColorUtils.rgb(190, 185, 255);

        drawStyledRect(posX, posY, width, height, 4);
        Scissor.push();
        Scissor.setFromComponentCoordinates(posX, posY, width, height);
      
        Fonts.sfui.drawText(ms, "Cooldowns", posX + 18, posY + 5.5f, ColorUtils.rgba(255, 255, 255, 255), fontSize);

        posY += fontSize + padding * 2;
        float maxWidth = Fonts.sfui.getWidth("Cooldowns", fontSize) + padding * 2;
        float localHeight = fontSize + padding * 2;
        posY += 3f;

        for (Item item : Registry.ITEM) {
            float cooldown = mc.player.getCooldownTracker().getCooldown(item, mc.getRenderPartialTicks());
            if (cooldown > 0) {
                String itemName = new ItemStack(item).getDisplayName().getString();
                String cooldownText = String.format("%.1fs", cooldown * item.getUseDuration(new ItemStack(item)) / 20f);

                float nameWidth = Fonts.sfui.getWidth(itemName, fontSize);
                float cooldownWidth = Fonts.sfui.getWidth(cooldownText, fontSize);
                float iconSize = 10;
                float iconPadding = 2;
                float totalWidth = nameWidth + cooldownWidth + padding * 3 + iconSize + iconPadding;
                float rectHeight = fontSize + padding;

                DisplayUtils.drawRoundedRect(
                        posX + 2,
                        posY - padding / 2 - 2,
                        width - 4,
                        rectHeight + 1,
                        2,
                        ColorUtils.rgba(255, 255, 255, 15)
                );

                drawItemIcon(new ItemStack(item), posX + padding, posY - 2, iconSize, iconSize);

                Fonts.sfui.drawText(ms, itemName, posX + padding + iconSize + iconPadding * 2, posY - 1,
                        ColorUtils.rgba(255, 255, 255, 255), fontSize);
                Fonts.sfui.drawText(ms, cooldownText, posX + width - padding - cooldownWidth, posY - 1,
                        ColorUtils.rgba(255, 255, 255, 255), fontSize);

                if (totalWidth > maxWidth) {
                    maxWidth = totalWidth;
                }

                posY += (fontSize + padding + 2);
                localHeight += (fontSize + padding + 2);
            }
        }

        Scissor.pop();
        width = Math.max(maxWidth, 85);
        height = localHeight + 1.5f;
        dragging.setWidth(width);
        dragging.setHeight(height);
    }
 
напастил жоские кулдауны время показывает 0 секунд
Java:
Expand Collapse Copy
[USER=1367676]@override[/USER]
    public void render(EventDisplay eventDisplay) {
        MatrixStack ms = eventDisplay.getMatrixStack();
        float posX = dragging.getX();
        float posY = dragging.getY();
        float fontSize = 8;
        float padding = 5;
        int iconcolor = ColorUtils.rgb(190, 185, 255);

        drawStyledRect(posX, posY, width, height, 4);
        Scissor.push();
        Scissor.setFromComponentCoordinates(posX, posY, width, height);
     
        Fonts.sfui.drawText(ms, "Cooldowns", posX + 18, posY + 5.5f, ColorUtils.rgba(255, 255, 255, 255), fontSize);

        posY += fontSize + padding * 2;
        float maxWidth = Fonts.sfui.getWidth("Cooldowns", fontSize) + padding * 2;
        float localHeight = fontSize + padding * 2;
        posY += 3f;

        for (Item item : Registry.ITEM) {
            float cooldown = mc.player.getCooldownTracker().getCooldown(item, mc.getRenderPartialTicks());
            if (cooldown > 0) {
                String itemName = new ItemStack(item).getDisplayName().getString();
                String cooldownText = String.format("%.1fs", cooldown * item.getUseDuration(new ItemStack(item)) / 20f);

                float nameWidth = Fonts.sfui.getWidth(itemName, fontSize);
                float cooldownWidth = Fonts.sfui.getWidth(cooldownText, fontSize);
                float iconSize = 10;
                float iconPadding = 2;
                float totalWidth = nameWidth + cooldownWidth + padding * 3 + iconSize + iconPadding;
                float rectHeight = fontSize + padding;

                DisplayUtils.drawRoundedRect(
                        posX + 2,
                        posY - padding / 2 - 2,
                        width - 4,
                        rectHeight + 1,
                        2,
                        ColorUtils.rgba(255, 255, 255, 15)
                );

                drawItemIcon(new ItemStack(item), posX + padding, posY - 2, iconSize, iconSize);

                Fonts.sfui.drawText(ms, itemName, posX + padding + iconSize + iconPadding * 2, posY - 1,
                        ColorUtils.rgba(255, 255, 255, 255), fontSize);
                Fonts.sfui.drawText(ms, cooldownText, posX + width - padding - cooldownWidth, posY - 1,
                        ColorUtils.rgba(255, 255, 255, 255), fontSize);

                if (totalWidth > maxWidth) {
                    maxWidth = totalWidth;
                }

                posY += (fontSize + padding + 2);
                localHeight += (fontSize + padding + 2);
            }
        }

        Scissor.pop();
        width = Math.max(maxWidth, 85);
        height = localHeight + 1.5f;
        dragging.setWidth(width);
        dragging.setHeight(height);
    }
И что это за говно?
 
@override
public void render(EventDisplay eventDisplay) {
MatrixStack ms = eventDisplay.getMatrixStack();
float posX = dragging.getX();
float posY = dragging.getY();
float fontSize = 8;
float padding = 5;
int iconColor = ColorUtils.rgb(190, 185, 255);

drawStyledRect(posX, posY, width, height, 4);
Scissor.push();
Scissor.setFromComponentCoordinates(posX, posY, width, height);

Fonts.sfui.drawText(ms, "Cooldowns", posX + 18, posY + 5.5f, ColorUtils.rgba(255, 255, 255, 255), fontSize);

posY += fontSize + padding * 2;
float maxWidth = Fonts.sfui.getWidth("Cooldowns", fontSize) + padding * 2;
float localHeight = fontSize + padding * 2;
posY += 3f;

for (Item item : Registry.ITEM) {
if (mc.player.getCooldownTracker().hasCooldown(item)) { // Проверка, есть ли кулдаун у предмета
float cooldown = mc.player.getCooldownTracker().getCooldown(item, mc.getRenderPartialTicks());
String itemName = new ItemStack(item).getDisplayName().getString();
float cooldownSeconds = cooldown * item.getUseDuration(new ItemStack(item)) / 20f;
String cooldownText = String.format("%.1fs", cooldownSeconds);

float nameWidth = Fonts.sfui.getWidth(itemName, fontSize);
float cooldownWidth = Fonts.sfui.getWidth(cooldownText, fontSize);
float iconSize = 10;
float iconPadding = 2;
float totalWidth = nameWidth + cooldownWidth + padding * 3 + iconSize + iconPadding;
float rectHeight = fontSize + padding;

DisplayUtils.drawRoundedRect(
posX + 2,
posY - padding / 2 - 2,
Math.max(width - 4, totalWidth), // Убедимся, что ширина корректная
rectHeight + 1,
2,
ColorUtils.rgba(255, 255, 255, 15)
);

drawItemIcon(new ItemStack(item), posX + padding, posY - 2, iconSize, iconSize);

Fonts.sfui.drawText(ms, itemName, posX + padding + iconSize + iconPadding * 2, posY - 1,
ColorUtils.rgba(255, 255, 255, 255), fontSize);
Fonts.sfui.drawText(ms, cooldownText, posX + width - padding - cooldownWidth, posY - 1,
ColorUtils.rgba(255, 255, 255, 255), fontSize);

if (totalWidth > maxWidth) {
maxWidth = totalWidth;
}

posY += (fontSize + padding + 2);
localHeight += (fontSize + padding + 2);
}
}

Scissor.pop();
width = Math.max(maxWidth, 85);
height = localHeight + 1.5f;
dragging.setWidth(width);
dragging.setHeight(height);
}


попробуй этот код, это немного исправленый твой код
 
Назад
Сверху Снизу