Гайд Notifications | Expensive 3.1

Начинающий
Статус
Оффлайн
Регистрация
10 Май 2023
Сообщения
515
Реакции[?]
8
Поинты[?]
3K
Запастил с невернайгта, короче по пути: src/im/expensive/ui/ создаем класс NotificationManager, туда вставляем этот код:



Java:
package fun.ellant.ui;

import com.mojang.blaze3d.matrix.MatrixStack;
import java.util.concurrent.CopyOnWriteArrayList;
import net.minecraft.util.ResourceLocation;
import fun.ellant.utils.animations.Animation;
import fun.ellant.utils.animations.Direction;
import fun.ellant.utils.animations.impl.EaseBackIn;
import fun.ellant.utils.animations.impl.EaseInOutQuad;
import fun.ellant.utils.client.IMinecraft;
import fun.ellant.utils.math.MathUtil;
import fun.ellant.utils.render.ColorUtils;
import fun.ellant.utils.render.DisplayUtils;
import fun.ellant.utils.render.font.Fonts;

public class NotificationManager {
    private final CopyOnWriteArrayList<Notification> notifications = new CopyOnWriteArrayList();
    private MathUtil AnimationMath;
    private ImageType imageType;
    boolean state;

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

    public void draw(MatrixStack stack) {
        int yOffset = 0;
        for (Notification notification : this.notifications) {
            if (System.currentTimeMillis() - notification.getTime() <= (long)notification.time2 * 1000L - 300L) {
                notification.yAnimation.setDirection(Direction.FORWARDS);
            }
            notification.alpha = (float)notification.animation.getOutput();
            if (System.currentTimeMillis() - notification.getTime() > (long)notification.time2 * 1000L) {
                notification.yAnimation.setDirection(Direction.BACKWARDS);
            }
            if (notification.yAnimation.finished(Direction.BACKWARDS)) {
                this.notifications.remove(notification);
                continue;
            }
            float x = (float)IMinecraft.mc.getMainWindow().scaledWidth() - (Fonts.sfMedium.getWidth(notification.getText(), 7.0f) + 8.0f) - 10.0f;
            float y = IMinecraft.mc.getMainWindow().scaledHeight() - 40;
            notification.yAnimation.setEndPoint(yOffset);
            notification.yAnimation.setDuration(500);
            notification.setX(x);
            notification.setY(MathUtil.fast(notification.getY(), y -= (float)((double)notification.draw(stack) * notification.yAnimation.getOutput() + 3.0), 15.0f));
            ++yOffset;
        }
    }

    private class Notification {
        private float x = 0.0f;
        private float y = IMinecraft.mc.getMainWindow().scaledHeight() + 24;
        private String text;
        private String content;
        private long time = System.currentTimeMillis();
        public Animation animation = new EaseInOutQuad(500, 1.0, Direction.FORWARDS);
        public Animation yAnimation = new EaseBackIn(500, 1.0, 1.0f);
        private ImageType imageType;
        float alpha;
        int time2 = 3;
        private boolean isState;
        private boolean state;

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

        public float draw(MatrixStack stack) {
            float width = Fonts.sfMedium.getWidth(this.text, 7.0f) + 8.0f;
            DisplayUtils.drawRoundedRect(this.x - 427.0f + 50.0f, this.y - 25.0f, width + 27.0f, 13.0f, 3.0f, ColorUtils.rgb(23, 22, 22));
            DisplayUtils.drawShadow(this.x - 427.0f + 50.0f, this.y - 25.0f, width + 27.0f, 13.0f, 3, ColorUtils.rgb(23, 22, 22));
            if (this.imageType == ImageType.FIRST_PHOTO) {
                ResourceLocation key = new ResourceLocation("expensive/images/hud/notify.png");
                DisplayUtils.drawImage(key, this.x - 424.0f + 50.0f, this.y - 26.5f, 16.0f, 16.0f, ColorUtils.rgb(255, 0, 0));
            } else {
                ResourceLocation key1 = new ResourceLocation("expensive/images/hud/notify2.png");
                DisplayUtils.drawImage(key1, this.x - 424.0f + 50.0f, this.y - 26.5f, 16.0f, 16.0f, ColorUtils.rgb(0, 255, 0));
            }
            Fonts.montserrat.drawText(stack, this.text, this.x - 407.0f + 50.0f, this.y - 22.0f, -1, 7.0f, 0.05f);
            int enabledColor = ColorUtils.rgba(0, 255, 0, 255);
            int disabledColor = ColorUtils.rgba(255, 0, 0, 255);
            int contentColor = this.state ? enabledColor : disabledColor;
            Fonts.sfMedium.drawText(stack, this.content, this.x, this.y, ColorUtils.rgb(0, 255, 0), 4.0f, 0.05f);
            return 24.0f;
        }

