Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Esp minecraft

Забаненный
Забаненный
Статус
Оффлайн
Регистрация
22 Янв 2026
Сообщения
15
Реакции
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
как сделать автоматическое определение рангов в ESP? Чтобы модуль сам определял любую привилегию игрока,код:
package im.expensive.functions.impl.render;

import com.google.common.eventbus.Subscribe;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.google.gson.*;
import im.expensive.events.EventDisplay;
import im.expensive.events.EventPacket;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.settings.impl.BooleanSetting;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.DisplayUtils;
import im.expensive.utils.render.font.Fonts;
import im.expensive.utils.projections.ProjectionUtil;
import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.play.NetworkPlayerInfo;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.server.SChatPacket;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector4f;
import net.minecraft.util.text.ITextComponent;
import org.lwjgl.opengl.GL11;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@FieldDefaults(level = AccessLevel.PRIVATE)
@FunctionRegister(name = "ESP", desc = "ESP над игроками", type = Category.Render)
public class ESP extends Function {

final Minecraft mc = Minecraft.getInstance();

final BooleanSetting showNametags = new BooleanSetting("Никнеймы", true);
final BooleanSetting showArmor = new BooleanSetting("Броня", true);
final BooleanSetting showDistance = new BooleanSetting("Дистанция", true);
final BooleanSetting showItems = new BooleanSetting("Предметы", false);
final BooleanSetting showPlayers = new BooleanSetting("Игроки", true);
final BooleanSetting showMobs = new BooleanSetting("Мобы", false);

final float MAX_RANGE = 100.0f;
final float FONT_SIZE = 6.0f;
final float ITEM_FONT_SIZE = 6.0f;

private final HashMap<Entity, Vector4f> positions = new HashMap<>();
private static final File CONFIG_FILE = new File(Minecraft.getInstance().gameDir, "expensive/ranks.json");
private final Map<String, Rank> ranks = new ConcurrentHashMap<>();
private final Map<String, String> playerRanks = new ConcurrentHashMap<>();

private static class Rank {
String name;
String prefix;
String colorCode;
int color;
int priority;

Rank(String name, String prefix, String colorCode, int color, int priority) {
this.name = name;
this.prefix = prefix;
this.colorCode = colorCode;
this.color = color;
this.priority = priority;
}
}

public ESP() {
addSettings(showNametags, showArmor, showDistance, showItems, showPlayers, showMobs);
loadRanksConfig();
saveDefaultConfig();
}

@Subscribe
private void onUpdate(EventUpdate e) {
if (mc.getConnection() != null && mc.getConnection().getPlayerInfoMap() != null) {
for (NetworkPlayerInfo playerInfo : mc.getConnection().getPlayerInfoMap()) {
ITextComponent displayNameComponent = playerInfo.getDisplayName();
if (displayNameComponent != null) {
String displayName = displayNameComponent.getString();
if (displayName != null && !displayName.isEmpty()) {
parseRankFromDisplayName(displayName);
}
}
}
}
}

@Subscribe
private void onPacket(EventPacket event) {
if (event.isReceive() && event.getPacket() instanceof SChatPacket) {
SChatPacket packet = (SChatPacket) event.getPacket();
String message = packet.getChatComponent().getString();

String cleanMessage = message.replaceAll("§[0-9a-fk-or]", "");
cleanMessage = cleanMessage.replaceAll("[^A-Za-zА-Яа-я0-9\\[\\]\\s]", "");
String withoutClan = cleanMessage.replaceFirst("^\\[[^\\]]+\\]\\s*", "");
String[] parts = withoutClan.split("\\s+");

if (parts.length >= 2) {
String rankName = parts[0].toUpperCase();
String playerName = parts[1];
if (ranks.containsKey(rankName.toLowerCase())) {
addPlayerRank(playerName, rankName);
System.out.println("[ESP] Найден ранг: " + rankName + " у игрока " + playerName);
}
}
}
}

private void parseRankFromDisplayName(String displayName) {
String cleanName = displayName.replaceAll("§[0-9a-fk-or]", "");
cleanName = cleanName.replaceAll("^[^A-Za-zА-Яа-я]+", "");

for (Rank rank : ranks.values()) {
if (cleanName.toLowerCase().startsWith(rank.name.toLowerCase() + " ")) {
String playerName = cleanName.substring(rank.name.length() + 1).trim();
if (!playerName.isEmpty() && !playerName.contains(" ")) {
addPlayerRank(playerName, rank.name);
break;
}
}
}
}

private void addPlayerRank(String playerName, String rankName) {
Rank rank = ranks.get(rankName.toLowerCase());
if (rank != null) {
String existingRank = playerRanks.get(playerName.toLowerCase());
if (existingRank == null || !existingRank.equals(rank.name)) {
playerRanks.put(playerName.toLowerCase(), rank.name);
saveConfigToFile();
System.out.println("[ESP] Определена привилегия " + rank.name + " у игрока " + playerName);
}
}
}

private void loadRanksConfig() {
ranks.clear();
playerRanks.clear();

if (!CONFIG_FILE.exists()) {
saveDefaultConfig();
return;
}

try (Reader reader = new FileReader(CONFIG_FILE)) {
JsonObject json = JsonParser.parseReader(reader).getAsJsonObject();

JsonArray ranksArray = json.getAsJsonArray("ranks");
for (JsonElement element : ranksArray) {
JsonObject rankObj = element.getAsJsonObject();
String name = rankObj.get("name").getAsString();
String prefix = rankObj.get("prefix").getAsString();
String colorCode = rankObj.get("colorCode").getAsString();
int color = rankObj.get("color").getAsInt();
int priority = rankObj.get("priority").getAsInt();
ranks.put(name.toLowerCase(), new Rank(name, prefix, colorCode, color, priority));
}

if (json.has("players")) {
JsonObject playersObj = json.getAsJsonObject("players");
for (Map.Entry<String, JsonElement> entry : playersObj.entrySet()) {
String playerName = entry.getKey();
String rankName = entry.getValue().getAsString();
playerRanks.put(playerName.toLowerCase(), rankName);
}
}

System.out.println("[ESP] Загружено " + ranks.size() + " привилегий и " + playerRanks.size() + " игроков");
} catch (Exception e) {
e.printStackTrace();
saveDefaultConfig();
}
}

private void saveDefaultConfig() {
ranks.clear();

addDefaultRank("Герцог", "[Герцог] ", "§c", ColorUtils.rgb(180, 40, 40), 110);
addDefaultRank("Князь", "[Князь] ", "§c", ColorUtils.rgb(255, 80, 80), 105);
addDefaultRank("Принц", "[Принц] ", "§c", ColorUtils.rgb(255, 100, 100), 100);
addDefaultRank("Титан", "[Титан] ", "§6", ColorUtils.rgb(255, 200, 80), 95);
addDefaultRank("Элита", "[Элита] ", "§5", ColorUtils.rgb(170, 80, 200), 90);
addDefaultRank("Глава", "[Глава] ", "§6", ColorUtils.rgb(255, 140, 40), 85);
addDefaultRank("Сквид", "[Сквид] ", "§b", ColorUtils.rgb(80, 180, 255), 80);
addDefaultRank("Аспид", "[Аспид] ", "§3", ColorUtils.rgb(60, 150, 200), 75);
addDefaultRank("Герой", "[Герой] ", "§a", ColorUtils.rgb(80, 220, 120), 70);
addDefaultRank("Страж", "[Страж] ", "§a", ColorUtils.rgb(120, 255, 80), 65);
addDefaultRank("Барон", "[Барон] ", "§b", ColorUtils.rgb(100, 200, 255), 60);

saveConfigToFile();
}

private void addDefaultRank(String name, String prefix, String colorCode, int color, int priority) {
ranks.put(name.toLowerCase(), new Rank(name, prefix, colorCode, color, priority));
}

private void saveConfigToFile() {
try {
CONFIG_FILE.getParentFile().mkdirs();

JsonObject json = new JsonObject();

JsonArray ranksArray = new JsonArray();
for (Rank rank : ranks.values()) {
JsonObject rankObj = new JsonObject();
rankObj.addProperty("name", rank.name);
rankObj.addProperty("prefix", rank.prefix);
rankObj.addProperty("colorCode", rank.colorCode);
rankObj.addProperty("color", rank.color);
rankObj.addProperty("priority", rank.priority);
ranksArray.add(rankObj);
}
json.add("ranks", ranksArray);

JsonObject playersObj = new JsonObject();
for (Map.Entry<String, String> entry : playerRanks.entrySet()) {
playersObj.addProperty(entry.getKey(), entry.getValue());
}
json.add("players", playersObj);

try (Writer writer = new FileWriter(CONFIG_FILE)) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
writer.write(gson.toJson(json));
}

} catch (Exception e) {
e.printStackTrace();
}
}

private Rank getPlayerRank(PlayerEntity player) {
String playerName = player.getName().getString();
String cleanName = playerName.replaceAll("§[0-9a-fk-or]", "").toLowerCase();

String manualRank = playerRanks.get(cleanName);
if (manualRank != null) {
Rank rank = ranks.get(manualRank.toLowerCase());
if (rank != null) return rank;
}

String displayName = player.getDisplayName().getString();
String cleanDisplay = displayName.replaceAll("§[0-9a-fk-or]", "");
Pattern pattern = Pattern.compile("\\[([A-Za-zА-Яа-я0-9_]+)\\]");
Matcher matcher = pattern.matcher(cleanDisplay);
if (matcher.find()) {
String rankName = matcher.group(1);
Rank rank = ranks.get(rankName.toLowerCase());
if (rank != null) {
playerRanks.put(cleanName, rank.name);
return rank;
}
}

return null;
}

private String cleanPlayerName(String playerName) {
String cleaned = playerName.replaceAll("§[0-9a-fk-or]", "");
cleaned = cleaned.replaceAll("^\\[.*?\\]\\s*", "");
return cleaned.trim();
}

@Subscribe
private void onRender(EventDisplay e) {
if (mc.world == null || mc.player == null || !isState()) return;
if (e.getType() != EventDisplay.Type.PRE) return;

positions.clear();

for (Entity entity : mc.world.getAllEntities()) {
if (!isValid(entity)) continue;
if (!shouldRender(entity)) continue;

double x = interpolate(entity.getPosX(), entity.lastTickPosX, e.getPartialTicks());
double y = interpolate(entity.getPosY(), entity.lastTickPosY, e.getPartialTicks());
double z = interpolate(entity.getPosZ(), entity.lastTickPosZ, e.getPartialTicks());

Vector3d size = new Vector3d(
entity.getBoundingBox().maxX - entity.getBoundingBox().minX,
entity.getBoundingBox().maxY - entity.getBoundingBox().minY,
entity.getBoundingBox().maxZ - entity.getBoundingBox().minZ
);

net.minecraft.util.math.AxisAlignedBB aabb = new net.minecraft.util.math.AxisAlignedBB(
x - size.x / 2f, y, z - size.z / 2f,
x + size.x / 2f, y + size.y, z + size.z / 2f
);

Vector4f position = null;
for (int i = 0; i < 8; i++) {
Vector2f vector = ProjectionUtil.project(
i % 2 == 0 ? aabb.minX : aabb.maxX,
(i / 2) % 2 == 0 ? aabb.minY : aabb.maxY,
(i / 4) % 2 == 0 ? aabb.minZ : aabb.maxZ
);

if (vector == null) continue;

if (position == null) {
position = new Vector4f(vector.x, vector.y, 1, 1.0f);
} else {
position.x = Math.min(vector.x, position.x);
position.y = Math.min(vector.y, position.y);
position.z = Math.max(vector.x, position.z);
position.w = Math.max(vector.y, position.w);
}
}

if (position != null) {
positions.put(entity, position);
}
}

GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

for (HashMap.Entry<Entity, Vector4f> entry : positions.entrySet()) {
Entity entity = entry.getKey();
Vector4f position = entry.getValue();

if (entity instanceof LivingEntity) {
renderLivingESP(e.getMatrixStack(), (LivingEntity) entity, position);
} else if (entity instanceof ItemEntity) {
renderItemESP(e.getMatrixStack(), (ItemEntity) entity, position);
}
}

GlStateManager.disableBlend();
GlStateManager.popMatrix();
}

