Начинающий
- Статус
- Оффлайн
- Регистрация
- 28 Авг 2023
- Сообщения
- 174
- Реакции
- 24
Что ты блять апгрейдишь? Китаец ебаный блятьmade in China
made in johON0, attack.dev, china (xzxcasd)
by Centric Developers
Drag.java:public class Drag { private float xPos, yPos; private float startX, startY; private boolean dragging; public Drag(float initialXVal, float initialYVal) { this.xPos = initialXVal; this.yPos = initialYVal; } public float getX() { return xPos; } public void setX(float x) { this.xPos = x; } public float getY() { return yPos; } public void setY(float y) { this.yPos = y; } public final void onDraw(int mouseX, int mouseY) { if (dragging) { xPos = (mouseX - startX); yPos = (mouseY - startY); } } public final void onDrawNegX(int mouseX, int mouseY) { if (dragging) { xPos = -(mouseX - startX); yPos = (mouseY - startY); } } public final void onClick(int mouseX, int mouseY, int button, boolean canDrag) { if (button == 0 && canDrag) { dragging = true; startX = (int) (mouseX - xPos); startY = (int) (mouseY - yPos); } } public final void onClickAddX(int mouseX, int mouseY, int button, boolean canDrag) { if (button == 0 && canDrag) { dragging = true; startX = (int) (mouseX + xPos); startY = (int) (mouseY - yPos); } } public final void onRelease(int button) { if (button == 0) dragging = false; } }
Dragging.java:public class Dragging { @Expose @SerializedName("x") private float xPos; @Expose @SerializedName("y") private float yPos; public float initialXVal; public float initialYVal; private float startX, startY; private boolean dragging; private float width, height; @Expose @SerializedName("name") private final String name; private final Function module; private static final float grid = 20; private static final float snap_thr = 10; private float lineAlpha = 0.0f; private long lastUpdateTime; private boolean showVerticalLine = false; private boolean showHorizontalLine = false; private float closestVerticalLine = 0; private float closestHorizontalLine = 0; private final float resetButtonWidth = 110; private final float resetButtonHeight = 16; private final String resetButtonText = "Reset Draggables"; public Dragging(Function module, String name, float initialXVal, float initialYVal) { this.module = module; this.name = name; this.xPos = initialXVal; this.yPos = initialYVal; this.initialXVal = initialXVal; this.initialYVal = initialYVal; } public Function getModule() { return module; } public String getName() { return name; } public float getWidth() { return width; } public void setWidth(float width) { this.width = width; } 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; } public float getY() { return yPos; } public void setY(float y) { this.yPos = y; } public final void onDraw(int mouseX, int mouseY, MainWindow res) { Vec2i fixed = ClientUtil.getMouse(mouseX, mouseY); mouseX = fixed.getX(); mouseY = fixed.getY(); if (dragging) { xPos = (mouseX - startX); yPos = (mouseY - startY); xPos = snap(xPos, grid, snap_thr); yPos = snap(yPos, grid, snap_thr); if (xPos + width > res.scaledWidth()) { xPos = res.scaledWidth() - width; } if (yPos + height > res.scaledHeight()) { yPos = res.scaledHeight() - height; } if (xPos < 0) { xPos = 0; } if (yPos < 0) { yPos = 0; } updateLineAlpha(true); checkClosestGridLines(); } else { updateLineAlpha(false); showVerticalLine = false; showHorizontalLine = false; } drawGridLines(res); drawResetButton(res, mouseX, mouseY); } 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; } private void updateLineAlpha(boolean increasing) { long currentTime = System.currentTimeMillis(); float deltaTime = (currentTime - lastUpdateTime) / 1000.0f; lastUpdateTime = currentTime; 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 void drawGridLines(MainWindow res) { float alpha = lineAlpha * 1; int color = ((int) (alpha * 255) << 24) | 0xFFFFFF; if (showVerticalLine) { DisplayUtils.drawRoundedRect(closestVerticalLine, 0, 1, res.scaledHeight(), 1, color); } if (showHorizontalLine) { DisplayUtils.drawRoundedRect(0, closestHorizontalLine, res.scaledWidth(), 1, 1, color); } } private void drawResetButton(MainWindow res, int mouseX, int mouseY) { MatrixStack matrixStack = new MatrixStack(); if (Minecraft.getInstance().ingameGUI.getChatGUI().getChatOpen()) { float centerX = (res.scaledWidth() - resetButtonWidth) / 2; float centerY = 5; boolean hovered = mouseX >= centerX && mouseX <= centerX + resetButtonWidth && mouseY >= centerY && mouseY <= centerY + resetButtonHeight; int color = hovered ? 0x90FFFFFF : 0x60FFFFFF; DisplayUtils.drawRoundedRect(centerX, centerY + 20, resetButtonWidth, resetButtonHeight, 6, ColorUtils.rgba(0,0,0,40)); ClientFonts.small_pixel[24].drawString(matrixStack, resetButtonText, centerX + 8, centerY + 25, -1); } } 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 (Minecraft.getInstance().ingameGUI.getChatGUI().getChatOpen()) { float centerX = (Minecraft.getInstance().getMainWindow().getScaledWidth() - resetButtonWidth) / 2; float centerY = 5; if (button == 0 && mouseX >= centerX && mouseX <= centerX + resetButtonWidth && mouseY >= centerY + 20 && mouseY <= centerY + 20 + resetButtonHeight) { DragManager.resetAllPositions(); return true; } } 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; } }
DragManager.java:package fun.centric.api.utils.drag; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import net.minecraft.client.Minecraft; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.StandardOpenOption; import java.util.LinkedHashMap; public class DragManager { public static LinkedHashMap<String, Dragging> draggables = new LinkedHashMap<>(); private static final File DRAG_DATA = new File(Minecraft.getInstance().gameDir, "\\centric\\files\\drags.json"); private static final Gson GSON = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); public static void save() { if (!DRAG_DATA.exists()) { DRAG_DATA.getParentFile().mkdirs(); } try { Files.writeString(DRAG_DATA.toPath(), GSON.toJson(draggables.values())); } catch (IOException ex) { ex.printStackTrace(); } } public static void load() { if (!DRAG_DATA.exists()) { DRAG_DATA.getParentFile().mkdirs(); return; } try { String jsonData = Files.readString(DRAG_DATA.toPath()); Dragging[] draggings = GSON.fromJson(jsonData, Dragging[].class); if (draggings != null) { for (Dragging dragging : draggings) { draggables.put(dragging.getName(), dragging); } } } catch (IOException ex) { ex.printStackTrace(); } } public static void resetAllPositions() { for (Dragging dragging : draggables.values()) { dragging.resetPosition(); } save(); } public static void addDraggable(Dragging dragging) { draggables.put(dragging.getName(), dragging); save(); } public static void removeDraggable(String name) { draggables.remove(name); save(); } }
:screamcat::screamcat::screamcat: