Начинающий
- Статус
- Оффлайн
- Регистрация
- 8 Авг 2025
- Сообщения
- 21
- Реакции
- 0
- Выберите загрузчик игры
- Fabric
- OptiFine
Привет югейм!
Решил сделать завозик вам, это моя первая тема на югейме, не бейте палками.
Так ладно ближе к делу, данная функция если её можно так назвать рандомизирует никнейм как в
nursultan(noad). Надеюсь не будет -rep/del. Я старался.
Code:
SS:(Прикреплен к теме)
Сделано: Spartanec&Rastyshka1337
Спартанец не бей палкой по пузику пжж
Слито by SpookyClient.fun(NOAD)
Решил сделать завозик вам, это моя первая тема на югейме, не бейте палками.
Так ладно ближе к делу, данная функция если её можно так назвать рандомизирует никнейм как в
nursultan(noad). Надеюсь не будет -rep/del. Я старался.
Code:
Великий код:
package SpookyClient.ui.ALT;
import SpookyClient.SpookySelfCoder;
import SpookyClient.utils.client.IMinecraft;
import SpookyClient.utils.math.MathUtil;
import SpookyClient.utils.render.ColorUtils;
import SpookyClient.utils.render.DisplayUtils;
import SpookyClient.utils.render.Scissor;
import com.mojang.blaze3d.matrix.MatrixStack;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.Iterator;
import java.util.Random;
import java.util.UUID;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.util.Session;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
public class NewAltManager extends Screen implements IMinecraft {
private TextFieldWidget Search;
public ArrayList<Account> accounts = new ArrayList<>();
public float scroll;
public float scrollAn;
private String selectedString = "";
// Random name generation fields
private final Set<String> usedNames = new HashSet<>();
private final long globalSeed = UUID.randomUUID().getMostSignificantBits() ^ System.nanoTime();
public NewAltManager() {
super(new StringTextComponent(""));
}
public String generateUniqueFakeName() {
Random random = new Random(System.nanoTime() ^ globalSeed);
String[] nameStart = {
"Kai", "Lex", "Val", "Max", "Zor", "Dex", "Tor", "Ren", "Leo", "Luc",
"Rav", "Ash", "Ard", "Nik", "Sam", "Ben", "Kel", "Jax", "Nol", "Vin",
"Tyr", "Sil", "Cai", "Dar", "Fen", "Gav", "Mal", "Neo"
};
String[] nameEnd = {
"on", "ix", "us", "en", "or", "el", "ar", "an", "eo", "is", "eth", "il",
"ad", "os", "an", "eus", "es", "ym", "ax", "ik"
};
String[] suffixes = {"x", "q", "zz", "ai", "xy", "zor", "ar", "yn"};
int tries = 0;
String finalName;
do {
StringBuilder name = new StringBuilder();
// Основа
String start = nameStart[random.nextInt(nameStart.length)];
String end = nameEnd[random.nextInt(nameEnd.length)];
name.append(start).append(end);
// AI-суффикс
if (random.nextFloat() < 0.25f) {
name.append(suffixes[random.nextInt(suffixes.length)]);
}
// Вставка заглавной буквы
if (random.nextFloat() < 0.15f && name.length() >= 4) {
int mid = 1 + random.nextInt(name.length() - 2);
name.setCharAt(mid, Character.toUpperCase(name.charAt(mid)));
}
// Подчёркивание (редко)
if (random.nextFloat() < 0.2f) {
name.append("_");
}
// Обязательно добавим уникализирующую часть
long uniquePart = (System.currentTimeMillis() + tries * 1234567 + globalSeed) & 0xFFFFF;
name.append(uniquePart % 10000); // Например 4 цифры
finalName = name.toString();
tries++;
} while (usedNames.contains(finalName) && tries < 20);
usedNames.add(finalName);
return finalName;
}
@Override
public void tick() {
this.Search.tick();
super.tick();
}
@Override
protected void init() {
super.init();
float[] center = new float[]{this.width / 2.0F, this.height - 60};
int width = 150;
this.addButton(new Button((int)center[0] - 150, (int)center[1] + 5, width, 20, new TranslationTextComponent("Login"), ppp -> {
if (this.selectedString != null) {
for (Account account : this.accounts) {
if (account.accountName.equals(this.selectedString)) {
mc.session = new Session(account.accountName, "", "", "mojang");
AltConfig.updateFile();
break;
}
}
}
}));
this.addButton(
new Button(
(int)center[0] + 5,
(int)center[1] + 5,
width,
20,
new TranslationTextComponent("Add account"),
ppp -> mc.displayGuiScreen(Dick.getInstance().getALT_ADD())
)
);
this.addButton(new Button((int)center[0] - 150, (int)center[1] + 30, width, 20, new TranslationTextComponent("Delete"), ppp -> {
if (this.selectedString != null) {
Iterator<Account> iterator = this.accounts.iterator();
while (iterator.hasNext()) {
Account account = iterator.next();
if (account.accountName.equals(this.selectedString)) {
iterator.remove();
AltConfig.updateFile();
break;
}
}
}
}));
this.addButton(new Button((int)center[0] + 5, (int)center[1] + 30, width, 20, new TranslationTextComponent("Cancel"), ppp -> this.closeScreen()));
this.Search = new TextFieldWidget(this.font, this.width / 2 - 100, 20, 200, 20, new TranslationTextComponent("Searcher"));
this.Search.setFocused2(false);
this.Search.setText("");
this.children.add(this.Search);
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
float x = this.width / 2.0F - 125.0F;
float y = IMinecraft.mc.getMainWindow().getScaledHeight() / 2.0F - this.height / 2.0F + 25.0F;
float size = 0.0F;
float iter = this.scrollAn;
float offsetAccounts = 0.0F;
float offset = 6.0F;
float max = 0.0F;
this.scrollAn = MathUtil.lerp(this.scrollAn, this.scroll, 5.0F);
this.renderBackground(matrixStack);
DisplayUtils.drawRoundedRect(0.0F, 50.0F, this.width, this.height - 120, 0.0F, 1.0F, ColorUtils.rgba(10, 10, 10, 200));
drawCenteredString(matrixStack, this.font, "Account Manager (" + mc.session.getUsername() + ")", this.width / 2, 5, -1);
// Show current filter mode under title
this.Search.render(matrixStack, mouseX, mouseY, partialTicks);
Scissor.push();
Scissor.setFromComponentCoordinates(0, 50, this.width, this.height - 120);
int count = 0;
// render favorites first
Set<String> seen = new HashSet<>();
for (Account account : this.accounts) {
if (!account.favorite) continue;
if (!seen.add(account.accountName)) continue;
boolean isCurrentAcc = mc.session != null && mc.session.getUsername() != null && mc.session.getUsername().equalsIgnoreCase(account.accountName);
if (account.accountName.toLowerCase().contains(this.Search.getText().toLowerCase())) {
float scrollY = y + iter * 17.0F;
drawString(
matrixStack,
this.font,
++count + "",
(int)(x - 3.0F - this.font.getStringWidth(count + "")),
(int)(scrollY + offset + 25.0F + offsetAccounts),
-1
);
boolean isCurrent = mc.session != null && mc.session.getUsername() != null && mc.session.getUsername().equalsIgnoreCase(account.accountName);
int nameColor = isCurrent ? ColorUtils.rgb(255, 60, 60) : ColorUtils.rgb(255, 215, 0);
int iconX = (int)x + 15;
if (isCurrent) {
drawString(matrixStack, this.font, "▶", iconX, (int)(scrollY + offset + 25.0F + offsetAccounts), ColorUtils.rgb(255, 60, 60));
iconX += this.font.getStringWidth("▶ ");
}
drawString(matrixStack, this.font, account.accountName + " ★", iconX, (int)(scrollY + offset + 25.0F + offsetAccounts), nameColor);
if (account.accountName.equals(this.selectedString)) {
this.renderActives(matrixStack, x, scrollY + 34.0F);
}
mc.getTextureManager().bindTexture(account.skin);
AbstractGui.drawScaledCustomSizeModalRect(x, scrollY + offset + 22.0F + offsetAccounts, 8.0F, 8.0F, 8.0F, 8.0F, 12.0F, 12.0F, 64.0F, 64.0F);
size++;
iter++;
}
}
// separator for non-favorites
boolean anyFav = this.accounts.stream().anyMatch(a -> a.favorite);
if (anyFav) {
float titleY2 = y + iter * 17.0F + 8.0F;
drawCenteredString(matrixStack, this.font, "Accounts", this.width / 2, (int)titleY2, ColorUtils.rgba(220, 220, 220, 255));
iter += 2.0F;
}
for (Account account : this.accounts) {
if (account.favorite) continue;
if (!seen.add(account.accountName)) continue;
boolean isCurrentAcc = mc.session != null && mc.session.getUsername() != null && mc.session.getUsername().equalsIgnoreCase(account.accountName);
if (account.accountName.toLowerCase().contains(this.Search.getText().toLowerCase())) {
float scrollY = y + iter * 17.0F;
drawString(
matrixStack,
this.font,
++count + "",
(int)(x - 3.0F - this.font.getStringWidth(count + "")),
(int)(scrollY + offset + 25.0F + offsetAccounts),
-1
);
boolean isCurrent = mc.session != null && mc.session.getUsername() != null && mc.session.getUsername().equalsIgnoreCase(account.accountName);
int nameColor = isCurrent ? ColorUtils.rgb(255, 60, 60) : -1;
int iconX = (int)x + 15;
if (isCurrent) {
drawString(matrixStack, this.font, "▶", iconX, (int)(scrollY + offset + 25.0F + offsetAccounts), ColorUtils.rgb(255, 60, 60));
iconX += this.font.getStringWidth("▶ ");
}
drawString(matrixStack, this.font, account.accountName, iconX, (int)(scrollY + offset + 25.0F + offsetAccounts), nameColor);
if (account.accountName.equals(this.selectedString)) {
this.renderActives(matrixStack, x, scrollY + 34.0F);
}
mc.getTextureManager().bindTexture(account.skin);
AbstractGui.drawScaledCustomSizeModalRect(x, scrollY + offset + 22.0F + offsetAccounts, 8.0F, 8.0F, 8.0F, 8.0F, 12.0F, 12.0F, 64.0F, 64.0F);
size++;
iter++;
}
}
Scissor.unset();
Scissor.pop();
this.scroll = MathHelper.clamp(this.scroll, -iter, 0.0F);
this.scrollAn = MathHelper.clamp(this.scrollAn, -iter, 0.0F);
// Draw random nick button (bottom-left)
float btnX = 10.0F;
float btnY = this.height - 30.0F;
float btnW = 110.0F;
float btnH = 18.0F;
DisplayUtils.drawRoundedRect(btnX, btnY, btnW, btnH, 3.0F, 1.0F, ColorUtils.rgba(20, 20, 20, 200));
drawCenteredString(matrixStack, this.font, "Random Nick", (int)(btnX + btnW / 2.0F), (int)(btnY + 5.0F), -1);
// Draw Favorite toggle button next to it
float favBtnX = btnX + btnW + 8.0F;
float favBtnY = btnY;
float favBtnW = 90.0F;
float favBtnH = btnH;
DisplayUtils.drawRoundedRect(favBtnX, favBtnY, favBtnW, favBtnH, 3.0F, 1.0F, ColorUtils.rgba(20, 20, 20, 200));
drawCenteredString(matrixStack, this.font, "Favorite", (int)(favBtnX + favBtnW / 2.0F), (int)(favBtnY + 5.0F), ColorUtils.rgb(255, 215, 0));
super.render(matrixStack, mouseX, mouseY, partialTicks);
}
public static void renderModel2D(Account account, float x, float y) {
IMinecraft.mc.getTextureManager().bindTexture(account.skin);
AbstractGui.drawScaledCustomSizeModalRect(20.0F, y, 8.0F, 8.0F, 8.0F, 8.0F, 12.0F, 12.0F, 64.0F, 64.0F);
}
public void renderActives(MatrixStack stack, float x, float y) {
DisplayUtils.drawRoundedRect(x - 2.0F, y + 7.0F, 251.0F, 1.0F, 0.0F, 0.0F, ColorUtils.rgba(180, 180, 180, 255));
DisplayUtils.drawRoundedRect(x - 2.0F, y - 8.0F, 250.0F, 1.0F, 0.0F, 0.0F, ColorUtils.rgba(180, 180, 180, 255));
DisplayUtils.drawRoundedRect(x - 2.0F, y - 8.0F, 1.0F, 15.0F, 0.0F, 0.0F, ColorUtils.rgba(180, 180, 180, 255));
DisplayUtils.drawRoundedRect(x + 248.0F, y - 8.0F, 1.0F, 15.0F, 0.0F, 0.0F, ColorUtils.rgba(180, 180, 180, 255));
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
float x = this.width / 2.0F - 125.0F;
float y = IMinecraft.mc.getMainWindow().getScaledHeight() / 2.0F - this.height / 2.0F + 25.0F;
float iter = this.scrollAn;
float offsetAccounts = 0.0F;
float offset = 6.0F;
if (MathUtil.isHovered((float)mouseX, (float)mouseY, 0.0F, 50.0F, this.width, this.height - 120)) {
float rowHeightPx = 17.0F;
float baseYpx = y + this.scrollAn * rowHeightPx;
java.util.Set<String> seenClick = new java.util.HashSet<>();
// favorites first
for (Account account : this.accounts) {
if (!account.favorite) continue;
if (!seenClick.add(account.accountName)) continue;
if (account.accountName.toLowerCase().contains(this.Search.getText().toLowerCase())) {
float rowTop = baseYpx + offset + 20.0F + offsetAccounts;
if (MathUtil.isHovered((float)mouseX, (float)mouseY, x - 5.0F, rowTop, 250.0F, rowHeightPx) && button == 0) {
this.selectedString = account.accountName;
return true;
}
baseYpx += rowHeightPx;
}
}
boolean anyFav = this.accounts.stream().anyMatch(a -> a.favorite);
if (anyFav) {
// add the 8px offset used to draw the title and then two rows worth spacing
baseYpx += 8.0F;
baseYpx += 2.0F * rowHeightPx;
}
for (Account account : this.accounts) {
if (account.favorite) continue;
if (!seenClick.add(account.accountName)) continue;
if (account.accountName.toLowerCase().contains(this.Search.getText().toLowerCase())) {
float rowTop = baseYpx + offset + 20.0F + offsetAccounts;
if (MathUtil.isHovered((float)mouseX, (float)mouseY, x - 5.0F, rowTop, 250.0F, rowHeightPx) && button == 0) {
this.selectedString = account.accountName;
return true;
}
baseYpx += rowHeightPx;
}
}
}
// Random nick button at bottom-left
float btnX = 10.0F;
float btnY = this.height - 30.0F;
float btnW = 110.0F;
float btnH = 18.0F;
if (MathUtil.isHovered((float)mouseX, (float)mouseY, btnX, btnY, btnW, btnH) && button == 0) {
// generate unique random nick using sophisticated algorithm
String nick = generateUniqueFakeName();
mc.session = new Session(nick, "", "", "mojang");
Account acc = new Account(nick);
acc.favorite = true;
AltConfig.addAndSave(acc);
// add to list and select
this.accounts.add(0, acc);
this.selectedString = nick;
return true;
}
// Favorite button click
float favBtnX = btnX + btnW + 8.0F;
float favBtnY = btnY;
float favBtnW = 90.0F;
float favBtnH = btnH;
if (MathUtil.isHovered((float)mouseX, (float)mouseY, favBtnX, favBtnY, favBtnW, favBtnH) && button == 0) {
if (this.selectedString != null && !this.selectedString.isEmpty()) {
for (Account account : this.accounts) {
if (account.accountName.equals(this.selectedString)) {
account.favorite = !account.favorite;
AltConfig.updateFile();
break;
}
}
}
return true;
}
return super.mouseClicked(mouseX, mouseY, button);
}
@Override
public boolean mouseReleased(double mouseX, double mouseY, int button) {
return super.mouseReleased(mouseX, mouseY, button);
}
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
if (MathUtil.isHovered((float)mouseX, (float)mouseY, 0.0F, 50.0F, this.width, this.height - 120)) {
this.scroll += (float)(delta * 2.0);
}
return super.mouseScrolled(mouseX, mouseY, delta);
}
}
Сделано: Spartanec&Rastyshka1337
Спартанец не бей палкой по пузику пжж
Слито by SpookyClient.fun(NOAD)