private void renderLivingESP(MatrixStack ms, LivingEntity entity, Vector4f position) {
float width = position.z - position.x;

if (width <= 0 || position.y <= 0 || position.y > mc.getMainWindow().getScaledHeight()) {
return;
}

String rawName = entity.getName().getString();
String cleanName = cleanPlayerName(rawName);

Rank rank = null;
if (entity instanceof PlayerEntity) {
rank = getPlayerRank((PlayerEntity) entity);
}

if (showArmor.get() && entity instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) entity;
float iconsY = position.y - 18;
float iconsX = position.x + width / 2f;
float iconSize = 10;
float iconSpacing = 2;

List<ResourceLocation> iconsList = new ArrayList<>();

int[] armorSlots = {0, 1, 2, 3};

for (int i = 0; i < armorSlots.length; i++) {
ItemStack armor = player.inventory.armorInventory.get(armorSlots);
if (!armor.isEmpty() && armor.getItem() instanceof ArmorItem) {
net.minecraft.util.ResourceLocation itemKey = net.minecraft.util.registry.Registry.ITEM.getKey(armor.getItem());
String itemName = itemKey.getPath();
iconsList.add(new ResourceLocation("minecraft", "textures/item/" + itemName + ".png"));
}
}

ItemStack mainHand = player.getHeldItemMainhand();
if (!mainHand.isEmpty()) {
net.minecraft.util.ResourceLocation itemKey = net.minecraft.util.registry.Registry.ITEM.getKey(mainHand.getItem());
String itemName = itemKey.getPath();
if (itemName.contains("sword")) {
iconsList.add(new ResourceLocation("minecraft", "textures/item/" + itemName + ".png"));
}
}

if (!iconsList.isEmpty()) {
float totalWidth = iconsList.size() * (iconSize + iconSpacing) - iconSpacing;
float startX = iconsX - totalWidth / 2f;
float currentX = startX;

for (ResourceLocation icon : iconsList) {
mc.getTextureManager().bindTexture(icon);
DisplayUtils.drawImage(icon, currentX, iconsY, iconSize, iconSize, -1);
currentX += iconSize + iconSpacing;
}
}
}

