Начинающий
Начинающий
- Статус
- Оффлайн
- Регистрация
- 26 Фев 2026
- Сообщения
- 31
- Реакции
- 0
я делаю интернал на полуфабрикабрик 1.20.1 и чето мой есп не работает
хелп пж
esp.cpp:
#define NOMINMAX
#include "Features.h"
#include "../core/SDK.h"
#include "../ui/UI.h"
#include <imgui.h>
#include <cmath>
#include <algorithm>
static bool WorldToScreen(const SDK::Game::Vector3& pos, ImVec2& screen) {
JNIEnv* env = SDK::GetJNIEnv();
if (!env || !SDK::Game::minecraft) return false;
static jclass mcClass = SDK::FindClass(env, "net/minecraft/class_310");
static jmethodID getCameraMethod = env->GetMethodID(mcClass, "method_15690", "()Lnet/minecraft/class_4184;");
jobject camera = env->CallObjectMethod(SDK::Game::minecraft, getCameraMethod);
if (!camera)
return false;
static jclass cameraClass = SDK::FindClass(env, "net/minecraft/class_4184");
static jmethodID getCamPos = env->GetMethodID(cameraClass, "method_19428", "()Lnet/minecraft/class_243;");
jobject camVec = env->CallObjectMethod(camera, getCamPos);
static jclass vec3dClass = SDK::FindClass(env, "net/minecraft/class_243");
static jfieldID xField = env->GetFieldID(vec3dClass, "field_1352", "D");
static jfieldID yField = env->GetFieldID(vec3dClass, "field_1351", "D");
static jfieldID zField = env->GetFieldID(vec3dClass, "field_1350", "D");
double camX = camVec ? env->GetDoubleField(camVec, xField) : 0;
double camY = camVec ? env->GetDoubleField(camVec, yField) : 0;
double camZ = camVec ? env->GetDoubleField(camVec, zField) : 0;
static jmethodID getYaw = env->GetMethodID(cameraClass, "method_19426", "()F");
static jmethodID getPitch = env->GetMethodID(cameraClass, "method_19427", "()F");
float yaw = env->CallFloatMethod(camera, getYaw);
float pitch = env->CallFloatMethod(camera, getPitch);
static jmethodID getGameRenderer = env->GetMethodID(mcClass, "method_1552", "()Lnet/minecraft/class_757;");
jobject gameRenderer = env->CallObjectMethod(SDK::Game::minecraft, getGameRenderer);
static jclass grClass = SDK::FindClass(env, "net/minecraft/class_757");
static jmethodID getProjMat = env->GetMethodID(grClass, "method_19431", "()Lorg/joml/Matrix4f;");
jobject projMat = env->CallObjectMethod(gameRenderer, getProjMat);
static jclass mat4Class = SDK::FindClass(env, "org/joml/Matrix4f");
static jfieldID m00 = env->GetFieldID(mat4Class, "field_0", "F");
static jfieldID m01 = env->GetFieldID(mat4Class, "field_1", "F");
static jfieldID m02 = env->GetFieldID(mat4Class, "field_2", "F");
static jfieldID m03 = env->GetFieldID(mat4Class, "field_3", "F");
static jfieldID m10 = env->GetFieldID(mat4Class, "field_4", "F");
static jfieldID m11 = env->GetFieldID(mat4Class, "field_5", "F");
static jfieldID m12 = env->GetFieldID(mat4Class, "field_6", "F");
static jfieldID m13 = env->GetFieldID(mat4Class, "field_7", "F");
static jfieldID m20 = env->GetFieldID(mat4Class, "field_8", "F");
static jfieldID m21 = env->GetFieldID(mat4Class, "field_9", "F");
static jfieldID m22 = env->GetFieldID(mat4Class, "field_10", "F");
static jfieldID m23 = env->GetFieldID(mat4Class, "field_11", "F");
static jfieldID m30 = env->GetFieldID(mat4Class, "field_12", "F");
static jfieldID m31 = env->GetFieldID(mat4Class, "field_13", "F");
static jfieldID m32 = env->GetFieldID(mat4Class, "field_14", "F");
static jfieldID m33 = env->GetFieldID(mat4Class, "field_15", "F");
float proj[16];
proj[0] = env->GetFloatField(projMat, m00); proj[1] = env->GetFloatField(projMat, m01);
proj[2] = env->GetFloatField(projMat, m02); proj[3] = env->GetFloatField(projMat, m03);
proj[4] = env->GetFloatField(projMat, m10); proj[5] = env->GetFloatField(projMat, m11);
proj[6] = env->GetFloatField(projMat, m12); proj[7] = env->GetFloatField(projMat, m13);
proj[8] = env->GetFloatField(projMat, m20); proj[9] = env->GetFloatField(projMat, m21);
proj[10] = env->GetFloatField(projMat, m22); proj[11] = env->GetFloatField(projMat, m23);
proj[12] = env->GetFloatField(projMat, m30); proj[13] = env->GetFloatField(projMat, m31);
proj[14] = env->GetFloatField(projMat, m32); proj[15] = env->GetFloatField(projMat, m33);
float radYaw = yaw * 0.017453292f;
float radPitch = pitch * 0.017453292f;
float cosY = cosf(radYaw), sinY = sinf(radYaw);
float cosP = cosf(radPitch), sinP = sinf(radPitch);
float view[16] = {
-cosY, 0, sinY, 0,
-sinY * (-sinP), cosP, -cosY * (-sinP), 0,
sinY * cosP, sinP, cosY * cosP, 0,
-(pos.x - camX) * (-cosY) - (pos.y - camY) * (-sinY * (-sinP)) - (pos.z - camZ) * (sinY * cosP),
-(pos.x - camX) * 0 - (pos.y - camY) * (cosP) - (pos.z - camZ) * (sinP),
-(pos.x - camX) * (sinY) - (pos.y - camY) * (-cosY * (-sinP)) - (pos.z - camZ) * (cosY * cosP),
1
};
float mvp[16];
for (int c = 0; c < 4; c++) {
for (int r = 0; r < 4; r++) {
mvp[c * 4 + r] = 0;
for (int k = 0; k < 4; k++)
mvp[c * 4 + r] += proj[ k * 4 + r] * view[ c * 4 + k];
}
}
float clipW = mvp[3] + mvp[7] + mvp[11] + mvp[15];
if (clipW < 0.1f) { env->DeleteLocalRef(camera); if(camVec) env->DeleteLocalRef(camVec); return false; }
float ndcX = (mvp[0] + mvp[4] + mvp[8] + mvp[12]) / clipW;
float ndcY = (mvp[1] + mvp[5] + mvp[9] + mvp[13]) / clipW;
ImGuiIO& io = ImGui::GetIO();
screen.x = (ndcX + 1.0f) * 0.5f * io.DisplaySize.x;
screen.y = (1.0f - ndcY) * 0.5f * io.DisplaySize.y;
env->DeleteLocalRef(camera);
if (camVec)
env->DeleteLocalRef(camVec);
return true;
}
void Features::ESP(JNIEnv* env) {
if (!env || !SDK::Game::player || !SDK::Game::world) return;
SDK::Game::Update(env);
auto entities = SDK::GetWorldEntities(env);
UI::nVisibleEntities = (int)entities.size();
auto drawList = ImGui::GetForegroundDrawList();
static jclass entityClass = SDK::FindClass(env, "net/minecraft/class_1297");
static jfieldID posXField = env->GetFieldID(entityClass, "field_45169", "D");
static jfieldID posYField = env->GetFieldID(entityClass, "field_45170", "D");
static jfieldID posZField = env->GetFieldID(entityClass, "field_45171", "D");
static jmethodID isAlive = env->GetMethodID(entityClass, "method_5806", "()Z");
static jmethodID isPlayer = env->GetMethodID(entityClass, "method_5807", "()Z");
static jmethodID getName = env->GetMethodID(entityClass, "method_5477", "()Lnet/minecraft/class_2561;");
static jclass playerClass = SDK::FindClass(env, "net/minecraft/class_746");
static jfieldID pPosX = env->GetFieldID(playerClass, "field_45169", "D");
static jfieldID pPosY = env->GetFieldID(playerClass, "field_45170", "D");
static jfieldID pPosZ = env->GetFieldID(playerClass, "field_45171", "D");
double px = env->GetDoubleField(SDK::Game::player, pPosX);
double py = env->GetDoubleField(SDK::Game::player, pPosY);
double pz = env->GetDoubleField(SDK::Game::player, pPosZ);
for (auto& ent : entities) {
if (!ent || env->IsSameObject(ent, SDK::Game::player)) {
env->DeleteLocalRef(ent);
continue;
}
if (!env->CallBooleanMethod(ent, isAlive)) {
env->DeleteLocalRef(ent);
continue;
}
double ex = env->GetDoubleField(ent, posXField);
double ey = env->GetDoubleField(ent, posYField);
double ez = env->GetDoubleField(ent, posZField);
static jmethodID getHeight = env->GetMethodID(entityClass, "method_5768", "()F");
float height = env->CallFloatMethod(ent, getHeight);
float width = 0.6f;
SDK::Game::Vector3 feetPos = {
(float)ex,
(float)ey,
(float)ez
};
SDK::Game::Vector3 headPos = {
(float)ex,
(float)(ey + height),
(float)ez
};
ImVec2 screenFeet, screenHead;
if (!WorldToScreen(feetPos, screenFeet) || !WorldToScreen(headPos, screenHead)) {
env->DeleteLocalRef(ent);
continue;
}
float boxHeight = screenFeet.y - screenHead.y;
if (boxHeight < 2.0f) {
env->DeleteLocalRef(ent);
continue;
}
float boxWidth = boxHeight * (width / height);
if (boxWidth < 2.0f) boxWidth = 2.0f;
float left = screenHead.x - boxWidth * 0.5f;
float right = screenHead.x + boxWidth * 0.5f;
float top = screenHead.y;
float bottom = screenFeet.y;
float dist = sqrtf((float)((ex - px) * (ex - px) + (ey - py) * (ey - py) + (ez - pz) * (ez - pz)));
int r = (int)std::min(255.0f, dist * 2.5f);
int g = (int)std::max(0.0f, 255.0f - dist * 2.5f);
ImU32 boxColor = IM_COL32(r, g, 50, 255);
ImU32 fillColor = IM_COL32(r, g, 50, 40);
drawList->AddRectFilled(ImVec2(left, top), ImVec2(right, bottom), fillColor);
drawList->AddRect(ImVec2(left, top), ImVec2(right, bottom), boxColor);
bool isMob = env->CallBooleanMethod(ent, isPlayer);
const char* label = isMob ? "Player" : "Mob";
ImVec2 textSize = ImGui::CalcTextSize(label);
drawList->AddText(ImVec2(screenHead.x - textSize.x * 0.5f, top - textSize.y - 2), boxColor, label);
char distStr[32];
snprintf(distStr, sizeof(distStr), "%.0fm", dist);
ImVec2 distSize = ImGui::CalcTextSize(distStr);
drawList->AddText(ImVec2(screenHead.x - distSize.x * 0.5f, bottom + 2), IM_COL32(200, 200, 200, 255), distStr);
env->DeleteLocalRef(ent);
}
}
хелп пж