| 1 | package thunder.hack.utility.render;
|
| 2 |
|
| 3 | import com.mojang.blaze3d.vertex.BufferBuilder;
|
| 4 | import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
| 5 | import com.mojang.blaze3d.vertex.PoseStack;
|
| 6 | import thunder.hack.utility.render.Tesselator;
|
| 7 | import com.mojang.blaze3d.vertex.VertexConsumer;
|
| 8 | import com.mojang.blaze3d.vertex.VertexFormat;
|
| 9 | import com.mojang.math.Axis;
|
| 10 | import com.mojang.blaze3d.platform.GlStateManager;
|
| 11 | import thunder.hack.utility.render.compat.RenderSystem;
|
| 12 | import net.minecraft.client.Camera;
|
| 13 | import net.minecraft.client.Minecraft;
|
| 14 | import thunder.hack.utility.render.ShaderProgramKeys;
|
| 15 | import thunder.hack.utility.render.BufferRenderer;
|
| 16 | import net.minecraft.core.*;
|
| 17 | import net.minecraft.util.Mth;
|
| 18 | import net.minecraft.world.entity.Entity;
|
| 19 | import net.minecraft.world.phys.*;
|
| 20 | import org.jetbrains.annotations.NotNull;
|
| 21 | import org.joml.Matrix4f;
|
| 22 | import org.joml.Vector3f;
|
| 23 | import org.joml.Vector4f;
|
| 24 | import org.lwjgl.opengl.GL11;
|
| 25 | import thunder.hack.ThunderHack;
|
| 26 | import thunder.hack.core.manager.client.ModuleManager;
|
| 27 | import thunder.hack.features.modules.client.ClientSettings;
|
| 28 | import thunder.hack.features.modules.client.HudEditor;
|
| 29 | import thunder.hack.gui.font.FontRenderers;
|
| 30 |
|
| 31 | import java.awt.*;
|
| 32 | import java.util.ArrayList;
|
| 33 | import java.util.List;
|
| 34 |
|
| 35 | import static thunder.hack.features.modules.Module.mc;
|
| 36 |
|
| 37 | public class Render3DEngine {
|
| 38 | public static List<FillAction> FILLED_QUEUE = new ArrayList<>();
|
| 39 | public static List<OutlineAction> OUTLINE_QUEUE = new ArrayList<>();
|
| 40 | public static List<FadeAction> FADE_QUEUE = new ArrayList<>();
|
| 41 | public static List<FillSideAction> FILLED_SIDE_QUEUE = new ArrayList<>();
|
| 42 | public static List<OutlineSideAction> OUTLINE_SIDE_QUEUE = new ArrayList<>();
|
| 43 | public static List<DebugLineAction> DEBUG_LINE_QUEUE = new ArrayList<>();
|
| 44 | public static List<LineAction> LINE_QUEUE = new ArrayList<>();
|
| 45 |
|
| 46 | public static final Matrix4f lastProjMat = new Matrix4f();
|
| 47 | public static final Matrix4f lastModMat = new Matrix4f();
|
| 48 | public static final Matrix4f lastWorldSpaceMatrix = new Matrix4f();
|
| 49 |
|
| 50 | private static float prevCircleStep;
|
| 51 | private static float circleStep;
|
| 52 |
|
| 53 | // getTickDelta() -> mc.getRenderTickCounter().getTickProgress(true)
|
| 54 |
|
| 55 | public static void onRender3D(PoseStack stack) {
|
| 56 | if (!FILLED_QUEUE.isEmpty() || !FADE_QUEUE.isEmpty() || !FILLED_SIDE_QUEUE.isEmpty()) {
|
| 57 | Tesselator tessellator = Tesselator.getInstance();
|
| 58 | BufferBuilder bufferBuilder = tessellator.begin(com.mojang.blaze3d.PrimitiveTopology.QUADS, DefaultVertexFormat.POSITION_COLOR);
|
| 59 | RenderSystem.disableDepthTest();
|
| 60 | setupRender();
|
| 61 | RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
|
| 62 |
|
| 63 | FILLED_QUEUE.forEach(action -> setFilledBoxVertexes(bufferBuilder, stack.last().pose(), action.box(), action.color()));
|
| 64 |
|
| 65 | FADE_QUEUE.forEach(action -> setFilledFadePoints(action.box(), bufferBuilder, stack.last().pose(), action.color(), action.color2()));
|
| 66 |
|
| 67 | FILLED_SIDE_QUEUE.forEach(action -> setFilledSidePoints(bufferBuilder, stack.last().pose(), action.box, action.color(), action.side()));
|
| 68 | Render2DEngine.endBuilding(bufferBuilder);
|
| 69 |
|
| 70 | endRender();
|
| 71 | RenderSystem.enableDepthTest();
|
| 72 |
|
| 73 | FADE_QUEUE.clear();
|
| 74 | FILLED_SIDE_QUEUE.clear();
|
| 75 | FILLED_QUEUE.clear();
|
| 76 | }
|
| 77 |
|
| 78 | if (!OUTLINE_QUEUE.isEmpty() || !OUTLINE_SIDE_QUEUE.isEmpty()) {
|
| 79 | setupRender();
|
| 80 | Tesselator tessellator = Tesselator.getInstance();
|
| 81 | BufferBuilder buffer = tessellator.begin(com.mojang.blaze3d.PrimitiveTopology.LINES, DefaultVertexFormat.POSITION_COLOR);
|
| 82 | RenderSystem.disableCull();
|
| 83 | RenderSystem.disableDepthTest();
|
| 84 | RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES);
|
| 85 |
|
| 86 | RenderSystem.lineWidth(2f);
|
| 87 |
|
| 88 | OUTLINE_QUEUE.forEach(action -> {
|
| 89 | setOutlinePoints(action.box(), matrixFrom(action.box().minX, action.box().minY, action.box().minZ), buffer, action.color());
|
| 90 | });
|
| 91 |
|
| 92 | OUTLINE_SIDE_QUEUE.forEach(action -> {
|
| 93 | setSideOutlinePoints(action.box, matrixFrom(action.box().minX, action.box().minY, action.box().minZ), buffer, action.color(), action.side());
|
| 94 | });
|
| 95 |
|
| 96 | Render2DEngine.endBuilding(buffer);
|
| 97 |
|
| 98 | RenderSystem.enableCull();
|
| 99 | RenderSystem.enableDepthTest();
|
| 100 | endRender();
|
| 101 | OUTLINE_QUEUE.clear();
|
| 102 | OUTLINE_SIDE_QUEUE.clear();
|
| 103 | }
|
| 104 |
|
| 105 | if (!DEBUG_LINE_QUEUE.isEmpty()) {
|
| 106 | setupRender();
|
| 107 | RenderSystem.disableDepthTest();
|
| 108 | Tesselator tessellator = Tesselator.getInstance();
|
| 109 | BufferBuilder buffer = tessellator.begin(com.mojang.blaze3d.PrimitiveTopology.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
|
| 110 |
|
| 111 | RenderSystem.disableCull();
|
| 112 | RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES);
|
| 113 | DEBUG_LINE_QUEUE.forEach(action -> {
|
| 114 | PoseStack matrices = matrixFrom(action.start.x(), action.start.y(), action.start.z());
|
| 115 | vertexLine(matrices, buffer, 0f, 0f, 0f, (float) (action.end.x() - action.start.x()), (float) (action.end.y() - action.start.y()), (float) (action.end.z() - action.start.z()), action.color);
|
| 116 | });
|
| 117 | Render2DEngine.endBuilding(buffer);
|
| 118 | RenderSystem.enableCull();
|
| 119 | RenderSystem.enableDepthTest();
|
| 120 | endRender();
|
| 121 | DEBUG_LINE_QUEUE.clear();
|
| 122 | }
|
| 123 |
|
| 124 | if (!LINE_QUEUE.isEmpty()) {
|
| 125 | setupRender();
|
| 126 | Tesselator tessellator = Tesselator.getInstance();
|
| 127 | RenderSystem.disableCull();
|
| 128 | RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES);
|
| 129 | RenderSystem.lineWidth(2f);
|
| 130 | RenderSystem.disableDepthTest();
|
| 131 | BufferBuilder buffer = tessellator.begin(com.mojang.blaze3d.PrimitiveTopology.LINES, DefaultVertexFormat.POSITION_COLOR);
|
| 132 | LINE_QUEUE.forEach(action -> {
|
| 133 | PoseStack matrices = matrixFrom(action.start.x(), action.start.y(), action.start.z());
|
| 134 | vertexLine(matrices, buffer, 0f, 0f, 0f, (float) (action.end.x() - action.start.x()), (float) (action.end.y() - action.start.y()), (float) (action.end.z() - action.start.z()), action.color);
|
| 135 | });
|
| 136 | Render2DEngine.endBuilding(buffer);
|
| 137 | RenderSystem.enableCull();
|
| 138 | RenderSystem.lineWidth(1f);
|
| 139 | RenderSystem.enableDepthTest();
|
| 140 | endRender();
|
| 141 | LINE_QUEUE.clear();
|
| 142 | }
|
| 143 | }
|
| 144 |
|
| 145 | @Deprecated
|
| 146 | @SuppressWarnings("unused")
|
| 147 | public static void drawFilledBox(PoseStack stack, AABB box, Color c) {
|
| 148 | FILLED_QUEUE.add(new FillAction(box, c));
|
| 149 | }
|
| 150 |
|
| 151 | public static void setFilledBoxVertexes(@NotNull BufferBuilder bufferBuilder, Matrix4f m, @NotNull AABB box, @NotNull Color c) {
|
| 152 | float minX = (float) (box.minX - mc.getEntityRenderDispatcher().camera.position().x);
|
| 153 | float minY = (float) (box.minY - mc.getEntityRenderDispatcher().camera.position().y);
|
| 154 | float minZ = (float) (box.minZ - mc.getEntityRenderDispatcher().camera.position().z);
|
| 155 | float maxX = (float) (box.maxX - mc.getEntityRenderDispatcher().camera.position().x);
|
| 156 | float maxY = (float) (box.maxY - mc.getEntityRenderDispatcher().camera.position().y);
|
| 157 | float maxZ = (float) (box.maxZ - mc.getEntityRenderDispatcher().camera.position().z);
|
| 158 |
|
| 159 | bufferBuilder.addVertex(m, minX, minY, minZ).setColor(c.getRGB());
|
| 160 | bufferBuilder.addVertex(m, maxX, minY, minZ).setColor(c.getRGB());
|
| 161 | bufferBuilder.addVertex(m, maxX, minY, maxZ).setColor(c.getRGB());
|
| 162 | bufferBuilder.addVertex(m, minX, minY, maxZ).setColor(c.getRGB());
|
| 163 |
|
| 164 | bufferBuilder.addVertex(m, minX, minY, minZ).setColor(c.getRGB());
|
| 165 | bufferBuilder.addVertex(m, minX, maxY, minZ).setColor(c.getRGB());
|
| 166 | bufferBuilder.addVertex(m, maxX, maxY, minZ).setColor(c.getRGB());
|
| 167 | bufferBuilder.addVertex(m, maxX, minY, minZ).setColor(c.getRGB());
|
| 168 |
|
| 169 | bufferBuilder.addVertex(m, maxX, minY, minZ).setColor(c.getRGB());
|
| 170 | bufferBuilder.addVertex(m, maxX, maxY, minZ).setColor(c.getRGB());
|
| 171 | bufferBuilder.addVertex(m, maxX, maxY, maxZ).setColor(c.getRGB());
|
| 172 | bufferBuilder.addVertex(m, maxX, minY, maxZ).setColor(c.getRGB());
|
| 173 |
|
| 174 | bufferBuilder.addVertex(m, minX, minY, maxZ).setColor(c.getRGB());
|
| 175 | bufferBuilder.addVertex(m, maxX, minY, maxZ).setColor(c.getRGB());
|
| 176 | bufferBuilder.addVertex(m, maxX, maxY, maxZ).setColor(c.getRGB());
|
| 177 | bufferBuilder.addVertex(m, minX, maxY, maxZ).setColor(c.getRGB());
|
| 178 |
|
| 179 | bufferBuilder.addVertex(m, minX, minY, minZ).setColor(c.getRGB());
|
| 180 | bufferBuilder.addVertex(m, minX, minY, maxZ).setColor(c.getRGB());
|
| 181 | bufferBuilder.addVertex(m, minX, maxY, maxZ).setColor(c.getRGB());
|
| 182 | bufferBuilder.addVertex(m, minX, maxY, minZ).setColor(c.getRGB());
|
| 183 |
|
| 184 | bufferBuilder.addVertex(m, minX, maxY, minZ).setColor(c.getRGB());
|
| 185 | bufferBuilder.addVertex(m, minX, maxY, maxZ).setColor(c.getRGB());
|
| 186 | bufferBuilder.addVertex(m, maxX, maxY, maxZ).setColor(c.getRGB());
|
| 187 | bufferBuilder.addVertex(m, maxX, maxY, minZ).setColor(c.getRGB());
|
| 188 | }
|
| 189 |
|
| 190 | public static @NotNull AABB interpolateBox(@NotNull AABB from, @NotNull AABB to, float delta) {
|
| 191 | double X = Render2DEngine.interpolate(from.maxX, to.maxX, delta);
|
| 192 | double Y = Render2DEngine.interpolate(from.maxY, to.maxY, delta);
|
| 193 | double Z = Render2DEngine.interpolate(from.maxZ, to.maxZ, delta);
|
| 194 | double X1 = Render2DEngine.interpolate(from.minX, to.minX, delta);
|
| 195 | double Y1 = Render2DEngine.interpolate(from.minY, to.minY, delta);
|
| 196 | double Z1 = Render2DEngine.interpolate(from.minZ, to.minZ, delta);
|
| 197 | return new AABB(X1, Y1, Z1, X, Y, Z);
|
| 198 | }
|
| 199 |
|
| 200 | @Deprecated
|
| 201 | public static void drawFilledSide(PoseStack stack, @NotNull AABB box, Color c, Direction dir) {
|
| 202 | FILLED_SIDE_QUEUE.add(new FillSideAction(box, c, dir));
|
| 203 | }
|
| 204 |
|
| 205 | public static void setFilledSidePoints(BufferBuilder buffer, Matrix4f matrix, AABB box, Color c, Direction dir) {
|
| 206 | float minX = (float) (box.minX - mc.getEntityRenderDispatcher().camera.position().x);
|
| 207 | float minY = (float) (box.minY - mc.getEntityRenderDispatcher().camera.position().y);
|
| 208 | float minZ = (float) (box.minZ - mc.getEntityRenderDispatcher().camera.position().z);
|
| 209 | float maxX = (float) (box.maxX - mc.getEntityRenderDispatcher().camera.position().x);
|
| 210 | float maxY = (float) (box.maxY - mc.getEntityRenderDispatcher().camera.position().y);
|
| 211 | float maxZ = (float) (box.maxZ - mc.getEntityRenderDispatcher().camera.position().z);
|
| 212 |
|
| 213 | if (dir == Direction.DOWN) {
|
| 214 | buffer.addVertex(matrix, minX, minY, minZ).setColor(c.getRGB());
|
| 215 | buffer.addVertex(matrix, maxX, minY, minZ).setColor(c.getRGB());
|
| 216 | buffer.addVertex(matrix, maxX, minY, maxZ).setColor(c.getRGB());
|
| 217 | buffer.addVertex(matrix, minX, minY, maxZ).setColor(c.getRGB());
|
| 218 | }
|
| 219 |
|
| 220 | if (dir == Direction.NORTH) {
|
| 221 | buffer.addVertex(matrix, minX, minY, minZ).setColor(c.getRGB());
|
| 222 | buffer.addVertex(matrix, minX, maxY, minZ).setColor(c.getRGB());
|
| 223 | buffer.addVertex(matrix, maxX, maxY, minZ).setColor(c.getRGB());
|
| 224 | buffer.addVertex(matrix, maxX, minY, minZ).setColor(c.getRGB());
|
| 225 | }
|
| 226 |
|
| 227 | if (dir == Direction.EAST) {
|
| 228 | buffer.addVertex(matrix, maxX, minY, minZ).setColor(c.getRGB());
|
| 229 | buffer.addVertex(matrix, maxX, maxY, minZ).setColor(c.getRGB());
|
| 230 | buffer.addVertex(matrix, maxX, maxY, maxZ).setColor(c.getRGB());
|
| 231 | buffer.addVertex(matrix, maxX, minY, maxZ).setColor(c.getRGB());
|
| 232 | }
|
| 233 | if (dir == Direction.SOUTH) {
|
| 234 | buffer.addVertex(matrix, minX, minY, maxZ).setColor(c.getRGB());
|
| 235 | buffer.addVertex(matrix, maxX, minY, maxZ).setColor(c.getRGB());
|
| 236 | buffer.addVertex(matrix, maxX, maxY, maxZ).setColor(c.getRGB());
|
| 237 | buffer.addVertex(matrix, minX, maxY, maxZ).setColor(c.getRGB());
|
| 238 | }
|
| 239 |
|
| 240 | if (dir == Direction.WEST) {
|
| 241 | buffer.addVertex(matrix, minX, minY, minZ).setColor(c.getRGB());
|
| 242 | buffer.addVertex(matrix, minX, minY, maxZ).setColor(c.getRGB());
|
| 243 | buffer.addVertex(matrix, minX, maxY, maxZ).setColor(c.getRGB());
|
| 244 | buffer.addVertex(matrix, minX, maxY, minZ).setColor(c.getRGB());
|
| 245 | }
|
| 246 |
|
| 247 | if (dir == Direction.UP) {
|
| 248 | buffer.addVertex(matrix, minX, maxY, minZ).setColor(c.getRGB());
|
| 249 | buffer.addVertex(matrix, minX, maxY, maxZ).setColor(c.getRGB());
|
| 250 | buffer.addVertex(matrix, maxX, maxY, maxZ).setColor(c.getRGB());
|
| 251 | buffer.addVertex(matrix, maxX, maxY, minZ).setColor(c.getRGB());
|
| 252 | }
|
| 253 | }
|
| 254 |
|
| 255 | public static void drawTextIn3D(String text, @NotNull Vec3 pos, double offX, double offY, double textOffset, @NotNull Color color) {
|
| 256 | PoseStack matrices = new PoseStack();
|
| 257 | Camera camera = mc.gameRenderer.mainCamera();
|
| 258 | RenderSystem.disableDepthTest();
|
| 259 | RenderSystem.disableCull();
|
| 260 | matrices.mulPose(Axis.XP.rotationDegrees(camera.xRot()));
|
| 261 | matrices.mulPose(Axis.YP.rotationDegrees(camera.yRot() + 180.0F));
|
| 262 | matrices.translate(pos.x() - camera.position().x, pos.y() - camera.position().y, pos.z() - camera.position().z);
|
| 263 | matrices.mulPose(Axis.YP.rotationDegrees(-camera.yRot()));
|
| 264 | matrices.mulPose(Axis.XP.rotationDegrees(camera.xRot()));
|
| 265 | setupRender();
|
| 266 | matrices.translate(offX, offY - 0.1, -0.01);
|
| 267 | matrices.scale(-0.025f, -0.025f, 0);
|
| 268 | FontRenderers.sf_medium.drawCenteredString(matrices, text, textOffset, 0f, color.getRGB());
|
| 269 | RenderSystem.enableCull();
|
| 270 | RenderSystem.enableDepthTest();
|
| 271 | endRender();
|
| 272 | }
|
| 273 |
|
| 274 | public static @NotNull Vec3 worldSpaceToScreenSpace(@NotNull Vec3 pos) {
|
| 275 | Camera camera = mc.getEntityRenderDispatcher().camera;
|
| 276 | int displayHeight = mc.getWindow().getScreenHeight();
|
| 277 | int[] viewport = new int[4];
|
| 278 | GL11.glGetIntegerv(GL11.GL_VIEWPORT, viewport);
|
| 279 | Vector3f target = new Vector3f();
|
| 280 |
|
| 281 | double deltaX = pos.x - camera.position().x;
|
| 282 | double deltaY = pos.y - camera.position().y;
|
| 283 | double deltaZ = pos.z - camera.position().z;
|
| 284 |
|
| 285 | Vector4f transformedCoordinates = new Vector4f((float) deltaX, (float) deltaY, (float) deltaZ, 1.f).mul(lastWorldSpaceMatrix);
|
| 286 | Matrix4f matrixProj = new Matrix4f(lastProjMat);
|
| 287 | Matrix4f matrixModel = new Matrix4f(lastModMat);
|
| 288 | matrixProj.mul(matrixModel).project(transformedCoordinates.x(), transformedCoordinates.y(), transformedCoordinates.z(), viewport, target);
|
| 289 |
|
| 290 | return new Vec3(target.x / getScaleFactor(), (displayHeight - target.y) / getScaleFactor(), target.z);
|
| 291 | }
|
| 292 |
|
| 293 | public static double getScaleFactor() {
|
| 294 | return ClientSettings.scaleFactorFix.getValue() ? ClientSettings.scaleFactorFixValue.getValue() : mc.getWindow().getGuiScale();
|
| 295 | }
|
| 296 |
|
| 297 | @Deprecated
|
| 298 | @SuppressWarnings("unused")
|
| 299 | public static void drawFilledFadeBox(@NotNull PoseStack stack, @NotNull AABB box, @NotNull Color c, @NotNull Color c1) {
|
| 300 | FADE_QUEUE.add(new FadeAction(box, c, c1));
|
| 301 | }
|
| 302 |
|
| 303 | public static void setFilledFadePoints(AABB box, BufferBuilder buffer, Matrix4f posMatrix, Color c, Color c1) {
|
| 304 | float minX = (float) (box.minX - mc.getEntityRenderDispatcher().camera.position().x);
|
| 305 | float minY = (float) (box.minY - mc.getEntityRenderDispatcher().camera.position().y);
|
| 306 | float minZ = (float) (box.minZ - mc.getEntityRenderDispatcher().camera.position().z);
|
| 307 | float maxX = (float) (box.maxX - mc.getEntityRenderDispatcher().camera.position().x);
|
| 308 | float maxY = (float) (box.maxY - mc.getEntityRenderDispatcher().camera.position().y);
|
| 309 | float maxZ = (float) (box.maxZ - mc.getEntityRenderDispatcher().camera.position().z);
|
| 310 |
|
| 311 | if (ModuleManager.holeESP.culling.getValue())
|
| 312 | RenderSystem.enableCull();
|
| 313 |
|
| 314 | buffer.addVertex(posMatrix, minX, minY, minZ).setColor(c.getRGB());
|
| 315 | buffer.addVertex(posMatrix, minX, maxY, minZ).setColor(c1.getRGB());
|
| 316 | buffer.addVertex(posMatrix, maxX, maxY, minZ).setColor(c1.getRGB());
|
| 317 | buffer.addVertex(posMatrix, maxX, minY, minZ).setColor(c.getRGB());
|
| 318 |
|
| 319 | buffer.addVertex(posMatrix, maxX, minY, minZ).setColor(c.getRGB());
|
| 320 | buffer.addVertex(posMatrix, maxX, maxY, minZ).setColor(c1.getRGB());
|
| 321 | buffer.addVertex(posMatrix, maxX, maxY, maxZ).setColor(c1.getRGB());
|
| 322 | buffer.addVertex(posMatrix, maxX, minY, maxZ).setColor(c.getRGB());
|
| 323 |
|
| 324 | buffer.addVertex(posMatrix, minX, minY, maxZ).setColor(c.getRGB());
|
| 325 | buffer.addVertex(posMatrix, maxX, minY, maxZ).setColor(c.getRGB());
|
| 326 | buffer.addVertex(posMatrix, maxX, maxY, maxZ).setColor(c1.getRGB());
|
| 327 | buffer.addVertex(posMatrix, minX, maxY, maxZ).setColor(c1.getRGB());
|
| 328 |
|
| 329 | buffer.addVertex(posMatrix, minX, minY, minZ).setColor(c.getRGB());
|
| 330 | buffer.addVertex(posMatrix, minX, minY, maxZ).setColor(c.getRGB());
|
| 331 | buffer.addVertex(posMatrix, minX, maxY, maxZ).setColor(c1.getRGB());
|
| 332 | buffer.addVertex(posMatrix, minX, maxY, minZ).setColor(c1.getRGB());
|
| 333 |
|
| 334 | buffer.addVertex(posMatrix, minX, maxY, minZ).setColor(c1.getRGB());
|
| 335 | buffer.addVertex(posMatrix, minX, maxY, maxZ).setColor(c1.getRGB());
|
| 336 | buffer.addVertex(posMatrix, maxX, maxY, maxZ).setColor(c1.getRGB());
|
| 337 | buffer.addVertex(posMatrix, maxX, maxY, minZ).setColor(c1.getRGB());
|
| 338 |
|
| 339 | if (ModuleManager.holeESP.culling.getValue())
|
| 340 | RenderSystem.disableCull();
|
| 341 | }
|
| 342 |
|
| 343 | public static void drawLine(@NotNull Vec3 start, @NotNull Vec3 end, @NotNull Color color) {
|
| 344 | LINE_QUEUE.add(new LineAction(start, end, color));
|
| 345 | }
|
| 346 |
|
| 347 | @Deprecated
|
| 348 | public static void drawBoxOutline(@NotNull AABB box, Color color, float lineWidth) {
|
| 349 | OUTLINE_QUEUE.add(new OutlineAction(box, color, lineWidth));
|
| 350 | }
|
| 351 |
|
| 352 | public static void setOutlinePoints(AABB box, PoseStack matrices, BufferBuilder buffer, Color color) {
|
| 353 | box = box.move(new Vec3(box.minX, box.minY, box.minZ).reverse());
|
| 354 |
|
| 355 | float x1 = (float) box.minX;
|
| 356 | float y1 = (float) box.minY;
|
| 357 | float z1 = (float) box.minZ;
|
| 358 | float x2 = (float) box.maxX;
|
| 359 | float y2 = (float) box.maxY;
|
| 360 | float z2 = (float) box.maxZ;
|
| 361 |
|
| 362 | vertexLine(matrices, buffer, x1, y1, z1, x2, y1, z1, color);
|
| 363 | vertexLine(matrices, buffer, x2, y1, z1, x2, y1, z2, color);
|
| 364 | vertexLine(matrices, buffer, x2, y1, z2, x1, y1, z2, color);
|
| 365 | vertexLine(matrices, buffer, x1, y1, z2, x1, y1, z1, color);
|
| 366 | vertexLine(matrices, buffer, x1, y1, z2, x1, y2, z2, color);
|
| 367 | vertexLine(matrices, buffer, x1, y1, z1, x1, y2, z1, color);
|
| 368 | vertexLine(matrices, buffer, x2, y1, z2, x2, y2, z2, color);
|
| 369 | vertexLine(matrices, buffer, x2, y1, z1, x2, y2, z1, color);
|
| 370 | vertexLine(matrices, buffer, x1, y2, z1, x2, y2, z1, color);
|
| 371 | vertexLine(matrices, buffer, x2, y2, z1, x2, y2, z2, color);
|
| 372 | vertexLine(matrices, buffer, x2, y2, z2, x1, y2, z2, color);
|
| 373 | vertexLine(matrices, buffer, x1, y2, z2, x1, y2, z1, color);
|
| 374 | }
|
| 375 |
|
| 376 | @Deprecated
|
| 377 | public static void drawSideOutline(@NotNull AABB box, Color color, float lineWidth, Direction dir) {
|
| 378 | OUTLINE_SIDE_QUEUE.add(new OutlineSideAction(box, color, lineWidth, dir));
|
| 379 | }
|
| 380 |
|
| 381 | public static void setSideOutlinePoints(AABB box, PoseStack matrices, BufferBuilder buffer, Color color, Direction dir) {
|
| 382 | box = box.move(new Vec3(box.minX, box.minY, box.minZ).reverse());
|
| 383 |
|
| 384 | float x1 = (float) box.minX;
|
| 385 | float y1 = (float) box.minY;
|
| 386 | float z1 = (float) box.minZ;
|
| 387 | float x2 = (float) box.maxX;
|
| 388 | float y2 = (float) box.maxY;
|
| 389 | float z2 = (float) box.maxZ;
|
| 390 |
|
| 391 | switch (dir) {
|
| 392 | case UP -> {
|
| 393 | vertexLine(matrices, buffer, x1, y2, z1, x2, y2, z1, color);
|
| 394 | vertexLine(matrices, buffer, x2, y2, z1, x2, y2, z2, color);
|
| 395 | vertexLine(matrices, buffer, x2, y2, z2, x1, y2, z2, color);
|
| 396 | vertexLine(matrices, buffer, x1, y2, z2, x1, y2, z1, color);
|
| 397 | }
|
| 398 | case DOWN -> {
|
| 399 | vertexLine(matrices, buffer, x1, y1, z1, x2, y1, z1, color);
|
| 400 | vertexLine(matrices, buffer, x2, y1, z1, x2, y1, z2, color);
|
| 401 | vertexLine(matrices, buffer, x2, y1, z2, x1, y1, z2, color);
|
| 402 | vertexLine(matrices, buffer, x1, y1, z2, x1, y1, z1, color);
|
| 403 | }
|
| 404 | case EAST -> {
|
| 405 | vertexLine(matrices, buffer, x2, y1, z1, x2, y2, z1, color);
|
| 406 | vertexLine(matrices, buffer, x2, y1, z2, x2, y2, z2, color);
|
| 407 | vertexLine(matrices, buffer, x2, y2, z2, x2, y2, z1, color);
|
| 408 | vertexLine(matrices, buffer, x2, y1, z2, x2, y1, z1, color);
|
| 409 | }
|
| 410 | case WEST -> {
|
| 411 | vertexLine(matrices, buffer, x1, y1, z1, x1, y2, z1, color);
|
| 412 | vertexLine(matrices, buffer, x1, y1, z2, x1, y2, z2, color);
|
| 413 | vertexLine(matrices, buffer, x1, y2, z2, x1, y2, z1, color);
|
| 414 | vertexLine(matrices, buffer, x1, y1, z2, x1, y1, z1, color);
|
| 415 | }
|
| 416 | case NORTH -> {
|
| 417 | vertexLine(matrices, buffer, x2, y1, z1, x2, y2, z1, color);
|
| 418 | vertexLine(matrices, buffer, x1, y1, z1, x1, y2, z1, color);
|
| 419 | vertexLine(matrices, buffer, x2, y1, z1, x1, y1, z1, color);
|
| 420 | vertexLine(matrices, buffer, x2, y2, z1, x1, y2, z1, color);
|
| 421 | }
|
| 422 | case SOUTH -> {
|
| 423 | vertexLine(matrices, buffer, x1, y1, z2, x1, y2, z2, color);
|
| 424 | vertexLine(matrices, buffer, x2, y1, z2, x2, y2, z2, color);
|
| 425 | vertexLine(matrices, buffer, x1, y1, z2, x2, y1, z2, color);
|
| 426 | vertexLine(matrices, buffer, x1, y2, z2, x2, y2, z2, color);
|
| 427 | }
|
| 428 | }
|
| 429 | }
|
| 430 |
|
| 431 | public static void drawHoleOutline(@NotNull AABB box, Color color, float lineWidth) {
|
| 432 | setupRender();
|
| 433 | PoseStack matrices = matrixFrom(box.minX, box.minY, box.minZ);
|
| 434 | Tesselator tessellator = Tesselator.getInstance();
|
| 435 | BufferBuilder buffer = tessellator.begin(com.mojang.blaze3d.PrimitiveTopology.LINES, DefaultVertexFormat.POSITION_COLOR);
|
| 436 |
|
| 437 | RenderSystem.disableCull();
|
| 438 | RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES);
|
| 439 | RenderSystem.lineWidth(lineWidth);
|
| 440 |
|
| 441 | box = box.move(new Vec3(box.minX, box.minY, box.minZ).reverse());
|
| 442 |
|
| 443 | float x1 = (float) box.minX;
|
| 444 | float y1 = (float) box.minY;
|
| 445 | float y2 = (float) box.maxY;
|
| 446 | float z1 = (float) box.minZ;
|
| 447 | float x2 = (float) box.maxX;
|
| 448 | float z2 = (float) box.maxZ;
|
| 449 |
|
| 450 | vertexLine(matrices, buffer, x1, y1, z1, x2, y1, z1, color);
|
| 451 | vertexLine(matrices, buffer, x2, y1, z1, x2, y1, z2, color);
|
| 452 | vertexLine(matrices, buffer, x2, y1, z2, x1, y1, z2, color);
|
| 453 | vertexLine(matrices, buffer, x1, y1, z2, x1, y1, z1, color);
|
| 454 |
|
| 455 | vertexLine(matrices, buffer, x1, y1, z1, x1, y2, z1, color);
|
| 456 | vertexLine(matrices, buffer, x2, y1, z2, x2, y2, z2, color);
|
| 457 | vertexLine(matrices, buffer, x1, y1, z2, x1, y2, z2, color);
|
| 458 | vertexLine(matrices, buffer, x2, y1, z1, x2, y2, z1, color);
|
| 459 |
|
| 460 | Render2DEngine.endBuilding(buffer);
|
| 461 | RenderSystem.enableCull();
|
| 462 | endRender();
|
| 463 | }
|
| 464 |
|
| 465 | public static void vertexLine(@NotNull PoseStack matrices, @NotNull VertexConsumer buffer, float x1, float y1, float z1, float x2, float y2, float z2, @NotNull Color lineColor) {
|
| 466 | Matrix4f model = matrices.last().pose();
|
| 467 | PoseStack.Pose entry = matrices.last();
|
| 468 | Vector3f normalVec = getNormal(x1, y1, z1, x2, y2, z2);
|
| 469 | buffer.addVertex(model, x1, y1, z1).setColor(lineColor.getRed(), lineColor.getGreen(), lineColor.getBlue(), lineColor.getAlpha()).setNormal(entry, normalVec.x(), normalVec.y(), normalVec.z());
|
| 470 | buffer.addVertex(model, x2, y2, z2).setColor(lineColor.getRed(), lineColor.getGreen(), lineColor.getBlue(), lineColor.getAlpha()).setNormal(entry, normalVec.x(), normalVec.y(), normalVec.z());
|
| 471 | }
|
| 472 |
|
| 473 | public static @NotNull Vector3f getNormal(float x1, float y1, float z1, float x2, float y2, float z2) {
|
| 474 | float xNormal = x2 - x1;
|
| 475 | float yNormal = y2 - y1;
|
| 476 | float zNormal = z2 - z1;
|
| 477 | float normalSqrt = Mth.sqrt(xNormal * xNormal + yNormal * yNormal + zNormal * zNormal);
|
| 478 |
|
| 479 | return new Vector3f(xNormal / normalSqrt, yNormal / normalSqrt, zNormal / normalSqrt);
|
| 480 | }
|
| 481 |
|
| 482 | public static @NotNull PoseStack matrixFrom(double x, double y, double z) {
|
| 483 | PoseStack matrices = new PoseStack();
|
| 484 |
|
| 485 | Camera camera = Minecraft.getInstance().gameRenderer.mainCamera();
|
| 486 | matrices.mulPose(Axis.XP.rotationDegrees(camera.xRot()));
|
| 487 | matrices.mulPose(Axis.YP.rotationDegrees(camera.yRot() + 180.0F));
|
| 488 |
|
| 489 | matrices.translate(x - camera.position().x, y - camera.position().y, z - camera.position().z);
|
| 490 |
|
| 491 | return matrices;
|
| 492 | }
|
| 493 |
|
| 494 | public static void setupRender() {
|
| 495 | RenderSystem.enableBlend();
|
| 496 | RenderSystem.defaultBlendFunc();
|
| 497 | }
|
| 498 |
|
| 499 | public static void endRender() {
|
| 500 | RenderSystem.disableBlend();
|
| 501 | }
|
| 502 |
|
| 503 | public static void drawTargetEsp(PoseStack stack, @NotNull Entity target) {
|
| 504 | ArrayList<Vec3> vecs = new ArrayList<>();
|
| 505 | ArrayList<Vec3> vecs1 = new ArrayList<>();
|
| 506 | ArrayList<Vec3> vecs2 = new ArrayList<>();
|
| 507 |
|
| 508 | double x = target.xo + (target.getX() - target.xo) * getTickDelta()
|
| 509 | - mc.getEntityRenderDispatcher().camera.position().x;
|
| 510 | double y = target.yo + (target.getY() - target.yo) * getTickDelta()
|
| 511 | - mc.getEntityRenderDispatcher().camera.position().y;
|
| 512 | double z = target.zo + (target.getZ() - target.zo) * getTickDelta()
|
| 513 | - mc.getEntityRenderDispatcher().camera.position().z;
|
| 514 |
|
| 515 |
|
| 516 | double height = target.getBbHeight();
|
| 517 |
|
| 518 | for (int i = 0; i <= 361; ++i) {
|
| 519 | double v = Math.sin(Math.toRadians(i));
|
| 520 | double u = Math.cos(Math.toRadians(i));
|
| 521 | Vec3 vec = new Vec3((float) (u * 0.5f), height, (float) (v * 0.5f));
|
| 522 | vecs.add(vec);
|
| 523 |
|
| 524 | double v1 = Math.sin(Math.toRadians((i + 120) % 360));
|
| 525 | double u1 = Math.cos(Math.toRadians(i + 120) % 360);
|
| 526 | Vec3 vec1 = new Vec3((float) (u1 * 0.5f), height, (float) (v1 * 0.5f));
|
| 527 | vecs1.add(vec1);
|
| 528 |
|
| 529 | double v2 = Math.sin(Math.toRadians((i + 240) % 360));
|
| 530 | double u2 = Math.cos(Math.toRadians((i + 240) % 360));
|
| 531 | Vec3 vec2 = new Vec3((float) (u2 * 0.5f), height, (float) (v2 * 0.5f));
|
| 532 | vecs2.add(vec2);
|
| 533 | height -= 0.004f;
|
| 534 | }
|
| 535 |
|
| 536 |
|
| 537 | stack.pushPose();
|
| 538 | stack.translate(x, y, z);
|
| 539 | BufferBuilder bufferBuilder;
|
| 540 | setupRender();
|
| 541 | RenderSystem.disableCull();
|
| 542 | RenderSystem.disableDepthTest();
|
| 543 |
|
| 544 | RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
|
| 545 | bufferBuilder = Tesselator.getInstance().begin(com.mojang.blaze3d.PrimitiveTopology.TRIANGLE_STRIP, DefaultVertexFormat.POSITION_COLOR);
|
| 546 |
|
| 547 | Matrix4f matrix = stack.last().pose();
|
| 548 |
|
| 549 | for (int j = 0; j < vecs.size() - 1; ++j) {
|
| 550 | float alpha = 1f - (((float) j + ((System.currentTimeMillis() - ThunderHack.initTime) / 5f)) % 360) / 60f;
|
| 551 | bufferBuilder.addVertex(matrix, (float) vecs.get(j).x, (float) vecs.get(j).y, (float) vecs.get(j).z).setColor(Render2DEngine.injectAlpha(HudEditor.getColor((int) (j / 20f)), (int) (alpha * 255)).getRGB());
|
| 552 | bufferBuilder.addVertex(matrix, (float) vecs.get(j + 1).x, (float) vecs.get(j + 1).y + 0.1f, (float) vecs.get(j + 1).z).setColor(Render2DEngine.injectAlpha(HudEditor.getColor((int) (j / 20f)), (int) (alpha * 255f)).getRGB());
|
| 553 | }
|
| 554 | Render2DEngine.endBuilding(bufferBuilder);
|
| 555 |
|
| 556 | RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
|
| 557 | bufferBuilder = Tesselator.getInstance().begin(com.mojang.blaze3d.PrimitiveTopology.TRIANGLE_STRIP, DefaultVertexFormat.POSITION_COLOR);
|
| 558 | for (int j = 0; j < vecs1.size() - 1; ++j) {
|
| 559 | float alpha = 1f - (((float) j + ((System.currentTimeMillis() - ThunderHack.initTime) / 5f)) % 360) / 60f;
|
| 560 | bufferBuilder.addVertex(matrix, (float) vecs1.get(j).x, (float) vecs1.get(j).y, (float) vecs1.get(j).z).setColor(Render2DEngine.injectAlpha(HudEditor.getColor((int) (j / 20f)), (int) (alpha * 255)).getRGB());
|
| 561 | bufferBuilder.addVertex(matrix, (float) vecs1.get(j + 1).x, (float) vecs1.get(j + 1).y + 0.1f, (float) vecs1.get(j + 1).z).setColor(Render2DEngine.injectAlpha(HudEditor.getColor((int) (j / 20f)), (int) (alpha * 255f)).getRGB());
|
| 562 | }
|
| 563 | Render2DEngine.endBuilding(bufferBuilder);
|
| 564 |
|
| 565 | RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
|
| 566 | bufferBuilder = Tesselator.getInstance().begin(com.mojang.blaze3d.PrimitiveTopology.TRIANGLE_STRIP, DefaultVertexFormat.POSITION_COLOR);
|
| 567 | for (int j = 0; j < vecs2.size() - 1; ++j) {
|
| 568 | float alpha = 1f - (((float) j + ((System.currentTimeMillis() - ThunderHack.initTime) / 5f)) % 360) / 60f;
|
| 569 | bufferBuilder.addVertex(matrix, (float) vecs2.get(j).x, (float) vecs2.get(j).y, (float) vecs2.get(j).z).setColor(Render2DEngine.injectAlpha(HudEditor.getColor((int) (j / 20f)), (int) (alpha * 255)).getRGB());
|
| 570 | bufferBuilder.addVertex(matrix, (float) vecs2.get(j + 1).x, (float) vecs2.get(j + 1).y + 0.1f, (float) vecs2.get(j + 1).z).setColor(Render2DEngine.injectAlpha(HudEditor.getColor((int) (j / 20f)), (int) (alpha * 255f)).getRGB());
|
| 571 | }
|
| 572 | Render2DEngine.endBuilding(bufferBuilder);
|
| 573 |
|
| 574 | RenderSystem.enableCull();
|
| 575 | stack.translate(-x, -y, -z);
|
| 576 | endRender();
|
| 577 | RenderSystem.enableDepthTest();
|
| 578 | stack.popPose();
|
| 579 | }
|
| 580 |
|
| 581 | public static void renderCrosses(@NotNull AABB box, Color color, float lineWidth) {
|
| 582 | setupRender();
|
| 583 | PoseStack matrices = matrixFrom(box.minX, box.minY, box.minZ);
|
| 584 | RenderSystem.disableCull();
|
| 585 | RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES);
|
| 586 | RenderSystem.lineWidth(lineWidth);
|
| 587 | BufferBuilder buffer = Tesselator.getInstance().begin(com.mojang.blaze3d.PrimitiveTopology.LINES, DefaultVertexFormat.POSITION_COLOR);
|
| 588 |
|
| 589 | box = box.move(new Vec3(box.minX, box.minY, box.minZ).reverse());
|
| 590 |
|
| 591 | vertexLine(matrices, buffer, (float) box.maxX, (float) box.minY, (float) box.minZ, (float) box.minX, (float) box.minY, (float) box.maxZ, color);
|
| 592 | vertexLine(matrices, buffer, (float) box.minX, (float) box.minY, (float) box.minZ, (float) box.maxX, (float) box.minY, (float) box.maxZ, color);
|
| 593 |
|
| 594 | Render2DEngine.endBuilding(buffer);
|
| 595 | RenderSystem.enableCull();
|
| 596 | endRender();
|
| 597 | }
|
| 598 |
|
| 599 | public static void drawSphere(PoseStack matrix, float radius, int slices, int stacks, int color) {
|
| 600 | float drho = 3.1415927F / ((float) stacks);
|
| 601 | float dtheta = 6.2831855F / ((float) slices - 1f);
|
| 602 | float rho;
|
| 603 | float theta;
|
| 604 | float x;
|
| 605 | float y;
|
| 606 | float z;
|
| 607 | int i;
|
| 608 | int j;
|
| 609 | setupRender();
|
| 610 | for (i = 1; i < stacks; ++i) {
|
| 611 | rho = (float) i * drho;
|
| 612 |
|
| 613 | BufferBuilder buffer = Tesselator.getInstance().begin(com.mojang.blaze3d.PrimitiveTopology.DEBUG_LINE_STRIP, DefaultVertexFormat.POSITION_COLOR);
|
| 614 | RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
|
| 615 |
|
| 616 | for (j = 0; j < slices; ++j) {
|
| 617 | theta = (float) j * dtheta;
|
| 618 | x = (float) (Math.cos(theta) * Math.sin(rho));
|
| 619 | y = (float) (Math.sin(theta) * Math.sin(rho));
|
| 620 | z = (float) Math.cos(rho);
|
| 621 | buffer.addVertex(matrix.last().pose(), x * radius, y * radius, z * radius).setColor(color);
|
| 622 | }
|
| 623 | Render2DEngine.endBuilding(buffer);
|
| 624 | }
|
| 625 |
|
| 626 | for (j = 0; j < slices; ++j) {
|
| 627 | theta = (float) j * dtheta;
|
| 628 |
|
| 629 | BufferBuilder buffer = Tesselator.getInstance().begin(com.mojang.blaze3d.PrimitiveTopology.DEBUG_LINE_STRIP, DefaultVertexFormat.POSITION_COLOR);
|
| 630 |
|
| 631 | RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
|
| 632 |
|
| 633 | for (i = 0; i <= stacks; ++i) {
|
| 634 | rho = (float) i * drho;
|
| 635 | x = (float) (Math.cos(theta) * Math.sin(rho));
|
| 636 | y = (float) (Math.sin(theta) * Math.sin(rho));
|
| 637 | z = (float) Math.cos(rho);
|
| 638 | buffer.addVertex(matrix.last().pose(), x * radius, y * radius, z * radius).setColor(color);
|
| 639 | }
|
| 640 | BufferRenderer.drawWithGlobalProgram(buffer.buildOrThrow());
|
| 641 | }
|
| 642 | endRender();
|
| 643 | }
|
| 644 |
|
| 645 | public static void drawCylinder(PoseStack stack, final float radius, final float height, final int slices, final int stacks, int color) {
|
| 646 |
|
| 647 | final float da = (float) ((Math.PI * 2f) / slices);
|
| 648 | final float dz = height / stacks;
|
| 649 |
|
| 650 | BufferBuilder buffer = Tesselator.getInstance().begin(com.mojang.blaze3d.PrimitiveTopology.DEBUG_LINE_STRIP, DefaultVertexFormat.POSITION_COLOR);
|
| 651 | RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
|
| 652 |
|
| 653 | float y = 0;
|
| 654 |
|
| 655 | for (int j = 0; j <= stacks; ++j) {
|
| 656 | for (int i = 0; i <= slices; ++i) {
|
| 657 | final float x = (float) Math.cos(i * da);
|
| 658 | final float z = (float) Math.sin(i * da);
|
| 659 | buffer.addVertex(stack.last().pose(), x * radius, y, z * radius).setColor(color);
|
| 660 | }
|
| 661 | y += dz;
|
| 662 | }
|
| 663 |
|
| 664 | BufferRenderer.drawWithGlobalProgram(buffer.buildOrThrow());
|
| 665 |
|
| 666 | buffer = Tesselator.getInstance().begin(com.mojang.blaze3d.PrimitiveTopology.DEBUG_LINE_STRIP, DefaultVertexFormat.POSITION_COLOR);
|
| 667 | RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
|
| 668 |
|
| 669 | for (int i = 0; i <= slices; ++i) {
|
| 670 | final float x = (float) Math.cos(i * da);
|
| 671 | final float z = (float) Math.sin(i * da);
|
| 672 |
|
| 673 | buffer.addVertex(stack.last().pose(), x * radius, 0, z * radius).setColor(color);
|
| 674 | buffer.addVertex(stack.last().pose(), x * radius, height, z * radius).setColor(color);
|
| 675 | }
|
| 676 |
|
| 677 | BufferRenderer.drawWithGlobalProgram(buffer.buildOrThrow());
|
| 678 | }
|
| 679 |
|
| 680 |
|
| 681 | public static void drawCircle3D(PoseStack stack, Entity ent, float radius, int color, int points, boolean hudColor, int colorOffset) {
|
| 682 | setupRender();
|
| 683 | RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
|
| 684 | BufferBuilder bufferBuilder = Tesselator.getInstance().begin(com.mojang.blaze3d.PrimitiveTopology.DEBUG_LINE_STRIP, DefaultVertexFormat.POSITION_COLOR);
|
| 685 | double x = ent.xo + (ent.getX() - ent.xo) * getTickDelta() - mc.getEntityRenderDispatcher().camera.position().x;
|
| 686 | double y = ent.yo + (ent.getY() - ent.yo) * getTickDelta() - mc.getEntityRenderDispatcher().camera.position().y;
|
| 687 | double z = ent.zo + (ent.getZ() - ent.zo) * getTickDelta() - mc.getEntityRenderDispatcher().camera.position().z;
|
| 688 | stack.pushPose();
|
| 689 | stack.translate(x, y, z);
|
| 690 |
|
| 691 | Matrix4f matrix = stack.last().pose();
|
| 692 | for (int i = 0; i <= points; i++) {
|
| 693 | if (hudColor)
|
| 694 | color = HudEditor.getColor(i * colorOffset).getRGB();
|
| 695 |
|
| 696 | bufferBuilder.addVertex(matrix, (float) (radius * Math.cos(i * 6.28 / points)), 0f, (float) (radius * Math.sin(i * 6.28 / points))).setColor(color);
|
| 697 | }
|
| 698 |
|
| 699 | BufferRenderer.drawWithGlobalProgram(bufferBuilder.buildOrThrow());
|
| 700 | endRender();
|
| 701 | stack.translate(-x, -y, -z);
|
| 702 | stack.popPose();
|
| 703 | }
|
| 704 |
|
| 705 | public static void drawOldTargetEsp(PoseStack stack, Entity target) {
|
| 706 | double cs = prevCircleStep + (circleStep - prevCircleStep) * getTickDelta();
|
| 707 | double prevSinAnim = absSinAnimation(cs - 0.45f);
|
| 708 | double sinAnim = absSinAnimation(cs);
|
| 709 | double x = target.xo + (target.getX() - target.xo) * getTickDelta() - mc.getEntityRenderDispatcher().camera.position().x;
|
| 710 | double y = target.yo + (target.getY() - target.yo) * getTickDelta() - mc.getEntityRenderDispatcher().camera.position().y + prevSinAnim * target.getBbHeight();
|
| 711 | double z = target.zo + (target.getZ() - target.zo) * getTickDelta() - mc.getEntityRenderDispatcher().camera.position().z;
|
| 712 | double nextY = target.yo + (target.getY() - target.yo) * getTickDelta() - mc.getEntityRenderDispatcher().camera.position().y + sinAnim * target.getBbHeight();
|
| 713 | stack.pushPose();
|
| 714 | setupRender();
|
| 715 | RenderSystem.disableCull();
|
| 716 | RenderSystem.disableDepthTest();
|
| 717 | BufferBuilder bufferBuilder = Tesselator.getInstance().begin(com.mojang.blaze3d.PrimitiveTopology.TRIANGLE_STRIP, DefaultVertexFormat.POSITION_COLOR);
|
| 718 |
|
| 719 | RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
|
| 720 | float cos;
|
| 721 | float sin;
|
| 722 | for (int i = 0; i <= 30; i++) {
|
| 723 | cos = (float) (x + Math.cos(i * 6.28 / 30) * target.getBbWidth() * 0.8);
|
| 724 | sin = (float) (z + Math.sin(i * 6.28 / 30) * target.getBbWidth() * 0.8);
|
| 725 | bufferBuilder.addVertex(stack.last().pose(), cos, (float) nextY, sin).setColor(Render2DEngine.injectAlpha(HudEditor.getColor(i), 170).getRGB());
|
| 726 | bufferBuilder.addVertex(stack.last().pose(), cos, (float) y, sin).setColor(Render2DEngine.injectAlpha(HudEditor.getColor(i), 0).getRGB());
|
| 727 | }
|
| 728 | Render2DEngine.endBuilding(bufferBuilder);
|
| 729 | RenderSystem.enableCull();
|
| 730 | endRender();
|
| 731 | RenderSystem.enableDepthTest();
|
| 732 | stack.popPose();
|
| 733 | }
|
| 734 |
|
| 735 | // Kalry не пасть
|
| 736 | // anti yg protection
|
| 737 | public static void renderGhosts(int espLength, int factor, float shaking, float amplitude, Entity target) {
|
| 738 | Camera camera = mc.gameRenderer.mainCamera();
|
| 739 |
|
| 740 | double tPosX = Render2DEngine.interpolate(target.xo, target.getX(), Render3DEngine.getTickDelta()) - camera.position().x;
|
| 741 | double tPosY = Render2DEngine.interpolate(target.yo, target.getY(), Render3DEngine.getTickDelta()) - camera.position().y;
|
| 742 | double tPosZ = Render2DEngine.interpolate(target.zo, target.getZ(), Render3DEngine.getTickDelta()) - camera.position().z;
|
| 743 | float iAge = (float) Render2DEngine.interpolate(target.tickCount - 1, target.tickCount, Render3DEngine.getTickDelta());
|
| 744 |
|
| 745 | RenderSystem.enableBlend();
|
| 746 | RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE);
|
| 747 | RenderSystem.setShaderTexture(0, TextureStorage.firefly);
|
| 748 | RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR);
|
| 749 | BufferBuilder buffer = Tesselator.getInstance().begin(com.mojang.blaze3d.PrimitiveTopology.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
| 750 |
|
| 751 | boolean canSee = mc.player.hasLineOfSight(target);
|
| 752 |
|
| 753 | if (canSee) {
|
| 754 | RenderSystem.enableDepthTest();
|
| 755 | RenderSystem.depthMask(false);
|
| 756 | } else RenderSystem.disableDepthTest();
|
| 757 |
|
| 758 | for (int j = 0; j < 3; j++) {
|
| 759 | for (int i = 0; i <= espLength; i++) {
|
| 760 | double radians = Math.toRadians((((float) i / 1.5f + iAge) * factor + (j * 120)) % (factor * 360));
|
| 761 | double sinQuad = Math.sin(Math.toRadians(iAge * 2.5f + i * (j + 1)) * amplitude) / shaking;
|
| 762 |
|
| 763 | float offset = ((float) i / espLength);
|
| 764 | PoseStack matrices = new PoseStack();
|
| 765 | matrices.mulPose(Axis.XP.rotationDegrees(camera.xRot()));
|
| 766 | matrices.mulPose(Axis.YP.rotationDegrees(camera.yRot() + 180.0F));
|
| 767 | matrices.translate(tPosX + Math.cos(radians) * target.getBbWidth(), (tPosY + 1 + sinQuad), tPosZ + Math.sin(radians) * target.getBbWidth());
|
| 768 | matrices.mulPose(Axis.YP.rotationDegrees(-camera.yRot()));
|
| 769 | matrices.mulPose(Axis.XP.rotationDegrees(camera.xRot()));
|
| 770 | Matrix4f matrix = matrices.last().pose();
|
| 771 | int color = Render2DEngine.applyOpacity(HudEditor.getColor((int) (180 * offset)), offset).getRGB();
|
| 772 | float scale = Math.max(0.24f * (offset), 0.2f);
|
| 773 | buffer.addVertex(matrix, -scale, scale, 0).setUv(0f, 1f).setColor(color);
|
| 774 | buffer.addVertex(matrix, scale, scale, 0).setUv(1f, 1f).setColor(color);
|
| 775 | buffer.addVertex(matrix, scale, -scale, 0).setUv(1f, 0).setColor(color);
|
| 776 | buffer.addVertex(matrix, -scale, -scale, 0).setUv(0, 0).setColor(color);
|
| 777 | }
|
| 778 | }
|
| 779 |
|
| 780 | BufferRenderer.drawWithGlobalProgram(buffer.buildOrThrow());
|
| 781 |
|
| 782 | if (canSee) {
|
| 783 | RenderSystem.depthMask(true);
|
| 784 | RenderSystem.disableDepthTest();
|
| 785 | } else RenderSystem.enableDepthTest();
|
| 786 |
|
| 787 | RenderSystem.disableBlend();
|
| 788 | }
|
| 789 |
|
| 790 | public static void updateTargetESP() {
|
| 791 | prevCircleStep = circleStep;
|
| 792 | circleStep += 0.15f;
|
| 793 | }
|
| 794 |
|
| 795 | public static double absSinAnimation(double input) {
|
| 796 | return Math.abs(1 + Math.sin(input)) / 2;
|
| 797 | }
|
| 798 |
|
| 799 | public static Vec3 interpolatePos(float prevposX, float prevposY, float prevposZ, float posX, float posY, float posZ) {
|
| 800 | double x = prevposX + ((posX - prevposX) * getTickDelta()) - mc.getEntityRenderDispatcher().camera.position().x;
|
| 801 | double y = prevposY + ((posY - prevposY) * getTickDelta()) - mc.getEntityRenderDispatcher().camera.position().y;
|
| 802 | double z = prevposZ + ((posZ - prevposZ) * getTickDelta()) - mc.getEntityRenderDispatcher().camera.position().z;
|
| 803 | return new Vec3(x, y, z);
|
| 804 | }
|
| 805 |
|
| 806 | public static void drawLineDebug(Vec3 start, Vec3 end, Color color) {
|
| 807 | DEBUG_LINE_QUEUE.add(new DebugLineAction(start, end, color));
|
| 808 | }
|
| 809 |
|
| 810 | public static float getTickDelta() {
|
| 811 | return mc.getDeltaTracker().getGameTimeDeltaPartialTick(true);
|
| 812 | }
|
| 813 |
|
| 814 | public record FillAction(AABB box, Color color) {
|
| 815 | }
|
| 816 |
|
| 817 | public record OutlineAction(AABB box, Color color, float lineWidth) {
|
| 818 | }
|
| 819 |
|
| 820 | public record FadeAction(AABB box, Color color, Color color2) {
|
| 821 | }
|
| 822 |
|
| 823 | public record FillSideAction(AABB box, Color color, Direction side) {
|
| 824 | }
|
| 825 |
|
| 826 | public record OutlineSideAction(AABB box, Color color, float lineWidth, Direction side) {
|
| 827 | }
|
| 828 |
|
| 829 | public record DebugLineAction(Vec3 start, Vec3 end, Color color) {
|
| 830 | }
|
| 831 |
|
| 832 | public record LineAction(Vec3 start, Vec3 end, Color color) {
|
| 833 | }
|
| 834 | }
|
| 835 |
|