        public float getX() {
            return this.x;
        }

        public float getY() {
            return this.y;
        }

        public void setX(float x) {
            this.x = x;
        }

        public void setY(float y) {
            this.y = y;
        }

        public String getText() {
            return this.text;
        }

        public String getContent() {
            return this.content;
        }

        public long getTime() {
            return this.time;
        }
    }

    public static enum ImageType {
        FIRST_PHOTO,
        SECOND_PHOTO;

    }
}
UPDATEEEEEEE


Забыл сказать тоже важное, то что вы должны сделать

Переходим в im/expensive/ui/display/impl и тут создаём NotificationsRenderer, сюда вставляем:


Java:
/*
 * Decompiled with CFR 0.153-SNAPSHOT (d6f6758-dirty).
 */
package fun.ellant.ui.display.impl;

import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.Minecraft;
import net.minecraft.util.text.StringTextComponent;
import fun.ellant.Ellant;
import fun.ellant.events.EventDisplay;
import fun.ellant.functions.api.Function;
import fun.ellant.functions.api.FunctionRegistry;
import fun.ellant.ui.display.ElementRenderer;
import fun.ellant.ui.styles.Style;
import fun.ellant.utils.render.ColorUtils;
import fun.ellant.utils.render.DisplayUtils;
import fun.ellant.utils.render.Scissor;
import fun.ellant.utils.render.font.Fonts;
import fun.ellant.utils.text.GradientUtil;

public class NotificationsRenderer
        implements ElementRenderer {
    private final FunctionRegistry functionRegistry;
    private float width;
    private float height;

    public NotificationsRenderer() {
        this.functionRegistry = Ellant.getInstance().getFunctionRegistry();
    }

    @Override
    public void render(EventDisplay eventDisplay) {
        MatrixStack ms = eventDisplay.getMatrixStack();
        float screenWidth = Minecraft.getInstance().getMainWindow().getScaledWidth();
        float screenHeight = Minecraft.getInstance().getMainWindow().getScaledHeight();
        float posX = screenWidth - this.width - 5.0f;
        float posY = screenHeight - this.height - 5.0f;
        float fontSize = 6.5f;
        float padding = 5.0f;
        StringTextComponent title = (StringTextComponent) GradientUtil.white("Функции");
        Style style = Ellant.getInstance().getStyleManager().getCurrentStyle();
        DisplayUtils.drawShadow(posX, posY, this.width, this.height, 10, style.getFirstColor().getRGB(), style.getSecondColor().getRGB());
        this.drawStyledRect(posX, posY, this.width, this.height, 4.0f);
        Scissor.push();
        Scissor.setFromComponentCoordinates(posX, posY, this.width, this.height);
        Fonts.sfui.drawCenteredText(ms, title, posX + this.width / 2.0f, posY + padding + 0.5f, fontSize);
        posY += fontSize + padding * 2.0f;
        float maxWidth = Fonts.sfMedium.getWidth(title, fontSize) + padding * 2.0f;
        float localHeight = fontSize + padding * 2.0f;
        for (Function function : this.functionRegistry.getFunctions()) {
            String functionName = function.getName() + " " + (function.isState() ? "включено" : "выключено");
            float nameWidth = Fonts.sfMedium.getWidth(functionName, fontSize);
            Fonts.sfMedium.drawText(ms, functionName, posX + padding, posY, ColorUtils.rgba(210, 210, 210, 255), fontSize);
            if (nameWidth + padding * 2.0f > maxWidth) {
                maxWidth = nameWidth + padding * 2.0f;
            }
            posY += fontSize + padding;
            localHeight += fontSize + padding;
        }
        Scissor.unset();
        Scissor.pop();
        this.width = Math.max(maxWidth, 80.0f);
        this.height = localHeight + 2.5f;
    }

    private void drawStyledRect(float x, float y, float width, float height, float radius) {
        DisplayUtils.drawRoundedRect(x - 0.5f, y - 0.5f, width + 1.0f, height + 1.0f, radius + 0.5f, ColorUtils.getColor(0));
        DisplayUtils.drawRoundedRect(x, y, width, height, radius, ColorUtils.rgba(21, 21, 21, 255));
    }

    public NotificationsRenderer(FunctionRegistry functionRegistry) {
        this.functionRegistry = functionRegistry;
    }
}

Если вы не рукожоп и умеете менять импорты через ctrl + h то можно переходить и к 3 этапу.



Переходим по такому пути: src/im/expensive/functions/api/, так так, если вы перешли по такому пути вы должны создать класс NaksonPaster, переносим этот код в класс





Java:
package fun.ellant.functions.api;



import fun.ellant.ui.NotificationManager;



