-
Автор темы
- #1
Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:
- бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
- маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
- приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
- обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.
Спасибо!
Привет всем, я делаю пасту expensive (пока что не полностью ренеймнута) и я добавил меню. Но кнопка Config не в нём и не нажимается. Что мне сделать? Вот код Window.java:
SS проблемы:
Java:
package wtf.expensive.ui.clickgui;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector4f;
import net.minecraft.util.text.ITextComponent;
import org.lwjgl.glfw.GLFW;
import wtf.expensive.managment.Managment;
import wtf.expensive.modules.Function;
import wtf.expensive.modules.Type;
import wtf.expensive.ui.clickgui.configs.ConfigDrawing;
import wtf.expensive.ui.clickgui.objects.ModuleObject;
import wtf.expensive.ui.clickgui.objects.Object;
import wtf.expensive.ui.clickgui.objects.sets.BindObject;
import wtf.expensive.ui.clickgui.theme.ThemeDrawing;
import wtf.expensive.util.ClientUtil;
import wtf.expensive.util.IMinecraft;
import wtf.expensive.util.font.Fonts;
import wtf.expensive.util.math.MathUtil;
import wtf.expensive.util.render.*;
import wtf.expensive.util.render.animation.AnimationMath;
import java.awt.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static wtf.expensive.util.IMinecraft.mc;
public class Window extends Screen {
private Vector2f position = new Vector2f(0, 0);
public static Vector2f size = new Vector2f(600, 500);
public static int dark = new Color(18, 19, 25).getRGB();
public static int medium = new Color(18, 19, 25).brighter().getRGB();
public static int light = new Color(129, 134, 153).getRGB();
private Type currentCategory;
private ThemeDrawing themeDrawing = new ThemeDrawing();
private ConfigDrawing configDrawing = new ConfigDrawing();
private ArrayList<ModuleObject> objects = new ArrayList<>();
public Window(ITextComponent titleIn) {
super(titleIn);
scrolling = 0;
for (Function function : Managment.FUNCTION_MANAGER.getFunctions()) {
objects.add(new ModuleObject(function));
}
this.previousCategory = Type.values()[0]; // Устанавливаем начальное значение как первую категорию
}
@Override
protected void init() {
super.init();
size = new Vector2f(450, 350);
position = new Vector2f(mc.getMainWindow().scaledWidth() / 2f - size.x / 2f, mc.getMainWindow().scaledHeight() / 2f - size.y / 2f);
}
public static float scrolling;
public static float scrollingOut;
public boolean searching;
private String searchText = "";
@Override
public boolean isPauseScreen() {
return false;
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
mc.gameRenderer.setupOverlayRendering(2);
float scale = 2f;
float width = 1200 / scale;
float height = 500 / scale;
float x = MathUtil.calculateXPosition(IMinecraft.mc.getMainWindow().scaledWidth() / 2f, width);
float y = MathUtil.calculateXPosition(IMinecraft.mc.getMainWindow().scaledHeight() / 2f, height);
super.render(matrixStack, mouseX, mouseY, partialTicks);
Vec2i fixed = ScaleMath.getMouse((int) mouseX, (int) mouseY);
mouseX = fixed.getX();
mouseY = fixed.getY();
RenderUtil.Render2D.drawRoundedCorner(x, y + 22, width, height, new Vector4f(0, 10, 0, 10), new Color(28, 28, 28, 255).getRGB());
RenderUtil.Render2D.drawRoundedCorner(x, y, width, 22, new Vector4f(10, 0, 10, 0), new Color(41, 41, 41, 255).getRGB());
RenderUtil.Render2D.drawRoundedRect(x + height - 30, y + height + 25, 140, 20, 3, ColorUtil.rgba(14, 14, 14, 255));
if (!searching && searchText.isEmpty()) {
Fonts.msSemiBold[16].drawCenteredString(matrixStack, "Search...", x + (y * 2 + 28), y + height + 32, RenderUtil.reAlphaInt(light, 200));
} else {
Fonts.msSemiBold[16].drawString(matrixStack, searchText + (searching ? (System.currentTimeMillis() % 1000 > 500 ? "|" : "") : ""),
x + (y * 2 - 30), y + height + 32, RenderUtil.reAlphaInt(light, 200));
}
// 9966
float len = 5;
for (Type type : Type.values()) {
type.anim = AnimationMath.fast((float) type.anim, type == currentCategory ? 1 : 0, 10);
if (type.anim > 0.001) {
String typeName = type.name();
int textWidth = (int) Fonts.msBold[14].getWidth(typeName) + 10;
RenderUtil.Render2D.drawShadow(x + len + 9, y + 5, textWidth, 10, (int) (12),
RenderUtil.reAlphaInt(ColorUtil.getColorStyle(100), (int) (255 * type.anim)),
RenderUtil.reAlphaInt(ColorUtil.getColorStyle(0), (int) (255 * type.anim)),
RenderUtil.reAlphaInt(ColorUtil.getColorStyle(0), (int) (255 * type.anim)),
RenderUtil.reAlphaInt(ColorUtil.getColorStyle(100), (int) (255 * type.anim)));
RenderUtil.Render2D.drawShadow(x + len + 9, y + 5, textWidth, 10, (int) (12),
RenderUtil.reAlphaInt(ColorUtil.getColorStyle(100), (int) (255 * type.anim)),
RenderUtil.reAlphaInt(ColorUtil.getColorStyle(0), (int) (255 * type.anim)),
RenderUtil.reAlphaInt(ColorUtil.getColorStyle(0), (int) (255 * type.anim)),
RenderUtil.reAlphaInt(ColorUtil.getColorStyle(100), (int) (255 * type.anim)));
RenderUtil.Render2D.drawGradientRound(x + len + 9, y + 5, textWidth, 10, (int) (5),
RenderUtil.reAlphaInt(ColorUtil.getColorStyle(100), (int) (255 * type.anim)),
RenderUtil.reAlphaInt(ColorUtil.getColorStyle(0), (int) (255 * type.anim)),
RenderUtil.reAlphaInt(ColorUtil.getColorStyle(0), (int) (255 * type.anim)),
RenderUtil.reAlphaInt(ColorUtil.getColorStyle(100), (int) (255 * type.anim)));
}
String typeName = type.name();
int textWidth = (int) Fonts.msBold[14].getWidth(typeName);
if (type == currentCategory) {
int textColor = interpolateColor(light, ColorUtil.getColorStyle(90), (float) type.anim * 255);
Fonts.msBold[14].drawString(matrixStack, ClientUtil.gradient(typeName,
ColorUtil.rgba(44, 44, 44, 255), ColorUtil.rgba(44, 44, 44, 255)), x + len + 15, y + 8, textColor);
} else {
Fonts.msBold[14].drawString(matrixStack, typeName, x + len + 15, y + 8, light);
}
len += textWidth + 62;
}
if (currentCategory == Type.Theme) {
themeDrawing.draw(matrixStack, mouseX, mouseY, position.x + 100, position.y, size.x - 100, size.y);
}
if (currentCategory == Type.Configs) {
configDrawing.draw(matrixStack, mouseX, mouseY, position.x + 100, position.y, size.x - 100, size.y - 80);
}
if (currentCategory != Type.Theme && currentCategory != Type.Configs)
drawModules(matrixStack, mouseX, mouseY);
scrollingOut = AnimationMath.fast(scrollingOut, scrolling, 15);
for (Object object : objects) {
if (object instanceof ModuleObject m) {
m.bindWindow.render(matrixStack, mouseX, mouseY);
for (Object object1 : m.object) {
if (object1 instanceof BindObject no) {
no.bindWindow.render(matrixStack, mouseX, mouseY);
}
}
}
}
// mc.gameRenderer.setupOverlayRendering();
}
@Override
public boolean charTyped(char codePoint, int modifiers) {
if (currentCategory == Type.Configs)
configDrawing.charTyped(codePoint);
if (configDrawing.searching && configDrawing.search.length() < 23) {
configDrawing.search += codePoint;
}
if (searching && searchText.length() < 13) {
searchText += codePoint;
}
return super.charTyped(codePoint, modifiers);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
for (ModuleObject m : objects) {
if (m.function.category == currentCategory)
m.keyTyped(keyCode, scanCode, modifiers);
}
if (currentCategory == Type.Configs)
configDrawing.keyTyped(keyCode);
if (configDrawing.searching) {
if (keyCode == GLFW.GLFW_KEY_BACKSPACE) {
if (!configDrawing.search.isEmpty())
configDrawing.search = configDrawing.search.substring(0, configDrawing.search.length() - 1);
}
if (keyCode == GLFW.GLFW_KEY_ENTER) {
configDrawing.searching = false;
}
}
if (searching) {
if (keyCode == GLFW.GLFW_KEY_BACKSPACE) {
if (!searchText.isEmpty())
searchText = searchText.substring(0, searchText.length() - 1);
}
if (keyCode == GLFW.GLFW_KEY_ENTER) {
searching = false;
}
}
for (Object object : objects) {
if (object instanceof ModuleObject m) {
m.bindWindow.keyPress(keyCode);
for (Object object1 : m.object) {
if (object1 instanceof BindObject no) {
no.bindWindow.keyPress(keyCode);
if (no.bindWindow.binding && keyCode == GLFW.GLFW_KEY_ESCAPE) {
return false;
}
}
}
}
}
return super.keyPressed(keyCode, scanCode, modifiers);
}
@Override
public boolean mouseReleased(double mouseX, double mouseY, int button) {
Vec2i fixed = ScaleMath.getMouse((int) mouseX, (int) mouseY);
mouseX = fixed.getX();
mouseY = fixed.getY();
for (ModuleObject m : objects) {
if (searching || !searchText.isEmpty()) {
if (!searchText.isEmpty())
if (!m.function.name.toLowerCase().contains(searchText.toLowerCase())) continue;
m.mouseReleased((int) mouseX, (int) mouseY, button);
} else {
if (m.function.category == currentCategory)
m.mouseReleased((int) mouseX, (int) mouseY, button);
}
}
for (Object object : objects) {
if (object instanceof ModuleObject m) {
m.bindWindow.mouseUn();
for (Object object1 : m.object) {
if (object1 instanceof BindObject no) {
no.bindWindow.mouseUn();
}
}
}
}
return super.mouseReleased(mouseX, mouseY, button);
}
@Override
public void onClose() {
super.onClose();
searching = false;
for (ModuleObject m : objects) {
m.exit();
}
}
private int interpolateColor(int startColor, int endColor, float percent) {
int startA = (startColor >> 24) & 0xFF;
int startR = (startColor >> 16) & 0xFF;
int startG = (startColor >> 8) & 0xFF;
int startB = startColor & 0xFF;
int endA = (endColor >> 24) & 0xFF;
int endR = (endColor >> 16) & 0xFF;
int endG = (endColor >> 8) & 0xFF;
int endB = endColor & 0xFF;
int interpolatedA = (int) (startA + (endA - startA) * percent);
int interpolatedR = (int) (startR + (endR - startR) * percent);
int interpolatedG = (int) (startG + (endG - startG) * percent);
int interpolatedB = (int) (startB + (endB - startB) * percent);
return (interpolatedA << 24) | (interpolatedR << 16) | (interpolatedG << 8) | interpolatedB;
}
private float offset = 0;
private static final float MIN_SCROLL_VALUE = -400;
private static final float MAX_SCROLL_VALUE = 0;
private Type previousCategory;
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
scrolling += (float) (delta * 30);
scrolling = Math.max(MIN_SCROLL_VALUE, Math.min(scrolling, MAX_SCROLL_VALUE));
return super.mouseScrolled(mouseX, mouseY, delta);
}
private void drawModules(MatrixStack stack, int mouseX, int mouseY) {
float scale = 2.3f;
float width = 1200 / scale;
float height = 500 / scale;
float x = MathUtil.calculateXPosition(IMinecraft.mc.getMainWindow().scaledWidth() / 2f, width);
float y = MathUtil.calculateXPosition(IMinecraft.mc.getMainWindow().scaledHeight() / 2f, height);
RenderUtil.SmartScissor.push();
RenderUtil.SmartScissor.setFromComponentCoordinates(x, y + 22, width, height);
List<ModuleObject> visibleObjects = objects.stream()
.filter(object -> (searchText.isEmpty() || object.function.name.toLowerCase().contains(searchText.toLowerCase()))
&& (searching || object.function.category == currentCategory))
.collect(Collectors.toList());
visibleObjects.sort(Comparator.comparingInt(o -> o.function.name.toLowerCase().hashCode()));
float maxPanelSize = 0;
for (int column = 0; column < 3; column++) {
float offset = scrollingOut;
List<ModuleObject> columnObjects = new ArrayList<>();
int objectsPerColumn = (visibleObjects.size() + 2) / 3;
int startIndex = column * objectsPerColumn;
int endIndex = Math.min((column + 1) * objectsPerColumn, visibleObjects.size());
for (int i = startIndex; i < endIndex; i++) {
ModuleObject object = visibleObjects.get(i);
object.x = x + (column * 180) + 42;
object.y = y + 55 + offset;
object.width = 160;
object.height = 22;
for (Object object1 : object.object) {
if (object1.setting.visible()) {
object.height += object1.height;
}
}
object.height += 3;
if (object.y - object.height - 300 < size.y) {
object.draw(stack, mouseX, mouseY);
}
if (maxPanelSize > size.y) {
scrollingOut = Math.max(MIN_SCROLL_VALUE, Math.min(scrollingOut, maxPanelSize - size.y));
}
if (currentCategory != previousCategory) {
scrollingOut = 0;
previousCategory = currentCategory;
}
offset += object.height + 5;
maxPanelSize = Math.max(maxPanelSize, offset);
}
}
RenderUtil.SmartScissor.unset();
RenderUtil.SmartScissor.pop();
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
Vec2i fixed = ScaleMath.getMouse((int) mouseX, (int) mouseY);
mouseX = fixed.getX();
mouseY = fixed.getY();
float scale = 2f;
float width = 1200 / scale;
float height = 500 / scale;
float x = MathUtil.calculateXPosition(IMinecraft.mc.getMainWindow().scaledWidth() / 2f, width);
float y = MathUtil.calculateXPosition(IMinecraft.mc.getMainWindow().scaledHeight() / 2f, height);
if (RenderUtil.isInRegion(mouseX, mouseY, x, y, width, 22)) {
float xOffset = 10;
float len = xOffset;
for (Type type : Type.values()) {
String typeName = type.name();
int textWidth = (int) Fonts.msBold[14].getWidth(typeName);
type.anim = AnimationMath.fast((float) type.anim, type == currentCategory ? 1 : 0, 10);
if (RenderUtil.isInRegion(mouseX, mouseY, x + len + 4, y + 5, textWidth + 5, 10)) {
currentCategory = type;
searching = false;
scrolling = 0; // Установка значения scrolling в 0 при смене категории
}
len += textWidth + 62;
}
return false;
}
if (RenderUtil.isInRegion(mouseX, mouseY, x + height - 30, y + height + 25, 140, 20)) {
if (RenderUtil.isInRegion(mouseX, mouseY, x + height - 30, y + height + 25, 140, 20)) {
searching = !searching;
}
}
if (RenderUtil.isInRegion(mouseX, mouseY, x, y + 22, width, height)) {
if (currentCategory == Type.Theme) {
themeDrawing.click((int) mouseX, (int) mouseY, button);
}
if (currentCategory == Type.Configs) {
configDrawing.click((int) mouseX, (int) mouseY, button);
}
for (ModuleObject m : objects) {
if ((searching || !searchText.isEmpty()) && m.function.name.toLowerCase().contains(searchText.toLowerCase())) {
m.mouseClicked((int) mouseX, (int) mouseY, button);
} else if (m.function.category == currentCategory) {
m.mouseClicked((int) mouseX, (int) mouseY, button);
}
}
for (Object object : objects) {
if (object instanceof ModuleObject m) {
m.bindWindow.mouseClick((int) mouseX, (int) mouseY, button);
for (Object object1 : m.object) {
if (object1 instanceof BindObject no) {
no.bindWindow.mouseClick((int) mouseX, (int) mouseY, button);
}
}
}
}
}
return false;
}
}
Пожалуйста, авторизуйтесь для просмотра ссылки.