String coloredText;
String plainText;

if (rank != null) {
coloredText = "§7[" + rank.colorCode + "§l" + rank.name + "§7] §f§l" + cleanName;
plainText = "[" + rank.name + "] " + cleanName;
} else {
coloredText = "§7[§f§lИгрок§7] §f§l" + cleanName;
plainText = "[Игрок] " + cleanName;
}

String armorText = "";
if (showArmor.get() && entity instanceof PlayerEntity) {
armorText = getArmorIcons((PlayerEntity) entity);
}

int currentHealth = (int) entity.getHealth();
String healthText = " [" + currentHealth + "HP]";

String fullColoredText = coloredText + (armorText.isEmpty() ? "" : " §f" + armorText) + healthText;
String fullPlainText = plainText + (armorText.isEmpty() ? "" : " " + armorText) + " [" + currentHealth + "HP]";

float textWidth = Fonts.sfMedium.getWidth(fullPlainText, FONT_SIZE) + 2f;
float textHeight = 7.0f;

float centerX = position.x + width / 2f;
float textX = centerX - textWidth / 2f;
float textY = position.y - 8;

float paddingX = 0.5f;
float paddingY = 0.1f;
float rectX = textX - paddingX;
float rectY = textY - paddingY;
float rectWidth = textWidth + paddingX * 2;
float rectHeight = textHeight + paddingY * 2;

DisplayUtils.drawRect(rectX, rectY, rectX + rectWidth, rectY + rectHeight,
ColorUtils.rgba(0, 0, 0, 150));

float currentX = textX;

if (rank != null) {
Fonts.sfMedium.drawText(ms, "[", currentX, textY, ColorUtils.rgb(200, 200, 200), FONT_SIZE);
currentX += Fonts.sfMedium.getWidth("[", FONT_SIZE);

Fonts.sfMedium.drawText(ms, rank.name, currentX, textY, rank.color, FONT_SIZE + 1.5f);
currentX += Fonts.sfMedium.getWidth(rank.name, FONT_SIZE + 1.5f);

Fonts.sfMedium.drawText(ms, "] ", currentX, textY, ColorUtils.rgb(200, 200, 200), FONT_SIZE);
currentX += Fonts.sfMedium.getWidth("] ", FONT_SIZE);
} else {
Fonts.sfMedium.drawText(ms, "[Игрок] ", currentX, textY, ColorUtils.rgb(200, 200, 200), FONT_SIZE);
currentX += Fonts.sfMedium.getWidth("[Игрок] ", FONT_SIZE);
}

Fonts.sfMedium.drawText(ms, cleanName, currentX, textY, ColorUtils.rgb(255, 255, 255), FONT_SIZE);
currentX += Fonts.sfMedium.getWidth(cleanName, FONT_SIZE);

if (!armorText.isEmpty()) {
Fonts.sfMedium.drawText(ms, " " + armorText, currentX, textY, ColorUtils.rgb(255, 255, 255), FONT_SIZE);
currentX += Fonts.sfMedium.getWidth(" " + armorText, FONT_SIZE);
}

Fonts.sfMedium.drawText(ms, healthText, currentX, textY, ColorUtils.rgb(255, 80, 80), FONT_SIZE);