public class NaksonPaster {

    public static NotificationManager NOTIFICATION_MANAGER;

}


После этого мы переходим в класс Expensive.java, который находится по такому пути: src/im/expensive/ , после строки tpsCalc = new TPSCalc(); вставляем этот код:
Java:
NaksonPaster.NOTIFICATION_MANAGER = new NotificationManager();


Фуух, вы сделали 50% от всего этого. Теперь надо парейти в класс Function.java, который находится по пути: src/im/expensive/functions/api/, после строки



public final void toggle() {

if (Function.mc.player == null || Function.mc.world == null) {

return;

}



Вы должны написать

Java:
        boolean bl = this.state = !this.state;

        if (!this.state) {

            this.onDisable();

            NaksonPaster.NOTIFICATION_MANAGER.add("Функция " + this.name + " была выключена.", "", 1, NotificationManager.ImageType.FIRST_PHOTO);

        } else {

            this.onEnable();

            NaksonPaster.NOTIFICATION_MANAGER.add("Функция " + this.name + " была включена.", "", 1, NotificationManager.ImageType.SECOND_PHOTO);

        }

        FunctionRegistry functionRegistry = Ellant.getInstance().getFunctionRegistry();

        ClientSounds clientSounds = functionRegistry.getClientSounds();

        if (clientSounds != null && clientSounds.isState()) {

            String fileName = clientSounds.getFileName(this.state);

            float volume = ((Float)clientSounds.volume.get()).floatValue();

            ClientUtil.playSound(fileName, volume, false);

        }

    }




После этого мы переходим в класс IngameGUI по пути: src/net/minecraft/client/gui/ и после строк: eventDisplay.setMatrixStack(matrixStack);

eventDisplay.setPartialTicks(partialTicks);



мы должны вставить это:

Java:
NaksonPaster.NOTIFICATION_MANAGER.draw(matrixStack);
Да я пастер
 
