• Я зарабатываю 100 000 RUB / месяц на этом сайте!

    А знаешь как? Я всего-лишь публикую (создаю темы), а админ мне платит. Трачу деньги на мороженое, робуксы и сервера в Minecraft. А ещё на паль из Китая. 

    Хочешь так же? Пиши и узнавай условия: https://t.me/alex_redact
    Реклама: https://t.me/yougame_official

Визуальная часть Dragging for HUD | Expensive 3.1

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
23 Сен 2024
Сообщения
252
Реакции
0
Выберите загрузчик игры
  1. Прочие моды
дарова югеймовцы, сегодня я вам решаю слить мои драгги для expensive 3.1, сразу скажу, утилки с литки, если вы не тупой перенесёте
Меня разбанили на
югейме поэтому сразу создаю тему, пользовался гпт при создании
SS: прикреплён

Важная часть, если вы не пропишите в элементе худа это после переноса моего кода:
dragging.setRound(закругление);
То обводка будет квадратной (без закругления) это сделано для того чтобы, обводка была ровной, также обводка берёт значения:
dragging.setWidth(число)
dragging.setHeight(число)
Поэтому указывайте точные числа для ровной обводки
Вот сам код:

Dragging Code:
Expand Collapse Copy
package client.util.drag;

import client.util.display.render.ColorUtil;
import client.util.excRender.shape.Round;
import client.util.excRender.shape.Shape;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import client.main.module.api.Feature;
import client.util.client.ClientUtil;
import client.util.client.Vec2i;
import client.util.math.MathUtil;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.MainWindow;
import client.util.display.render.RenderUtil;
import org.joml.Vector2f;

public class Dragging {
    @Expose
    @SerializedName("x")
    private float xPos;
    @Expose
    @SerializedName("y")
    private float yPos;
    public final Vector2f size = new Vector2f();
    public float initialXVal;
    public float initialYVal;

    private float startX, startY;
    private boolean dragging;
    private float closestVerticalLine = 0;
    private float closestHorizontalLine = 0;
    private static final float grid = 2;
    private static final float snap_thr = 10;
    private float width, height, round;
    boolean showVerticalLine, showHorizontalLine;
    @Expose
    @SerializedName("name")
    private final String name;
    private final Feature module;
    private float lineAlpha = 0.0f;
    private long lastUpdateTime;
    private int fontSize = 22;

    private float targetX, targetY;
    private final float smoothSpeed = 0.075f;

    public Dragging(Feature module, String name, float initialXVal, float initialYVal) {
        this.module = module;
        this.name = name;
        this.xPos = initialXVal;
        this.yPos = initialYVal;
        this.targetX = initialXVal;
        this.targetY = initialYVal;
        this.initialXVal = initialXVal;
        this.initialYVal = initialYVal;
    }

    public Feature getModule() {
        return module;
    }

    public String getName() {
        return name;
    }

    public float getWidth() {
        return width;
    }
    public float getRound() {
        return round;
    }

    public void setWidth(float width) {
        this.width = width;
    }
    public void setRound(float round) {
        this.round = round;
    }

    public float getHeight() {
        return height;
    }

    public void setHeight(float height) {
        this.height = height;
    }

    public float getX() {
        return xPos;
    }

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

    public float getY() {
        return yPos;
    }

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