if (showDistance.get()) {
double dist = mc.player.getDistance(entity);
String distText = String.format("%.1fm", dist);
float distWidth = Fonts.sfMedium.getWidth(distText, 5) + 1f;
float distX = centerX - distWidth / 2f;
float distY = textY + textHeight + 1;

float distPaddingX = 0.5f;
float distPaddingY = 0.1f;
float distRectX = distX - distPaddingX;
float distRectY = distY - distPaddingY;
float distRectWidth = distWidth + distPaddingX * 2;
float distRectHeight = 6.0f + distPaddingY * 2;

DisplayUtils.drawRect(distRectX, distRectY, distRectX + distRectWidth, distRectY + distRectHeight,
ColorUtils.rgba(0, 0, 0, 150));

Fonts.sfMedium.drawText(ms, distText, distX, distY, ColorUtils.rgb(200, 200, 200), 5);
}
}

private String getArmorIcons(PlayerEntity player) {
StringBuilder icons = new StringBuilder();
int[] slots = {2, 1, 0, 3};
String[] iconsMap = {"⛑", "🛡", "👖", "👢"};

for (int i = 0; i < slots.length; i++) {
ItemStack armor = player.inventory.armorInventory.get(slots);
if (!armor.isEmpty() && armor.getItem() instanceof ArmorItem) {
icons.append(iconsMap);
}
}

return icons.toString();
}

private void renderItemESP(MatrixStack ms, ItemEntity entity, Vector4f position) {
float width = position.z - position.x;

if (width <= 0 || position.y <= 0 || position.y > mc.getMainWindow().getScaledHeight()) {
return;
}

String name = entity.getDisplayName().getString();
StringBuilder itemText = new StringBuilder();
ItemStack stack = entity.getItem();

if (!stack.isEmpty()) {
String icon = getItemIcon(stack);
itemText.append(icon).append(" ");

String shortName = name.length() > 15 ? name.substring(0, 15) + "..." : name;
itemText.append(shortName);

if (stack.getCount() > 1) {
itemText.append(" ×").append(stack.getCount());
}
}

String plainText = itemText.toString().replaceAll("§[0-9a-fk-orl]", "");
float textWidth = Fonts.sfMedium.getWidth(plainText, ITEM_FONT_SIZE);
float textHeight = 7.0f;
float centerX = position.x + width / 2f;
float textX = centerX - textWidth / 2f;
float textY = position.y - 8;

float paddingX = 0.5f;
float paddingY = 0.1f;
float rectX = textX - paddingX;
float rectY = textY - paddingY;
float rectWidth = textWidth + paddingX * 2;
float rectHeight = textHeight + paddingY * 2;

DisplayUtils.drawRect(rectX, rectY, rectX + rectWidth, rectY + rectHeight,
ColorUtils.rgba(0, 0, 0, 80));

Fonts.sfMedium.drawText(ms, itemText.toString(),
textX, textY,
ColorUtils.rgb(255, 255, 255), ITEM_FONT_SIZE);
}

private String getItemIcon(ItemStack stack) {
String name = stack.getDisplayName().getString().toLowerCase();
if (name.contains("diamond")) return "💎";
if (name.contains("emerald")) return "💚";
if (name.contains("gold") || name.contains("золото")) return "✨";
if (name.contains("iron") || name.contains("железо")) return "⚙";
if (name.contains("netherite") || name.contains("незерит")) return "🖤";
if (name.contains("sword") || name.contains("меч")) return "⚔";
if (name.contains("bow") || name.contains("лук")) return "🏹";
if (name.contains("apple") || name.contains("яблоко")) return "🍎";
if (name.contains("bread") || name.contains("хлеб")) return "🍞";
if (name.contains("poti") || name.contains("зелье")) return "🧪";
if (name.contains("dirt") || name.contains("земля")) return "🟤";
if (name.contains("stone") || name.contains("камень")) return "🪨";
if (name.contains("wood") || name.contains("дерево")) return "🪵";
return "📦";
}

public boolean isValid(Entity entity) {
if (entity == mc.player) return false;
if (entity.removed) return false;
if (mc.player.getDistance(entity) > MAX_RANGE) return false;
return true;
}

private boolean shouldRender(Entity entity) {
if (entity instanceof PlayerEntity) {
return showPlayers.get();
}
if (entity instanceof ItemEntity) {
return showItems.get();
}
if (entity instanceof net.minecraft.entity.passive.AnimalEntity) {
return showMobs.get();
}
return false;
}

private double interpolate(double current, double last, float partialTicks) {
return last + (current - last) * partialTicks;
}
}
 
Назад
Сверху Снизу