package ru.nevetime.cheat.module.render; import com.mojang.blaze3d.systems.RenderSystem; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.minecraft.client.render.*; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; import org.joml.Matrix4f; import ru.nevetime.cheat.module.Module; public class ESP extends Module { public ESP() { super("ESP", Category.RENDER); } @Override public void onRender(WorldRenderContext context) { if (mc.player == null || mc.world == null) return; MatrixStack matrices = context.matrixStack(); matrices.push(); Vec3d camera = context.camera().getPos(); matrices.translate(-camera.x, -camera.y, -camera.z); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.disableDepthTest(); RenderSystem.setShader(GameRenderer::getPositionColorProgram); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); for (Entity entity : mc.world.getEntities()) { if (entity == mc.player) continue; if (!(entity instanceof PlayerEntity)) continue; if (!entity.isAlive()) continue; Box box = entity.getBoundingBox(); drawBox(matrices, buffer, box, 1.0f, 0.0f, 0.0f, 1.0f); } BufferRenderer.drawWithGlobalProgram(buffer.end()); RenderSystem.enableDepthTest(); RenderSystem.disableBlend(); matrices.pop(); } private void drawBox(MatrixStack matrices, BufferBuilder buffer, Box box, float r, float g, float b, float a) { Matrix4f matrix = matrices.peek().getPositionMatrix(); 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; buffer.vertex(matrix, minX, minY, minZ).color(r, g, b, a); buffer.vertex(matrix, maxX, minY, minZ).color(r, g, b, a); buffer.vertex(matrix, maxX, minY, minZ).color(r, g, b, a); buffer.vertex(matrix, maxX, minY, maxZ).color(r, g, b, a); buffer.vertex(matrix, maxX, minY, maxZ).color(r, g, b, a); buffer.vertex(matrix, minX, minY, maxZ).color(r, g, b, a); buffer.vertex(matrix, minX, minY, maxZ).color(r, g, b, a); buffer.vertex(matrix, minX, minY, minZ).color(r, g, b, a); buffer.vertex(matrix, minX, maxY, minZ).color(r, g, b, a); buffer.vertex(matrix, maxX, maxY, minZ).color(r, g, b, a); buffer.vertex(matrix, maxX, maxY, minZ).color(r, g, b, a); buffer.vertex(matrix, maxX, maxY, maxZ).color(r, g, b, a); buffer.vertex(matrix, maxX, maxY, maxZ).color(r, g, b, a); buffer.vertex(matrix, minX, maxY, maxZ).color(r, g, b, a); buffer.vertex(matrix, minX, maxY, maxZ).color(r, g, b, a); buffer.vertex(matrix, minX, maxY, minZ).color(r, g, b, a); buffer.vertex(matrix, minX, minY, minZ).color(r, g, b, a); buffer.vertex(matrix, minX, maxY, minZ).color(r, g, b, a); buffer.vertex(matrix, maxX, minY, minZ).color(r, g, b, a); buffer.vertex(matrix, maxX, maxY, minZ).color(r, g, b, a); buffer.vertex(matrix, maxX, minY, maxZ).color(r, g, b, a); buffer.vertex(matrix, maxX, maxY, maxZ).color(r, g, b, a); buffer.vertex(matrix, minX, minY, maxZ).color(r, g, b, a); buffer.vertex(matrix, minX, maxY, maxZ).color(r, g, b, a); } }