    public final void onDraw(int mouseX, int mouseY, MainWindow res, MatrixStack matrix) {
        Vec2i fixed = ClientUtil.getMouse(mouseX, mouseY);
        mouseX = fixed.getX();
        mouseY = fixed.getY();

        long currentTime = System.currentTimeMillis();
        float deltaTime = (currentTime - lastUpdateTime) / 1000.0f;
        lastUpdateTime = currentTime;

        if (dragging) {
            float rawTargetX = (mouseX - startX);
            float rawTargetY = (mouseY - startY);

            rawTargetX = snap(rawTargetX, grid, snap_thr);
            rawTargetY = snap(rawTargetY, grid, snap_thr);

            if (rawTargetX + width > res.scaledWidth()) rawTargetX = res.scaledWidth() - width;
            if (rawTargetY + height > res.scaledHeight()) rawTargetY = res.scaledHeight() - height;
            if (rawTargetX < 0) rawTargetX = 0;
            if (rawTargetY < 0) rawTargetY = 0;

            targetX = rawTargetX;
            targetY = rawTargetY;

            if (targetX + (width / 2) >= res.getScaledWidth() / 2 - 5 &&
                    targetX + (width / 2) <= res.getScaledWidth() / 2 + 5 &&
                    (mouseX >= targetX)) {

                targetX = res.getScaledWidth() / 2 - (width / 2);
                showHorizontalLine = false;
                showVerticalLine = false;
            } else {
                checkClosestGridLines();
            }

            updateLineAlpha(true, deltaTime);
        } else {
            updateLineAlpha(false, deltaTime);
        }

        float moveSpeed = 20;
        xPos += (targetX - xPos) * Math.min(deltaTime * moveSpeed, 1f);
        yPos += (targetY - yPos) * Math.min(deltaTime * moveSpeed, 1f);

        if (lineAlpha > 0.01f) {
            drawGridLines(res);

            float padding = 4f;
            float outlineX = xPos - padding;
            float outlineY = yPos - padding;
            float outlineWidth = width + 2 * padding;
            float outlineHeight = height + 2 * padding;
            float radiusOutline = round;

            int outlineAlpha = (int) (lineAlpha * 255);
            int outlineColor = (outlineAlpha << 24) | 0xFFFFFF;
            final Shape shape = new Shape(matrix, outlineX + 1, outlineY + 1,
                    outlineWidth - 2, outlineHeight - 2);
            shape.outline(0.75f, ColorUtil.reAlphaInt(outlineColor, (int) (125 * lineAlpha)), ColorUtil.reAlphaInt(outlineColor, (int) (255 * lineAlpha)), ColorUtil.reAlphaInt(outlineColor, (int) (125 * lineAlpha)), ColorUtil.reAlphaInt(outlineColor, (int) (255 * lineAlpha)), Round.of(radiusOutline));
        }
        }




    private float calculateOptimalCornerRadius(float width, float height) {
        float baseRadius = 7;
        float minDimension = Math.min(width, height);
        float maxRadius = minDimension / 4f;
        float proportionalRadius = minDimension * 0.1f;
        float optimalRadius = Math.min(proportionalRadius, maxRadius);
        optimalRadius = Math.max(optimalRadius, baseRadius);
        if (minDimension < 20) {
            optimalRadius = 5;
        }
        return optimalRadius;
    }

    private void drawGridLines(MainWindow res) {
        float alpha = lineAlpha * 1;
        int color = ((int) (alpha * 125) << 24) | 0xFFFFFF;
        if (showVerticalLine) {
            RenderUtil.drawRoundedRect(closestVerticalLine, 0, 1, res.scaledHeight(), 0, color);
        }
        if (showHorizontalLine) {
            RenderUtil.drawRoundedRect(0, closestHorizontalLine, res.scaledWidth(), 1, 0, color);
        }
    }

    private void updateLineAlpha(boolean increasing, float deltaTime) {
        if (increasing) {
            lineAlpha += deltaTime * 4;
            if (lineAlpha > 1.0f) lineAlpha = 1.0f;
        } else {
            lineAlpha -= deltaTime * 4;
            if (lineAlpha < 0.0f) lineAlpha = 0.0f;
        }
    }


    private void checkClosestGridLines() {
        closestVerticalLine = Math.round(xPos / grid) * grid;
        closestHorizontalLine = Math.round(yPos / grid) * grid;
        showVerticalLine = Math.abs(xPos - closestVerticalLine) < snap_thr;
        showHorizontalLine = Math.abs(yPos - closestHorizontalLine) < snap_thr;
    }

    private float snap(float pos, float gridSpacing, float snapThreshold) {
        float gridPos = Math.round(pos / gridSpacing) * gridSpacing;
        if (Math.abs(pos - gridPos) < snapThreshold) {
            return gridPos;
        }
        return pos;
    }

    public final boolean onClick(double mouseX, double mouseY, int button) {
        Vec2i fixed = ClientUtil.getMouse((int) mouseX, (int) mouseY);
        mouseX = fixed.getX();
        mouseY = fixed.getY();

        if (button == 0 && MathUtil.isHovered((float) mouseX, (float) mouseY, xPos, yPos, width, height)) {
            dragging = true;
            startX = (int) (mouseX - xPos);
            startY = (int) (mouseY - yPos);
            lastUpdateTime = System.currentTimeMillis();
            return true;
        }
        return false;
    }

    public final void onRelease(int button) {
        if (button == 0) dragging = false;
    }

    public void resetPosition() {
        this.xPos = this.initialXVal;
        this.yPos = this.initialYVal;
        this.targetX = this.initialXVal;
        this.targetY = this.initialYVal;
    }
}

