Подведи собственные итоги года совместно с YOUGAME и забери ценные призы! Перейти

BetterText [1.16.5]

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
8 Янв 2023
Сообщения
43
Реакции
1
Сливаю вам и так опен сурс который есть в рунете, но малоли кому нужен будет

Java:
Expand Collapse Copy
package air.sense.utils;

import air.sense.utils.math.TimerUtil;

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

public class BetterText {

    private List<String> texts = new ArrayList<>();


    public String output = "";

    private int delay = 0;

    public BetterText(List<String> texts, int delay) {
        this.texts = texts;
        this.delay = delay;
        start();
    }


    private TimerUtil timerUtil = new TimerUtil();

    public void start() {
        new Thread(() -> {
            try {
                int index = 0;
                while (true) {
                    for (int i = 0; i < texts.get(index).length(); i++) {
                        output += texts.get(index).charAt(i);
                        Thread.sleep(100);
                    }
                    Thread.sleep(delay);
                    for (int i = output.length(); i >= 0; i--) {
                        output = output.substring(0, i);
                        Thread.sleep(60);
                    }
                    if (index >= texts.size() - 1) {
                        index = 0;
                    }
                    index += 1;
                    Thread.sleep(400);
                }
            }
            catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }).start();
    }

}

пример использования

Java:
Expand Collapse Copy
    private BetterText text = new BetterText(Arrays.asList("думаю...", "запускаю..."), 800);

            Fonts.msMedium[20].drawCenteredString(matrixStack, text.output, width / 2f, height / 2f + 50, ColorUtil.rgba(255, 255, 255, 255));
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
ss?
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Сливаю вам и так опен сурс который есть в рунете, но малоли кому нужен будет

Java:
Expand Collapse Copy
package air.sense.utils;

import air.sense.utils.math.TimerUtil;

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

public class BetterText {

    private List<String> texts = new ArrayList<>();


    public String output = "";

    private int delay = 0;

    public BetterText(List<String> texts, int delay) {
        this.texts = texts;
        this.delay = delay;
        start();
    }


    private TimerUtil timerUtil = new TimerUtil();

    public void start() {
        new Thread(() -> {
            try {
                int index = 0;
                while (true) {
                    for (int i = 0; i < texts.get(index).length(); i++) {
                        output += texts.get(index).charAt(i);
                        Thread.sleep(100);
                    }
                    Thread.sleep(delay);
                    for (int i = output.length(); i >= 0; i--) {
                        output = output.substring(0, i);
                        Thread.sleep(60);
                    }
                    if (index >= texts.size() - 1) {
                        index = 0;
                    }
                    index += 1;
                    Thread.sleep(400);
                }
            }
            catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }).start();
    }

}

пример использования

Java:
Expand Collapse Copy
    private BetterText text = new BetterText(Arrays.asList("думаю...", "запускаю..."), 800);

            Fonts.msMedium[20].drawCenteredString(matrixStack, text.output, width / 2f, height / 2f + 50, ColorUtil.rgba(255, 255, 255, 255));
а что оно делает вообще я не понимаю!
 
а что оно делает вообще я не понимаю!
Перебирает символы текущего выделенного текста в списке текстов и с задержкой добавляет их в выходную строку.
После отображения всего текста он с меньшей задержкой удаляет символы из выходной строки, фактически стирая текст.
После этого происходит циклический перебор текстов в списке и повторение процесса анимации.
Процесс анимации выглядит непрерывным и выполняется в отдельном потоке до тех пор, пока его не прервет исключение InterruptedException.
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
t
Сливаю вам и так опен сурс который есть в рунете, но малоли кому нужен будет

Java:
Expand Collapse Copy
package air.sense.utils;

import air.sense.utils.math.TimerUtil;

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

public class BetterText {

    private List<String> texts = new ArrayList<>();


    public String output = "";

    private int delay = 0;

    public BetterText(List<String> texts, int delay) {
        this.texts = texts;
        this.delay = delay;
        start();
    }


    private TimerUtil timerUtil = new TimerUtil();

    public void start() {
        new Thread(() -> {
            try {
                int index = 0;
                while (true) {
                    for (int i = 0; i < texts.get(index).length(); i++) {
                        output += texts.get(index).charAt(i);
                        Thread.sleep(100);
                    }
                    Thread.sleep(delay);
                    for (int i = output.length(); i >= 0; i--) {
                        output = output.substring(0, i);
                        Thread.sleep(60);
                    }
                    if (index >= texts.size() - 1) {
                        index = 0;
                    }
                    index += 1;
                    Thread.sleep(400);
                }
            }
            catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }).start();
    }

}

пример использования

Java:
Expand Collapse Copy
    private BetterText text = new BetterText(Arrays.asList("думаю...", "запускаю..."), 800);

            Fonts.msMedium[20].drawCenteredString(matrixStack, text.output, width / 2f, height / 2f + 50, ColorUtil.rgba(255, 255, 255, 255));
/del не работает
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
/del
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Братишка зачем ты так о себе?
1699023994088.png
 
покажите как работает все-таки?)
 
Назад
Сверху Снизу