Последнее редактирование:
Начинающий
Статус
Оффлайн
Регистрация
6 Ноя 2023
Сообщения
26
Реакции[?]
0
Поинты[?]
0
Все сделал по гайду не работает :( буду рад если поможешь в дс doctor_frik
Запастил с невернайгта, короче по пути: src/im/expensive/ui/ создаем класс NotificationManager, туда вставляем этот код:



Java:
package fun.ellant.ui;



import com.mojang.blaze3d.matrix.MatrixStack;

import java.util.concurrent.CopyOnWriteArrayList;

import net.minecraft.util.ResourceLocation;

import fun.ellant.utils.animations.Animation;

import fun.ellant.utils.animations.Direction;

import fun.ellant.utils.animations.impl.EaseBackIn;

import fun.ellant.utils.animations.impl.EaseInOutQuad;

import fun.ellant.utils.client.IMinecraft;

import fun.ellant.utils.math.MathUtil;

import fun.ellant.utils.render.ColorUtils;

import fun.ellant.utils.render.DisplayUtils;

import fun.ellant.utils.render.font.Fonts;



public class NotificationManager {

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

    private MathUtil AnimationMath;

    private ImageType imageType;

    boolean state;



    public void add(String text, String content, int time, ImageType imageType) {

        this.notifications.add(new Notification(text, content, time, imageType));

    }

    public void draw(MatrixStack stack) {

        int yOffset = 0;

        for (Notification notification : this.notifications) {

            if (System.currentTimeMillis() - notification.getTime() <= (long) notification.time2 * 1000L - 300L) {

                notification.yAnimation.setDirection(Direction.FORWARDS);

            }

            notification.alpha = (float) notification.animation.getOutput();

            if (System.currentTimeMillis() - notification.getTime() > (long) notification.time2 * 1000L) {

                notification.yAnimation.setDirection(Direction.BACKWARDS);

            }

            if (notification.yAnimation.finished(Direction.BACKWARDS)) {

                this.notifications.remove(notification);

                continue;

            }



            // Calculate the width of the notification

            float notificationWidth = Fonts.sfMedium.getWidth(notification.getText(), 7.0f) + 8.0f;



            // Calculate x position to center horizontally

            float x = (IMinecraft.mc.getMainWindow().getScaledWidth() - notificationWidth) / 0.5f;



            // Calculate y position to center vertically

            float y = (IMinecraft.mc.getMainWindow().getScaledHeight() - 24.0f) / 0.5f; // 24.0f - height of the notification



            // Ensure x and y are within the visible screen area

            if (x < 0) {

                x = 0; // Adjust x if it goes off the left edge

            }

            if (y < 0) {

                y = 0; // Adjust y if it goes off the top edge

            }

            if (x + notificationWidth > IMinecraft.mc.getMainWindow().getScaledWidth()) {

                x = IMinecraft.mc.getMainWindow().getScaledWidth() - notificationWidth; // Adjust x if it goes off the right edge

            }

            if (y + 24.0f > IMinecraft.mc.getMainWindow().getScaledHeight()) {

                y = IMinecraft.mc.getMainWindow().getScaledHeight() - 24.0f; // Adjust y if it goes off the bottom edge

            }



            notification.yAnimation.setEndPoint(yOffset);

            notification.yAnimation.setDuration(500);

            notification.setX(x);

            notification.setY(MathUtil.fast(notification.getY(), y, 25.0f));



            notification.draw(stack);

            yOffset++;

        }

    }











    private class Notification {

        private float x = 0.0f;

        private float y = IMinecraft.mc.getMainWindow().scaledHeight() + 24;

        private String text;

        private String content;

        private long time = System.currentTimeMillis();

        public Animation animation = new EaseInOutQuad(500, 1.0, Direction.FORWARDS);

        public Animation yAnimation = new EaseBackIn(500, 1.0, 1.0f);

        private ImageType imageType;

        float alpha;

        int time2 = 3;

        private boolean isState;

        private boolean state;



        public Notification(String text, String content, int time, ImageType imageType) {

            this.text = text;

            this.content = content;

            this.time2 = time;

            this.imageType = imageType;

        }



        public float draw(MatrixStack stack) {

            float width = Fonts.sfMedium.getWidth(this.text, 7.0f) + 8.0f;

            DisplayUtils.drawRoundedRect(this.x - 427.0f + 50.0f, this.y - 25.0f, width + 27.0f, 13.0f, 3.0f, ColorUtils.rgb(23, 22, 22));

            DisplayUtils.drawShadow(this.x - 427.0f + 50.0f, this.y - 25.0f, width + 27.0f, 13.0f, 3, ColorUtils.rgb(23, 22, 22));

            if (this.imageType == ImageType.FIRST_PHOTO) {

                ResourceLocation key = new ResourceLocation("expensive/images/hud/notify2.png");

                DisplayUtils.drawImage(key, this.x - 424.0f + 50.0f, this.y - 26.5f, 16.0f, 16.0f, ColorUtils.rgb(255, 0, 0));

            } else {

                ResourceLocation key1 = new ResourceLocation("expensive/images/hud/notify.png");

                DisplayUtils.drawImage(key1, this.x - 424.0f + 50.0f, this.y - 26.5f, 16.0f, 16.0f, ColorUtils.rgb(0, 255, 0));

            }

            Fonts.montserrat.drawText(stack, this.text, this.x - 407.0f + 50.0f, this.y - 22.0f, -1, 7.0f, 0.05f);

            int enabledColor = ColorUtils.rgba(0, 255, 0, 255);

            int disabledColor = ColorUtils.rgba(255, 0, 0, 255);

            int contentColor = this.state ? enabledColor : disabledColor;

            Fonts.sfMedium.drawText(stack, this.content, this.x, this.y, ColorUtils.rgb(0, 255, 0), 4.0f, 0.05f);

            return 24.0f;

        }



        public float getX() {

            return this.x;

        }



        public float getY() {

            return this.y;

        }



        public void setX(float x) {

            this.x = x;

        }



        public void setY(float y) {

            this.y = y;

        }



        public String getText() {

            return this.text;

        }



        public String getContent() {

            return this.content;

        }



        public long getTime() {

            return this.time;

        }

    }



    public static enum ImageType {

        FIRST_PHOTO,

        SECOND_PHOTO;



    }

}


Если вы не рукожоп и умеете менять импорты через ctrl + h то можно переходить и к 2 этапу.



Переходим по такому пути: src/im/expensive/functions/api/, так так, если вы перешли по такому пути вы должны создать класс NaksonPaster, переносим этот код в класс





Java:
package fun.ellant.functions.api;



import fun.ellant.ui.NotificationManager;



public class NaksonPaster {

    public static NotificationManager NOTIFICATION_MANAGER;

}


После этого мы переходим в класс Expensive.java, который находится по такому пути: src/im/expensive/ , после строки tpsCalc = new TPSCalc(); вставляем этот код:
Java:
NaksonPaster.NOTIFICATION_MANAGER = new NotificationManager();


Фуух, вы сделали 50% от всего этого. Теперь надо парейти в класс Function.java, который находится по пути: src/im/expensive/functions/api/, после строки



public final void toggle() {

if (Function.mc.player == null || Function.mc.world == null) {

return;

}



Вы должны написать

Java:
        boolean bl = this.state = !this.state;

        if (!this.state) {

            this.onDisable();

            NaksonPaster.NOTIFICATION_MANAGER.add("Функция " + this.name + " была выключена.", "", 1, NotificationManager.ImageType.FIRST_PHOTO);

        } else {

            this.onEnable();

            NaksonPaster.NOTIFICATION_MANAGER.add("Функция " + this.name + " была включена.", "", 1, NotificationManager.ImageType.SECOND_PHOTO);

        }

        FunctionRegistry functionRegistry = Ellant.getInstance().getFunctionRegistry();

        ClientSounds clientSounds = functionRegistry.getClientSounds();

        if (clientSounds != null && clientSounds.isState()) {

            String fileName = clientSounds.getFileName(this.state);

            float volume = ((Float)clientSounds.volume.get()).floatValue();

            ClientUtil.playSound(fileName, volume, false);

        }

    }




После этого мы переходим в класс IngameGUI по пути: src/net/minecraft/client/gui/ и после строк: eventDisplay.setMatrixStack(matrixStack);

eventDisplay.setPartialTicks(partialTicks);



мы должны вставить это:

Java:
NaksonPaster.NOTIFICATION_MANAGER.draw(matrixStack);
Да я пастер
 
Начинающий
Статус
Оффлайн
Регистрация
26 Авг 2023
Сообщения
40
Реакции[?]
0
Поинты[?]
0
Начинающий
Статус
Оффлайн
Регистрация
26 Авг 2023
Сообщения
40
Реакции[?]
0
Поинты[?]
0
п
можешь мне тоже помочь дс dobccer
принимай
У всех у кого ошибка вот вам код чтобы все работало

Function.java:
public final void toggle() {
        if (Function.mc.player == null || Function.mc.world == null) {
            return;
        }
        boolean bl = this.state = !this.state;
        if (!this.state) {
            this.onDisable();
            NotifiDed.NOTIFICATION_MANAGER.add("Функция " + this.name + " была выключена.", "", 1, NotificationManager.ImageType.FIRST_PHOTO);
        } else {
            this.onEnable();
            NotifiDed.NOTIFICATION_MANAGER.add("Функция " + this.name + " была включена.", "", 1, NotificationManager.ImageType.SECOND_PHOTO);
        }
        FunctionRegistry functionRegistry = Dedyshka.getInstance().getFunctionRegistry();
        ClientSounds clientSounds = functionRegistry.getClientSounds();
        if (clientSounds != null && clientSounds.isState()) {
            String fileName = clientSounds.getFileName(this.state);
            float volume = ((Float)clientSounds.volume.get()).floatValue();
            ClientUtil.playSound(fileName, volume, false);
        }
    }
Это вставлять в Function.java, где public final void toggle()
 
Последнее редактирование:
Начинающий
Статус
Оффлайн
Регистрация
8 Мар 2024
Сообщения
536
Реакции[?]
2
Поинты[?]
2K
Запастил с невернайгта, короче по пути: src/im/expensive/ui/ создаем класс NotificationManager, туда вставляем этот код:



Java:
package fun.ellant.ui;



import com.mojang.blaze3d.matrix.MatrixStack;

import java.util.concurrent.CopyOnWriteArrayList;

import net.minecraft.util.ResourceLocation;

import fun.ellant.utils.animations.Animation;

import fun.ellant.utils.animations.Direction;

import fun.ellant.utils.animations.impl.EaseBackIn;

import fun.ellant.utils.animations.impl.EaseInOutQuad;

import fun.ellant.utils.client.IMinecraft;

import fun.ellant.utils.math.MathUtil;

import fun.ellant.utils.render.ColorUtils;

import fun.ellant.utils.render.DisplayUtils;

import fun.ellant.utils.render.font.Fonts;



public class NotificationManager {

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

    private MathUtil AnimationMath;

    private ImageType imageType;

    boolean state;



    public void add(String text, String content, int time, ImageType imageType) {

        this.notifications.add(new Notification(text, content, time, imageType));

    }

    public void draw(MatrixStack stack) {

        int yOffset = 0;

        for (Notification notification : this.notifications) {

            if (System.currentTimeMillis() - notification.getTime() <= (long) notification.time2 * 1000L - 300L) {

                notification.yAnimation.setDirection(Direction.FORWARDS);

            }

            notification.alpha = (float) notification.animation.getOutput();

            if (System.currentTimeMillis() - notification.getTime() > (long) notification.time2 * 1000L) {

                notification.yAnimation.setDirection(Direction.BACKWARDS);

            }

            if (notification.yAnimation.finished(Direction.BACKWARDS)) {

                this.notifications.remove(notification);

                continue;

            }



            // Calculate the width of the notification

            float notificationWidth = Fonts.sfMedium.getWidth(notification.getText(), 7.0f) + 8.0f;



            // Calculate x position to center horizontally

            float x = (IMinecraft.mc.getMainWindow().getScaledWidth() - notificationWidth) / 0.5f;



            // Calculate y position to center vertically

            float y = (IMinecraft.mc.getMainWindow().getScaledHeight() - 24.0f) / 0.5f; // 24.0f - height of the notification



            // Ensure x and y are within the visible screen area

            if (x < 0) {

                x = 0; // Adjust x if it goes off the left edge

            }

            if (y < 0) {

                y = 0; // Adjust y if it goes off the top edge

            }

            if (x + notificationWidth > IMinecraft.mc.getMainWindow().getScaledWidth()) {

                x = IMinecraft.mc.getMainWindow().getScaledWidth() - notificationWidth; // Adjust x if it goes off the right edge

            }

            if (y + 24.0f > IMinecraft.mc.getMainWindow().getScaledHeight()) {

                y = IMinecraft.mc.getMainWindow().getScaledHeight() - 24.0f; // Adjust y if it goes off the bottom edge

            }



            notification.yAnimation.setEndPoint(yOffset);

            notification.yAnimation.setDuration(500);

            notification.setX(x);

            notification.setY(MathUtil.fast(notification.getY(), y, 25.0f));



            notification.draw(stack);

            yOffset++;

        }

    }











    private class Notification {

        private float x = 0.0f;

        private float y = IMinecraft.mc.getMainWindow().scaledHeight() + 24;

        private String text;

        private String content;

        private long time = System.currentTimeMillis();

        public Animation animation = new EaseInOutQuad(500, 1.0, Direction.FORWARDS);

        public Animation yAnimation = new EaseBackIn(500, 1.0, 1.0f);

        private ImageType imageType;

        float alpha;

        int time2 = 3;

        private boolean isState;

        private boolean state;



        public Notification(String text, String content, int time, ImageType imageType) {

            this.text = text;

            this.content = content;

            this.time2 = time;

            this.imageType = imageType;

        }



        public float draw(MatrixStack stack) {

            float width = Fonts.sfMedium.getWidth(this.text, 7.0f) + 8.0f;

            DisplayUtils.drawRoundedRect(this.x - 427.0f + 50.0f, this.y - 25.0f, width + 27.0f, 13.0f, 3.0f, ColorUtils.rgb(23, 22, 22));

            DisplayUtils.drawShadow(this.x - 427.0f + 50.0f, this.y - 25.0f, width + 27.0f, 13.0f, 3, ColorUtils.rgb(23, 22, 22));

            if (this.imageType == ImageType.FIRST_PHOTO) {

                ResourceLocation key = new ResourceLocation("expensive/images/hud/notify2.png");

                DisplayUtils.drawImage(key, this.x - 424.0f + 50.0f, this.y - 26.5f, 16.0f, 16.0f, ColorUtils.rgb(255, 0, 0));

            } else {

                ResourceLocation key1 = new ResourceLocation("expensive/images/hud/notify.png");

                DisplayUtils.drawImage(key1, this.x - 424.0f + 50.0f, this.y - 26.5f, 16.0f, 16.0f, ColorUtils.rgb(0, 255, 0));

            }

            Fonts.montserrat.drawText(stack, this.text, this.x - 407.0f + 50.0f, this.y - 22.0f, -1, 7.0f, 0.05f);

            int enabledColor = ColorUtils.rgba(0, 255, 0, 255);

            int disabledColor = ColorUtils.rgba(255, 0, 0, 255);

            int contentColor = this.state ? enabledColor : disabledColor;

            Fonts.sfMedium.drawText(stack, this.content, this.x, this.y, ColorUtils.rgb(0, 255, 0), 4.0f, 0.05f);

            return 24.0f;

        }



        public float getX() {

            return this.x;

        }



        public float getY() {

            return this.y;

        }



        public void setX(float x) {

            this.x = x;

        }



        public void setY(float y) {

            this.y = y;

        }



        public String getText() {

            return this.text;

        }



        public String getContent() {

            return this.content;

        }



        public long getTime() {

            return this.time;

        }

    }



    public static enum ImageType {

        FIRST_PHOTO,

        SECOND_PHOTO;



    }

}


Если вы не рукожоп и умеете менять импорты через ctrl + h то можно переходить и к 2 этапу.



Переходим по такому пути: src/im/expensive/functions/api/, так так, если вы перешли по такому пути вы должны создать класс NaksonPaster, переносим этот код в класс





Java:
package fun.ellant.functions.api;



import fun.ellant.ui.NotificationManager;



public class NaksonPaster {

    public static NotificationManager NOTIFICATION_MANAGER;

}


После этого мы переходим в класс Expensive.java, который находится по такому пути: src/im/expensive/ , после строки tpsCalc = new TPSCalc(); вставляем этот код:
Java:
NaksonPaster.NOTIFICATION_MANAGER = new NotificationManager();


Фуух, вы сделали 50% от всего этого. Теперь надо парейти в класс Function.java, который находится по пути: src/im/expensive/functions/api/, после строки



public final void toggle() {

if (Function.mc.player == null || Function.mc.world == null) {

return;

}



Вы должны написать

Java:
        boolean bl = this.state = !this.state;

        if (!this.state) {

            this.onDisable();

            NaksonPaster.NOTIFICATION_MANAGER.add("Функция " + this.name + " была выключена.", "", 1, NotificationManager.ImageType.FIRST_PHOTO);

        } else {

            this.onEnable();

            NaksonPaster.NOTIFICATION_MANAGER.add("Функция " + this.name + " была включена.", "", 1, NotificationManager.ImageType.SECOND_PHOTO);

        }

        FunctionRegistry functionRegistry = Ellant.getInstance().getFunctionRegistry();

        ClientSounds clientSounds = functionRegistry.getClientSounds();

        if (clientSounds != null && clientSounds.isState()) {

            String fileName = clientSounds.getFileName(this.state);

            float volume = ((Float)clientSounds.volume.get()).floatValue();

            ClientUtil.playSound(fileName, volume, false);

        }

    }




После этого мы переходим в класс IngameGUI по пути: src/net/minecraft/client/gui/ и после строк: eventDisplay.setMatrixStack(matrixStack);

eventDisplay.setPartialTicks(partialTicks);



мы должны вставить это:

Java:
NaksonPaster.NOTIFICATION_MANAGER.draw(matrixStack);
Да я пастер
функции сами на себя накладываются а не улетают в верх пж помощь 1719643100128.png ds: kostya9899
 
Начинающий
Статус
Оффлайн
Регистрация
10 Май 2023
Сообщения
515
Реакции[?]
8
Поинты[?]
3K
Начинающий
Статус
Онлайн
Регистрация
2 Фев 2024
Сообщения
766
Реакции[?]
3
Поинты[?]
0
Все сделал по гайду не работает :( буду рад если поможешь в дс doctor_frik
Imgamegui или замени Function
Запастил с невернайгта, короче по пути: src/im/expensive/ui/ создаем класс NotificationManager, туда вставляем этот код:



Java:
package fun.ellant.ui;

import com.mojang.blaze3d.matrix.MatrixStack;
import java.util.concurrent.CopyOnWriteArrayList;
import net.minecraft.util.ResourceLocation;
import fun.ellant.utils.animations.Animation;
import fun.ellant.utils.animations.Direction;
import fun.ellant.utils.animations.impl.EaseBackIn;
import fun.ellant.utils.animations.impl.EaseInOutQuad;
import fun.ellant.utils.client.IMinecraft;
import fun.ellant.utils.math.MathUtil;
import fun.ellant.utils.render.ColorUtils;
import fun.ellant.utils.render.DisplayUtils;
import fun.ellant.utils.render.font.Fonts;

public class NotificationManager {
    private final CopyOnWriteArrayList<Notification> notifications = new CopyOnWriteArrayList();
    private MathUtil AnimationMath;
    private ImageType imageType;
    boolean state;

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

    public void draw(MatrixStack stack) {
        int yOffset = 0;
        for (Notification notification : this.notifications) {
            if (System.currentTimeMillis() - notification.getTime() <= (long)notification.time2 * 1000L - 300L) {
                notification.yAnimation.setDirection(Direction.FORWARDS);
            }
            notification.alpha = (float)notification.animation.getOutput();
            if (System.currentTimeMillis() - notification.getTime() > (long)notification.time2 * 1000L) {
                notification.yAnimation.setDirection(Direction.BACKWARDS);
            }
            if (notification.yAnimation.finished(Direction.BACKWARDS)) {
                this.notifications.remove(notification);
                continue;
            }
            float x = (float)IMinecraft.mc.getMainWindow().scaledWidth() - (Fonts.sfMedium.getWidth(notification.getText(), 7.0f) + 8.0f) - 10.0f;
            float y = IMinecraft.mc.getMainWindow().scaledHeight() - 40;
            notification.yAnimation.setEndPoint(yOffset);
            notification.yAnimation.setDuration(500);
            notification.setX(x);
            notification.setY(MathUtil.fast(notification.getY(), y -= (float)((double)notification.draw(stack) * notification.yAnimation.getOutput() + 3.0), 15.0f));
            ++yOffset;
        }
    }

    private class Notification {
        private float x = 0.0f;
        private float y = IMinecraft.mc.getMainWindow().scaledHeight() + 24;
        private String text;
        private String content;
        private long time = System.currentTimeMillis();
        public Animation animation = new EaseInOutQuad(500, 1.0, Direction.FORWARDS);
        public Animation yAnimation = new EaseBackIn(500, 1.0, 1.0f);
        private ImageType imageType;
        float alpha;
        int time2 = 3;
        private boolean isState;
        private boolean state;

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

        public float draw(MatrixStack stack) {
            float width = Fonts.sfMedium.getWidth(this.text, 7.0f) + 8.0f;
            DisplayUtils.drawRoundedRect(this.x - 427.0f + 50.0f, this.y - 25.0f, width + 27.0f, 13.0f, 3.0f, ColorUtils.rgb(23, 22, 22));
            DisplayUtils.drawShadow(this.x - 427.0f + 50.0f, this.y - 25.0f, width + 27.0f, 13.0f, 3, ColorUtils.rgb(23, 22, 22));
            if (this.imageType == ImageType.FIRST_PHOTO) {
                ResourceLocation key = new ResourceLocation("expensive/images/hud/notify.png");
                DisplayUtils.drawImage(key, this.x - 424.0f + 50.0f, this.y - 26.5f, 16.0f, 16.0f, ColorUtils.rgb(255, 0, 0));
            } else {
                ResourceLocation key1 = new ResourceLocation("expensive/images/hud/notify2.png");
                DisplayUtils.drawImage(key1, this.x - 424.0f + 50.0f, this.y - 26.5f, 16.0f, 16.0f, ColorUtils.rgb(0, 255, 0));
            }
            Fonts.montserrat.drawText(stack, this.text, this.x - 407.0f + 50.0f, this.y - 22.0f, -1, 7.0f, 0.05f);
            int enabledColor = ColorUtils.rgba(0, 255, 0, 255);
            int disabledColor = ColorUtils.rgba(255, 0, 0, 255);
            int contentColor = this.state ? enabledColor : disabledColor;
            Fonts.sfMedium.drawText(stack, this.content, this.x, this.y, ColorUtils.rgb(0, 255, 0), 4.0f, 0.05f);
            return 24.0f;
        }

        public float getX() {
            return this.x;
        }

        public float getY() {
            return this.y;
        }

        public void setX(float x) {
            this.x = x;
        }

        public void setY(float y) {
            this.y = y;
        }

        public String getText() {
            return this.text;
        }

        public String getContent() {
            return this.content;
        }

        public long getTime() {
            return this.time;
        }
    }

    public static enum ImageType {
        FIRST_PHOTO,
        SECOND_PHOTO;

    }
}


Если вы не рукожоп и умеете менять импорты через ctrl + h то можно переходить и к 2 этапу.



Переходим по такому пути: src/im/expensive/functions/api/, так так, если вы перешли по такому пути вы должны создать класс NaksonPaster, переносим этот код в класс





Java:
package fun.ellant.functions.api;



import fun.ellant.ui.NotificationManager;



public class NaksonPaster {

    public static NotificationManager NOTIFICATION_MANAGER;

}


После этого мы переходим в класс Expensive.java, который находится по такому пути: src/im/expensive/ , после строки tpsCalc = new TPSCalc(); вставляем этот код:
Java:
NaksonPaster.NOTIFICATION_MANAGER = new NotificationManager();


Фуух, вы сделали 50% от всего этого. Теперь надо парейти в класс Function.java, который находится по пути: src/im/expensive/functions/api/, после строки



public final void toggle() {

if (Function.mc.player == null || Function.mc.world == null) {

return;

}



Вы должны написать

Java:
        boolean bl = this.state = !this.state;

        if (!this.state) {

            this.onDisable();

            NaksonPaster.NOTIFICATION_MANAGER.add("Функция " + this.name + " была выключена.", "", 1, NotificationManager.ImageType.FIRST_PHOTO);

        } else {

            this.onEnable();

            NaksonPaster.NOTIFICATION_MANAGER.add("Функция " + this.name + " была включена.", "", 1, NotificationManager.ImageType.SECOND_PHOTO);

        }

        FunctionRegistry functionRegistry = Ellant.getInstance().getFunctionRegistry();

        ClientSounds clientSounds = functionRegistry.getClientSounds();

        if (clientSounds != null && clientSounds.isState()) {

            String fileName = clientSounds.getFileName(this.state);

            float volume = ((Float)clientSounds.volume.get()).floatValue();

            ClientUtil.playSound(fileName, volume, false);

        }

    }




После этого мы переходим в класс IngameGUI по пути: src/net/minecraft/client/gui/ и после строк: eventDisplay.setMatrixStack(matrixStack);

eventDisplay.setPartialTicks(partialTicks);



мы должны вставить это:

Java:
NaksonPaster.NOTIFICATION_MANAGER.draw(matrixStack);
Да я пастер
у меня еще давно были с вериста
 
Сверху Снизу