Удачи всем! Если что то не так, или я что то забыл дать, напишите в комментах, также можете заменить обводку на свою, но могут возникнуть ошибки
 

Вложения

  • 1758110131491.png
    1758110131491.png
    75.3 KB · Просмотры: 223
так это же у же было везде
 
дарова югеймовцы, сегодня я вам решаю слить мои драгги для expensive 3.1, сразу скажу, утилки с литки, если вы не тупой перенесёте
Меня разбанили на
югейме поэтому сразу создаю тему, пользовался гпт при создании
SS: прикреплён

Важная часть, если вы не пропишите в элементе худа это после переноса моего кода:
dragging.setRound(закругление);
То обводка будет квадратной (без закругления) это сделано для того чтобы, обводка была ровной, также обводка берёт значения:
dragging.setWidth(число)
dragging.setHeight(число)
Поэтому указывайте точные числа для ровной обводки
Вот сам код:

Dragging Code:
Expand Collapse Copy
package client.util.drag;

import client.util.display.render.ColorUtil;
import client.util.excRender.shape.Round;
import client.util.excRender.shape.Shape;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import client.main.module.api.Feature;
import client.util.client.ClientUtil;
import client.util.client.Vec2i;
import client.util.math.MathUtil;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.MainWindow;
import client.util.display.render.RenderUtil;
import org.joml.Vector2f;

public class Dragging {
    @Expose
    @SerializedName("x")
    private float xPos;
    @Expose
    @SerializedName("y")
    private float yPos;
    public final Vector2f size = new Vector2f();
    public float initialXVal;
    public float initialYVal;

    private float startX, startY;
    private boolean dragging;
    private float closestVerticalLine = 0;
    private float closestHorizontalLine = 0;
    private static final float grid = 2;
    private static final float snap_thr = 10;
    private float width, height, round;
    boolean showVerticalLine, showHorizontalLine;
    @Expose
    @SerializedName("name")
    private final String name;
    private final Feature module;
    private float lineAlpha = 0.0f;
    private long lastUpdateTime;
    private int fontSize = 22;

    private float targetX, targetY;
    private final float smoothSpeed = 0.075f;

    public Dragging(Feature module, String name, float initialXVal, float initialYVal) {
        this.module = module;
        this.name = name;
        this.xPos = initialXVal;
        this.yPos = initialYVal;
        this.targetX = initialXVal;
        this.targetY = initialYVal;
        this.initialXVal = initialXVal;
        this.initialYVal = initialYVal;
    }

    public Feature getModule() {
        return module;
    }

    public String getName() {
        return name;
    }

    public float getWidth() {
        return width;
    }
    public float getRound() {
        return round;
    }

    public void setWidth(float width) {
        this.width = width;
    }
    public void setRound(float round) {
        this.round = round;
    }

    public float getHeight() {
        return height;
    }

    public void setHeight(float height) {
        this.height = height;
    }

    public float getX() {
        return xPos;
    }

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

    public float getY() {
        return yPos;
    }

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

