Исходник Notification nursultan nextgen(Expensive 2.0 ready)

Начинающий
Статус
Оффлайн
Регистрация
19 Ноя 2023
Сообщения
202
Реакции[?]
2
Поинты[?]
2K
Последнее редактирование:
Начинающий
Статус
Оффлайн
Регистрация
30 Июл 2023
Сообщения
337
Реакции[?]
2
Поинты[?]
1K
Java:
package ru.nettix.notification;

import com.mojang.blaze3d.matrix.MatrixStack;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.potion.EffectInstance;
import net.minecraft.util.math.vector.Vector4f;
import ru.nettix.managment.Managment;
import ru.nettix.util.font.Fonts;
import ru.nettix.util.render.ColorUtil;
import ru.nettix.util.render.RenderUtil;
import ru.nettix.util.animations.Animation;
import ru.nettix.util.animations.Direction;
import ru.nettix.util.animations.impl.DecelerateAnimation;
import ru.nettix.util.render.animation.AnimationMath;

import java.util.Comparator;
import java.util.concurrent.CopyOnWriteArrayList;

import static ru.nettix.util.IMinecraft.mc;
import static ru.nettix.util.render.ColorUtil.getColorStyle;
import static ru.nettix.util.render.ColorUtil.rgba;

public class NotificationManager {

    private final CopyOnWriteArrayList<Notification> notifications = new CopyOnWriteArrayList<>();

    public void add(String text, String content, int time) {
        notifications.add(new Notification(text, content, time));
    }


    public void draw(MatrixStack stack) {
        int yOffset = 0;
        for (Notification notification : notifications) {

            if (System.currentTimeMillis() - notification.getTime() > (notification.time2 * 1000L) - 300) {
                notification.animation.setDirection(Direction.BACKWARDS);
            } else {
                notification.yAnimation.setDirection(Direction.FORWARDS);
                notification.animation.setDirection(Direction.FORWARDS);
            }
            notification.alpha = (float) notification.animation.getOutput();
            if (System.currentTimeMillis() - notification.getTime() > notification.time2 * 1000L) {
                notification.yAnimation.setDirection(Direction.BACKWARDS);
            }
            if (notification.yAnimation.finished(Direction.BACKWARDS)) {
                notifications.remove(notification);
                continue;
            }
            float x = mc.getMainWindow().scaledWidth() - (Fonts.gilroyBold[14].getWidth(notification.getText()) + 8) - 10;
            float y = mc.getMainWindow().scaledHeight() - 30 -  (mc.player.getActivePotionEffects().stream().sorted(Comparator.comparing(EffectInstance::getDuration)).toList().size() * 16);
            notification.yAnimation.setEndPoint(yOffset);
            notification.yAnimation.setDuration(300);
            y -= (float) (notification.draw(stack) * notification.yAnimation.getOutput());
            notification.setX(x);
            notification.setY(AnimationMath.fast(notification.getY(), y, 15));
            yOffset++;
        }
    }


    private class Notification {
        @Getter
        @Setter
        private float x, y = mc.getMainWindow().scaledHeight() + 24;

        @Getter
        private String text;
        @Getter
        private String content;

        @Getter
        private long time = System.currentTimeMillis();

        public Animation animation = new DecelerateAnimation(500, 1, Direction.FORWARDS);
        public Animation yAnimation = new DecelerateAnimation(500, 1, Direction.FORWARDS);
        float alpha;
        int time2 = 3;

        public Notification(String text, String content, int time) {
            this.text = text;
            this.content = content;
            time2 = time;
        }

        public float draw(MatrixStack stack) {
            float width = Fonts.gilroyBold[14].getWidth(text) + 8;

            int firstColor = RenderUtil.reAlphaInt(Managment.STYLE_MANAGER.getCurrentStyle().getColor(0), (int) (255 * alpha));
            int secondColor = RenderUtil.reAlphaInt(Managment.STYLE_MANAGER.getCurrentStyle().getColor(100), (int) (255 * alpha));
            int thirdColor = RenderUtil.reAlphaInt(Managment.STYLE_MANAGER.getCurrentStyle().getColor(0), (int) (255 * alpha));
            int fourthColor = RenderUtil.reAlphaInt(Managment.STYLE_MANAGER.getCurrentStyle().getColor(100), (int) (255 * alpha));

            if (Managment.FUNCTION_MANAGER.hud2.shadow.get())
                RenderUtil.Render2D.drawShadow(x - 30, y, width + 30, 20, 10, getColorStyle(40));
            RenderUtil.Render2D.drawRoundedRect(x - 30, y, width + 30, 20, 3, ColorUtil.rgba(0, 0, 0, 255 * alpha));

            Fonts.msMedium[14].drawString(stack, content, x + 4 - 30, y + 5, RenderUtil.reAlphaInt(-1, (int) (255 * alpha)));
            Fonts.msMedium[12].drawString(stack, text, x + 4 - 30, y + 13, RenderUtil.reAlphaInt(-1, (int) (255 * alpha)));
            return 24;
        }
    }
}
Оригинал:Посмотреть вложение 264128
Моё: Посмотреть вложение 264129
Только не бейте палками пж
лучший первая паста текста без ошибок от души
 
