Начинающий
Начинающий
- Статус
- Оффлайн
- Регистрация
- 18 Июн 2025
- Сообщения
- 30
- Реакции
- 1
с помощью ИИ делаю мод только на blockESP на версий 1.21.4 фабрик, оно мне написало +- рабочий BlockESP только свечение блоков не видно через другие блоки, пытался также исправить но использовав 4 ИИ ни один не дал рабочий вариант
Java:
public class BlockEspRenderer {
private static final int RADIUS = 16;
private static final int VERTICAL_HALF = 24;
public static void render(WorldRenderContext ctx, MinecraftClient client, ConfigManager config) {
if (config.getSelectedBlockIds().isEmpty()) return;
Camera camera = ctx.camera();
MatrixStack matrices = ctx.matrixStack();
VertexConsumerProvider buffers = ctx.consumers();
if (camera == null || matrices == null || buffers == null || client.world == null) return;
Vec3d camPos = camera.getPos();
BlockPos playerPos = BlockPos.ofFloored(camPos);
int color = parseColor(config.getOutlineColorHex());
float a = ((color >>> 24) & 0xFF) / 255f;
float r = ((color >>> 16) & 0xFF) / 255f;
float g = ((color >>> 8) & 0xFF) / 255f;
float b = (color & 0xFF) / 255f;
float width = Math.max(1.0f, config.getOutlineWidth());
matrices.push();
matrices.translate(-camPos.x, -camPos.y, -camPos.z);
Matrix4f posMatrix = matrices.peek().getPositionMatrix();
// === НАСТРОЙКИ РЕНДЕРИНГА ===
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.disableCull(); // Отключаем отсечение задних граней
RenderSystem.depthMask(false); // Не пишем в depth buffer
RenderSystem.enableDepthTest(); // Но читаем depth buffer
RenderSystem.lineWidth(1.0f); // Сбросим, будем задавать вручную
BlockPos.Mutable mutable = new BlockPos.Mutable();
int worldBottom = client.world.getBottomY();
int worldTop = worldBottom + client.world.getHeight() - 1;
int minY = Math.max(worldBottom, playerPos.getY() - VERTICAL_HALF);
int maxY = Math.min(worldTop, playerPos.getY() + VERTICAL_HALF);
int radiusSq = RADIUS * RADIUS;
VertexConsumer vc;
// === ПРОХОД 1: СКРЫТЫЕ ЧАСТИ (за блоками) ===
RenderSystem.depthFunc(GL11.GL_LEQUAL);
RenderSystem.lineWidth(width * 0.8f);
vc = buffers.getBuffer(RenderLayer.getLines());
renderBlocksInRange(client, config, playerPos, minY, maxY, radiusSq, mutable, posMatrix, vc,
r, g, b, a * 0.35f, -0.006f);
// === ПРОХОД 2: ВИДИМЫЕ ЧАСТИ (поверх всего) ===
RenderSystem.depthFunc(GL11.GL_ALWAYS);
RenderSystem.lineWidth(width * 1.6f);
vc = buffers.getBuffer(RenderLayer.getLines());
renderBlocksInRange(client, config, playerPos, minY, maxY, radiusSq, mutable, posMatrix, vc,
r, g, b, a, -0.002f);
// === ВОССТАНОВЛЕНИЕ СОСТОЯНИЯ ===
RenderSystem.lineWidth(1.0f);
RenderSystem.depthMask(true);
RenderSystem.depthFunc(GL11.GL_LEQUAL);
RenderSystem.enableCull();
RenderSystem.disableBlend();
matrices.pop();
}
private static void renderBlocksInRange(MinecraftClient client, ConfigManager config,
BlockPos playerPos, int minY, int maxY, int radiusSq,
BlockPos.Mutable mutable, Matrix4f posMatrix, VertexConsumer vc,
float r, float g, float b, float a, float shrink) {
for (int dx = -RADIUS; dx <= RADIUS; dx++) {
for (int dy = minY - playerPos.getY(); dy <= maxY - playerPos.getY(); dy++) {
for (int dz = -RADIUS; dz <= RADIUS; dz++) {
if (dx * dx + dy * dy + dz * dz > radiusSq) continue;
mutable.set(playerPos.getX() + dx, playerPos.getY() + dy, playerPos.getZ() + dz);
if (!client.world.isChunkLoaded(mutable)) continue;
BlockState state = client.world.getBlockState(mutable);
if (state.isAir() || !config.isSelected(state.getBlock())) continue;
VoxelShape shape = state.getOutlineShape(client.world, mutable);
if (shape.isEmpty()) continue;
Box box = shape.getBoundingBox().offset(mutable);
if (!isValid(box)) box = new Box(mutable);
// Сдвигаем внутрь блока, чтобы избежать z-fighting
Box shrunkBox = box.expand(shrink);
drawBoxOutline(posMatrix, vc, shrunkBox, r, g, b, a);
}
}
}
}
private static boolean isValid(Box box) {
return !(Double.isNaN(box.minX) || Double.isNaN(box.minY) || Double.isNaN(box.minZ)
|| Double.isNaN(box.maxX) || Double.isNaN(box.maxY) || Double.isNaN(box.maxZ)
|| box.minX > box.maxX || box.minY > box.maxY || box.minZ > box.maxZ);
}
private static void drawBoxOutline(Matrix4f posMatrix, VertexConsumer vc, Box box,
float r, float g, float b, float a) {
float minX = (float) box.minX;
float minY = (float) box.minY;
float minZ = (float) box.minZ;
float maxX = (float) box.maxX;
float maxY = (float) box.maxY;
float maxZ = (float) box.maxZ;
// Нижняя грань
vc.vertex(posMatrix, minX, minY, minZ).color(r, g, b, a);
vc.vertex(posMatrix, maxX, minY, minZ).color(r, g, b, a);
vc.vertex(posMatrix, maxX, minY, minZ).color(r, g, b, a);
vc.vertex(posMatrix, maxX, minY, maxZ).color(r, g, b, a);
vc.vertex(posMatrix, maxX, minY, maxZ).color(r, g, b, a);
vc.vertex(posMatrix, minX, minY, maxZ).color(r, g, b, a);
vc.vertex(posMatrix, minX, minY, maxZ).color(r, g, b, a);
vc.vertex(posMatrix, minX, minY, minZ).color(r, g, b, a);
// Верхняя грань
vc.vertex(posMatrix, minX, maxY, minZ).color(r, g, b, a);
vc.vertex(posMatrix, maxX, maxY, minZ).color(r, g, b, a);
vc.vertex(posMatrix, maxX, maxY, minZ).color(r, g, b, a);
vc.vertex(posMatrix, maxX, maxY, maxZ).color(r, g, b, a);
vc.vertex(posMatrix, maxX, maxY, maxZ).color(r, g, b, a);
vc.vertex(posMatrix, minX, maxY, maxZ).color(r, g, b, a);
vc.vertex(posMatrix, minX, maxY, maxZ).color(r, g, b, a);
vc.vertex(posMatrix, minX, maxY, minZ).color(r, g, b, a);
// Вертикальные рёбра
vc.vertex(posMatrix, minX, minY, minZ).color(r, g, b, a);
vc.vertex(posMatrix, minX, maxY, minZ).color(r, g, b, a);
vc.vertex(posMatrix, maxX, minY, minZ).color(r, g, b, a);
vc.vertex(posMatrix, maxX, maxY, minZ).color(r, g, b, a);
vc.vertex(posMatrix, maxX, minY, maxZ).color(r, g, b, a);
vc.vertex(posMatrix, maxX, maxY, maxZ).color(r, g, b, a);
vc.vertex(posMatrix, minX, minY, maxZ).color(r, g, b, a);
vc.vertex(posMatrix, minX, maxY, maxZ).color(r, g, b, a);
}
private static int parseColor(String hex) {
if (hex == null || hex.isEmpty()) return 0xFFFFFFFF;
String h = hex.startsWith("#") ? hex.substring(1) : hex;
try {
long v = Long.parseLong(h, 16);
if (h.length() == 6) v |= 0xFF000000L;
return (int) v;
} catch (NumberFormatException e) {
return 0xFFFFFFFF;
}
}
}