    public final void onDraw(int mouseX, int mouseY, MainWindow res, MatrixStack matrix) {
        Vec2i fixed = ClientUtil.getMouse(mouseX, mouseY);
        mouseX = fixed.getX();
        mouseY = fixed.getY();

        long currentTime = System.currentTimeMillis();
        float deltaTime = (currentTime - lastUpdateTime) / 1000.0f;
        lastUpdateTime = currentTime;

        if (dragging) {
            float rawTargetX = (mouseX - startX);
            float rawTargetY = (mouseY - startY);

            rawTargetX = snap(rawTargetX, grid, snap_thr);
            rawTargetY = snap(rawTargetY, grid, snap_thr);

            if (rawTargetX + width > res.scaledWidth()) rawTargetX = res.scaledWidth() - width;
            if (rawTargetY + height > res.scaledHeight()) rawTargetY = res.scaledHeight() - height;
            if (rawTargetX < 0) rawTargetX = 0;
            if (rawTargetY < 0) rawTargetY = 0;

            targetX = rawTargetX;
            targetY = rawTargetY;

            if (targetX + (width / 2) >= res.getScaledWidth() / 2 - 5 &&
                    targetX + (width / 2) <= res.getScaledWidth() / 2 + 5 &&
                    (mouseX >= targetX)) {

                targetX = res.getScaledWidth() / 2 - (width / 2);
                showHorizontalLine = false;
                showVerticalLine = false;
            } else {
                checkClosestGridLines();
            }

            updateLineAlpha(true, deltaTime);
        } else {
            updateLineAlpha(false, deltaTime);
        }

        float moveSpeed = 20;
        xPos += (targetX - xPos) * Math.min(deltaTime * moveSpeed, 1f);
        yPos += (targetY - yPos) * Math.min(deltaTime * moveSpeed, 1f);

        if (lineAlpha > 0.01f) {
            drawGridLines(res);

            float padding = 4f;
            float outlineX = xPos - padding;
            float outlineY = yPos - padding;
            float outlineWidth = width + 2 * padding;
            float outlineHeight = height + 2 * padding;
            float radiusOutline = round;

            int outlineAlpha = (int) (lineAlpha * 255);
            int outlineColor = (outlineAlpha << 24) | 0xFFFFFF;
            final Shape shape = new Shape(matrix, outlineX + 1, outlineY + 1,
                    outlineWidth - 2, outlineHeight - 2);
            shape.outline(0.75f, ColorUtil.reAlphaInt(outlineColor, (int) (125 * lineAlpha)), ColorUtil.reAlphaInt(outlineColor, (int) (255 * lineAlpha)), ColorUtil.reAlphaInt(outlineColor, (int) (125 * lineAlpha)), ColorUtil.reAlphaInt(outlineColor, (int) (255 * lineAlpha)), Round.of(radiusOutline));
        }
        }




    private float calculateOptimalCornerRadius(float width, float height) {
        float baseRadius = 7;
        float minDimension = Math.min(width, height);
        float maxRadius = minDimension / 4f;
        float proportionalRadius = minDimension * 0.1f;
        float optimalRadius = Math.min(proportionalRadius, maxRadius);
        optimalRadius = Math.max(optimalRadius, baseRadius);
        if (minDimension < 20) {
            optimalRadius = 5;
        }
        return optimalRadius;
    }

    private void drawGridLines(MainWindow res) {
        float alpha = lineAlpha * 1;
        int color = ((int) (alpha * 125) << 24) | 0xFFFFFF;
        if (showVerticalLine) {
            RenderUtil.drawRoundedRect(closestVerticalLine, 0, 1, res.scaledHeight(), 0, color);
        }
        if (showHorizontalLine) {
            RenderUtil.drawRoundedRect(0, closestHorizontalLine, res.scaledWidth(), 1, 0, color);
        }
    }

    private void updateLineAlpha(boolean increasing, float deltaTime) {
        if (increasing) {
            lineAlpha += deltaTime * 4;
            if (lineAlpha > 1.0f) lineAlpha = 1.0f;
        } else {
            lineAlpha -= deltaTime * 4;
            if (lineAlpha < 0.0f) lineAlpha = 0.0f;
        }
    }


    private void checkClosestGridLines() {
        closestVerticalLine = Math.round(xPos / grid) * grid;
        closestHorizontalLine = Math.round(yPos / grid) * grid;
        showVerticalLine = Math.abs(xPos - closestVerticalLine) < snap_thr;
        showHorizontalLine = Math.abs(yPos - closestHorizontalLine) < snap_thr;
    }

    private float snap(float pos, float gridSpacing, float snapThreshold) {
        float gridPos = Math.round(pos / gridSpacing) * gridSpacing;
        if (Math.abs(pos - gridPos) < snapThreshold) {
            return gridPos;
        }
        return pos;
    }

    public final boolean onClick(double mouseX, double mouseY, int button) {
        Vec2i fixed = ClientUtil.getMouse((int) mouseX, (int) mouseY);
        mouseX = fixed.getX();
        mouseY = fixed.getY();

        if (button == 0 && MathUtil.isHovered((float) mouseX, (float) mouseY, xPos, yPos, width, height)) {
            dragging = true;
            startX = (int) (mouseX - xPos);
            startY = (int) (mouseY - yPos);
            lastUpdateTime = System.currentTimeMillis();
            return true;
        }
        return false;
    }

    public final void onRelease(int button) {
        if (button == 0) dragging = false;
    }

    public void resetPosition() {
        this.xPos = this.initialXVal;
        this.yPos = this.initialYVal;
        this.targetX = this.initialXVal;
        this.targetY = this.initialYVal;
    }
}

Удачи всем! Если что то не так, или я что то забыл дать, напишите в комментах, также можете заменить обводку на свою, но могут возникнуть ошибки
бессмысленно как по мне, но пусть будет
 