Начинающий
Статус
Оффлайн
Регистрация
4 Июл 2024
Сообщения
319
Реакции[?]
0
Поинты[?]
0
Java:
package ru.nettix.notification;

import com.mojang.blaze3d.matrix.MatrixStack;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.potion.EffectInstance;
import net.minecraft.util.math.vector.Vector4f;
import ru.nettix.managment.Managment;
import ru.nettix.util.font.Fonts;
import ru.nettix.util.render.ColorUtil;
import ru.nettix.util.render.RenderUtil;
import ru.nettix.util.animations.Animation;
import ru.nettix.util.animations.Direction;
import ru.nettix.util.animations.impl.DecelerateAnimation;
import ru.nettix.util.render.animation.AnimationMath;

import java.util.Comparator;
import java.util.concurrent.CopyOnWriteArrayList;

import static ru.nettix.util.IMinecraft.mc;
import static ru.nettix.util.render.ColorUtil.getColorStyle;
import static ru.nettix.util.render.ColorUtil.rgba;

public class NotificationManager {

    private final CopyOnWriteArrayList<Notification> notifications = new CopyOnWriteArrayList<>();

    public void add(String text, String content, int time) {
        notifications.add(new Notification(text, content, time));
    }


    public void draw(MatrixStack stack) {
        int yOffset = 0;
        for (Notification notification : notifications) {

            if (System.currentTimeMillis() - notification.getTime() > (notification.time2 * 1000L) - 300) {
                notification.animation.setDirection(Direction.BACKWARDS);
            } else {
                notification.yAnimation.setDirection(Direction.FORWARDS);
                notification.animation.setDirection(Direction.FORWARDS);
            }
            notification.alpha = (float) notification.animation.getOutput();
            if (System.currentTimeMillis() - notification.getTime() > notification.time2 * 1000L) {
                notification.yAnimation.setDirection(Direction.BACKWARDS);
            }
            if (notification.yAnimation.finished(Direction.BACKWARDS)) {
                notifications.remove(notification);
                continue;
            }
            float x = mc.getMainWindow().scaledWidth() - (Fonts.gilroyBold[14].getWidth(notification.getText()) + 8) - 10;
            float y = mc.getMainWindow().scaledHeight() - 30 -  (mc.player.getActivePotionEffects().stream().sorted(Comparator.comparing(EffectInstance::getDuration)).toList().size() * 16);
            notification.yAnimation.setEndPoint(yOffset);
            notification.yAnimation.setDuration(300);
            y -= (float) (notification.draw(stack) * notification.yAnimation.getOutput());
            notification.setX(x);
            notification.setY(AnimationMath.fast(notification.getY(), y, 15));
            yOffset++;
        }
    }


    private class Notification {
        @Getter
        @Setter
        private float x, y = mc.getMainWindow().scaledHeight() + 24;

        @Getter
        private String text;
        @Getter
        private String content;

        @Getter
        private long time = System.currentTimeMillis();

        public Animation animation = new DecelerateAnimation(500, 1, Direction.FORWARDS);
        public Animation yAnimation = new DecelerateAnimation(500, 1, Direction.FORWARDS);
        float alpha;
        int time2 = 3;

        public Notification(String text, String content, int time) {
            this.text = text;
            this.content = content;
            time2 = time;
        }

        public float draw(MatrixStack stack) {
            float width = Fonts.gilroyBold[14].getWidth(text) + 8;

            int firstColor = RenderUtil.reAlphaInt(Managment.STYLE_MANAGER.getCurrentStyle().getColor(0), (int) (255 * alpha));
            int secondColor = RenderUtil.reAlphaInt(Managment.STYLE_MANAGER.getCurrentStyle().getColor(100), (int) (255 * alpha));
            int thirdColor = RenderUtil.reAlphaInt(Managment.STYLE_MANAGER.getCurrentStyle().getColor(0), (int) (255 * alpha));
            int fourthColor = RenderUtil.reAlphaInt(Managment.STYLE_MANAGER.getCurrentStyle().getColor(100), (int) (255 * alpha));

            if (Managment.FUNCTION_MANAGER.hud2.shadow.get())
                RenderUtil.Render2D.drawShadow(x - 30, y, width + 30, 20, 10, getColorStyle(40));
            RenderUtil.Render2D.drawRoundedRect(x - 30, y, width + 30, 20, 3, ColorUtil.rgba(0, 0, 0, 255 * alpha));

            Fonts.msMedium[14].drawString(stack, content, x + 4 - 30, y + 5, RenderUtil.reAlphaInt(-1, (int) (255 * alpha)));
            Fonts.msMedium[12].drawString(stack, text, x + 4 - 30, y + 13, RenderUtil.reAlphaInt(-1, (int) (255 * alpha)));
            return 24;
        }
    }
}
Оригинал:Посмотреть вложение 264128
Моё: Посмотреть вложение 264129
Только не бейте палками пж
опять сигма нот пастеры оскаюл начинающих
 
Сверху Снизу