дарова югеймовцы, сегодня я вам решаю слить мои драгги для expensive 3.1, сразу скажу, утилки с литки, если вы не тупой перенесёте
Меня разбанили на
югейме поэтому сразу создаю тему, пользовался гпт при создании
SS: прикреплён

Важная часть, если вы не пропишите в элементе худа это после переноса моего кода:
dragging.setRound(закругление);
То обводка будет квадратной (без закругления) это сделано для того чтобы, обводка была ровной, также обводка берёт значения:
dragging.setWidth(число)
dragging.setHeight(число)
Поэтому указывайте точные числа для ровной обводки
Вот сам код:

Dragging Code:
Expand Collapse Copy
package client.util.drag;

import client.util.display.render.ColorUtil;
import client.util.excRender.shape.Round;
import client.util.excRender.shape.Shape;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import client.main.module.api.Feature;
import client.util.client.ClientUtil;
import client.util.client.Vec2i;
import client.util.math.MathUtil;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.MainWindow;
import client.util.display.render.RenderUtil;
import org.joml.Vector2f;

public class Dragging {
    @Expose
    @SerializedName("x")
    private float xPos;
    @Expose
    @SerializedName("y")
    private float yPos;
    public final Vector2f size = new Vector2f();
    public float initialXVal;
    public float initialYVal;

    private float startX, startY;
    private boolean dragging;
    private float closestVerticalLine = 0;
    private float closestHorizontalLine = 0;
    private static final float grid = 2;
    private static final float snap_thr = 10;
    private float width, height, round;
    boolean showVerticalLine, showHorizontalLine;
    @Expose
    @SerializedName("name")
    private final String name;
    private final Feature module;
    private float lineAlpha = 0.0f;
    private long lastUpdateTime;
    private int fontSize = 22;

    private float targetX, targetY;
    private final float smoothSpeed = 0.075f;

    public Dragging(Feature module, String name, float initialXVal, float initialYVal) {
        this.module = module;
        this.name = name;
        this.xPos = initialXVal;
        this.yPos = initialYVal;
        this.targetX = initialXVal;
        this.targetY = initialYVal;
        this.initialXVal = initialXVal;
        this.initialYVal = initialYVal;
    }

    public Feature getModule() {
        return module;
    }

    public String getName() {
        return name;
    }

    public float getWidth() {
        return width;
    }
    public float getRound() {
        return round;
    }

    public void setWidth(float width) {
        this.width = width;
    }
    public void setRound(float round) {
        this.round = round;
    }

    public float getHeight() {
        return height;
    }

    public void setHeight(float height) {
        this.height = height;
    }

    public float getX() {
        return xPos;
    }

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

    public float getY() {
        return yPos;
    }

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

    public final void onDraw(int mouseX, int mouseY, MainWindow res, MatrixStack matrix) {
        Vec2i fixed = ClientUtil.getMouse(mouseX, mouseY);
        mouseX = fixed.getX();
        mouseY = fixed.getY();

        long currentTime = System.currentTimeMillis();
        float deltaTime = (currentTime - lastUpdateTime) / 1000.0f;
        lastUpdateTime = currentTime;

        if (dragging) {
            float rawTargetX = (mouseX - startX);
            float rawTargetY = (mouseY - startY);

            rawTargetX = snap(rawTargetX, grid, snap_thr);
            rawTargetY = snap(rawTargetY, grid, snap_thr);

            if (rawTargetX + width > res.scaledWidth()) rawTargetX = res.scaledWidth() - width;
            if (rawTargetY + height > res.scaledHeight()) rawTargetY = res.scaledHeight() - height;
            if (rawTargetX < 0) rawTargetX = 0;
            if (rawTargetY < 0) rawTargetY = 0;

            targetX = rawTargetX;
            targetY = rawTargetY;

            if (targetX + (width / 2) >= res.getScaledWidth() / 2 - 5 &&
                    targetX + (width / 2) <= res.getScaledWidth() / 2 + 5 &&
                    (mouseX >= targetX)) {

                targetX = res.getScaledWidth() / 2 - (width / 2);
                showHorizontalLine = false;
                showVerticalLine = false;
            } else {
                checkClosestGridLines();
            }

            updateLineAlpha(true, deltaTime);
        } else {
            updateLineAlpha(false, deltaTime);
        }

        float moveSpeed = 20;
        xPos += (targetX - xPos) * Math.min(deltaTime * moveSpeed, 1f);
        yPos += (targetY - yPos) * Math.min(deltaTime * moveSpeed, 1f);

        if (lineAlpha > 0.01f) {
            drawGridLines(res);

            float padding = 4f;
            float outlineX = xPos - padding;
            float outlineY = yPos - padding;
            float outlineWidth = width + 2 * padding;
            float outlineHeight = height + 2 * padding;
            float radiusOutline = round;

            int outlineAlpha = (int) (lineAlpha * 255);
            int outlineColor = (outlineAlpha << 24) | 0xFFFFFF;
            final Shape shape = new Shape(matrix, outlineX + 1, outlineY + 1,
                    outlineWidth - 2, outlineHeight - 2);
            shape.outline(0.75f, ColorUtil.reAlphaInt(outlineColor, (int) (125 * lineAlpha)), ColorUtil.reAlphaInt(outlineColor, (int) (255 * lineAlpha)), ColorUtil.reAlphaInt(outlineColor, (int) (125 * lineAlpha)), ColorUtil.reAlphaInt(outlineColor, (int) (255 * lineAlpha)), Round.of(radiusOutline));
        }
        }




    private float calculateOptimalCornerRadius(float width, float height) {
        float baseRadius = 7;
        float minDimension = Math.min(width, height);
        float maxRadius = minDimension / 4f;
        float proportionalRadius = minDimension * 0.1f;
        float optimalRadius = Math.min(proportionalRadius, maxRadius);
        optimalRadius = Math.max(optimalRadius, baseRadius);
        if (minDimension < 20) {
            optimalRadius = 5;
        }
        return optimalRadius;
    }

    private void drawGridLines(MainWindow res) {
        float alpha = lineAlpha * 1;
        int color = ((int) (alpha * 125) << 24) | 0xFFFFFF;
        if (showVerticalLine) {
            RenderUtil.drawRoundedRect(closestVerticalLine, 0, 1, res.scaledHeight(), 0, color);
        }
        if (showHorizontalLine) {
            RenderUtil.drawRoundedRect(0, closestHorizontalLine, res.scaledWidth(), 1, 0, color);
        }
    }

    private void updateLineAlpha(boolean increasing, float deltaTime) {
        if (increasing) {
            lineAlpha += deltaTime * 4;
            if (lineAlpha > 1.0f) lineAlpha = 1.0f;
        } else {
            lineAlpha -= deltaTime * 4;
            if (lineAlpha < 0.0f) lineAlpha = 0.0f;
        }
    }


    private void checkClosestGridLines() {
        closestVerticalLine = Math.round(xPos / grid) * grid;
        closestHorizontalLine = Math.round(yPos / grid) * grid;
        showVerticalLine = Math.abs(xPos - closestVerticalLine) < snap_thr;
        showHorizontalLine = Math.abs(yPos - closestHorizontalLine) < snap_thr;
    }

    private float snap(float pos, float gridSpacing, float snapThreshold) {
        float gridPos = Math.round(pos / gridSpacing) * gridSpacing;
        if (Math.abs(pos - gridPos) < snapThreshold) {
            return gridPos;
        }
        return pos;
    }

    public final boolean onClick(double mouseX, double mouseY, int button) {
        Vec2i fixed = ClientUtil.getMouse((int) mouseX, (int) mouseY);
        mouseX = fixed.getX();
        mouseY = fixed.getY();

        if (button == 0 && MathUtil.isHovered((float) mouseX, (float) mouseY, xPos, yPos, width, height)) {
            dragging = true;
            startX = (int) (mouseX - xPos);
            startY = (int) (mouseY - yPos);
            lastUpdateTime = System.currentTimeMillis();
            return true;
        }
        return false;
    }

    public final void onRelease(int button) {
        if (button == 0) dragging = false;
    }

    public void resetPosition() {
        this.xPos = this.initialXVal;
        this.yPos = this.initialYVal;
        this.targetX = this.initialXVal;
        this.targetY = this.initialYVal;
    }
}

Удачи всем! Если что то не так, или я что то забыл дать, напишите в комментах, также можете заменить обводку на свою, но могут возникнуть ошибки
это с релейка если чо
 
бессмысленно как по мне, но пусть будет
не, смысл имеет. Да бессмысленно, но маленький смысл оно имеет. Но надо для этого реализацию делать правильной+дать доступ например при удерживании какой то кнопки чтобы она выключалась и можно было спокойно передвигать. Там оно будет смысл иметь от правильной реализации.
 
Назад
Сверху Снизу