Skip to content

Commit e2848ed

Browse files
committed
fix: argument of VRender
1 parent dcff1fe commit e2848ed

File tree

11 files changed

+1236
-1090
lines changed

11 files changed

+1236
-1090
lines changed

src/main/java/me/matl114/hacks/RenderTasks.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public BoxObject(Vec3d start, Vec3d end, Color color) {
263263
@Override
264264
public void render(MatrixStack stack, float partialTicks) {
265265
RenderUtils.setAsCurrentShaderColor(color, opacity);
266-
RenderUtils.drawSolidBox(stack.peek().getPositionMatrix(), startVec, endVec);
266+
RenderUtils.drawSolidBox(stack, startVec, endVec);
267267
}
268268
}
269269

@@ -300,9 +300,9 @@ public BoxMoveTarget(Box startBox, Vec3d delta) {
300300
@Override
301301
public void render(MatrixStack stack, float partialTicks) {
302302
RenderUtils.setAsCurrentShaderColor(color1, 0.25F);
303-
RenderUtils.drawSolidBox(stack.peek().getPositionMatrix(), startBox.getMinPos(), startBox.getMaxPos());
303+
RenderUtils.drawSolidBox(stack, startBox.getMinPos(), startBox.getMaxPos());
304304
RenderUtils.drawSolidBox(
305-
stack.peek().getPositionMatrix(),
305+
stack,
306306
startBox.getMinPos().add(delta),
307307
startBox.getMaxPos().add(delta));
308308
for (var ver : CollisionUtil.getBoxVertices(startBox))
@@ -325,7 +325,7 @@ public QuadObject(Vec3d abcd, Vec3d b, Vec3d c, Vec3d d, Color color) {
325325
@Override
326326
public void render(MatrixStack stack, float partialTicks) {
327327
RenderUtils.setAsCurrentShaderColor(color, 0.25F);
328-
RenderUtils.drawQuad(stack.peek().getPositionMatrix(), abcd[0], abcd[1], abcd[2], abcd[3]);
328+
RenderUtils.drawQuad(stack, abcd[0], abcd[1], abcd[2], abcd[3]);
329329
}
330330
}
331331

@@ -373,7 +373,7 @@ public static class EntityBoxObject implements RenderObject {
373373
public void render(MatrixStack stack, float partialTicks) {
374374
RenderUtils.setAsCurrentShaderColor(color, 1.0F);
375375
RenderUtils.drawSolidBox(
376-
stack.peek().getPositionMatrix(),
376+
stack,
377377
entity.getBoundingBox().getMinPos(),
378378
entity.getBoundingBox().getMaxPos());
379379
}

src/main/java/me/matl114/hacks/modules/combat/Attack.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void onRenderTarget(Event<MatrixStack> stackE) {
162162
float opacity = Math.min(0.6F, 0.10F + dist * 0.02F);
163163
RenderUtils.setAsCurrentShaderColor(Color.GREEN, opacity);
164164
Box box = RenderUtils.getLerpedBox(entity, tickDelta);
165-
RenderUtils.drawSolidBox(stack.peek().getPositionMatrix(), box.getMinPos(), box.getMaxPos());
165+
RenderUtils.drawSolidBox(stack, box.getMinPos(), box.getMaxPos());
166166
}
167167
} finally {
168168
RenderUtils.stopDrawVirtual(stack);

src/main/java/me/matl114/hacks/modules/combat/BowEnhance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public void onRenderAimTarget(Event<MatrixStack> stackE) {
171171
if (entity != null) {
172172
RenderUtils.setAsCurrentShaderColor(Color.GREEN, 0.25F);
173173
Box box = RenderUtils.getLerpedBox(entity, tickDelta);
174-
RenderUtils.drawSolidBox(stack.peek().getPositionMatrix(), box.getMinPos(), box.getMaxPos());
174+
RenderUtils.drawSolidBox(stack, box.getMinPos(), box.getMaxPos());
175175
}
176176
} finally {
177177
RenderUtils.stopDrawVirtual(stack);

src/main/java/me/matl114/hacks/modules/mine/MineExtra.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public void onRender(Event<MatrixStack> renderEvent) {
192192
Vec3d vec3d = pos.add(box.getCenter());
193193
float clamped = MathHelper.clamp(progress, 0.0F, 1.0F);
194194
RenderUtils.drawSolidBox(
195-
renderEvent.context.peek().getPositionMatrix(),
195+
renderEvent.context,
196196
vec3d.add(vec3.multiply(-clamped)),
197197
vec3d.add(vec3.multiply(clamped)));
198198
}
@@ -228,7 +228,7 @@ public void onRender(Event<MatrixStack> renderEvent) {
228228
Vec3d vec3d = doubleMineVec.add(box.getCenter());
229229
float clamped = MathHelper.clamp(progressFail, 0.0F, 1.0F);
230230
RenderUtils.drawSolidBox(
231-
renderEvent.context.peek().getPositionMatrix(),
231+
renderEvent.context,
232232
vec3d.add(vec3.multiply(-clamped)),
233233
vec3d.add(vec3.multiply(clamped)));
234234
}

src/main/java/me/matl114/hacks/modules/render/ProjectileESP.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ private static void drawClassicArrowTrajectory(MatrixStack stack, List<Vec3d> ve
476476
Vec3d finalPosition = vec3ds.get(vec3ds.size() - 1);
477477
RenderUtils.setAsCurrentShaderColor(Color.GREEN, 0.25F);
478478
RenderUtils.drawSolidBox(
479-
stack.peek().getPositionMatrix(),
479+
stack,
480480
finalPosition.add(RenderTasks.SMALL_FROM),
481481
finalPosition.add(RenderTasks.SMALL_TO));
482482
}
@@ -491,14 +491,14 @@ private static void drawArrowTrajectoryWithHitResult(
491491
Vec3d finalPosition = vec3ds.get(vec3ds.size() - 1);
492492
RenderUtils.setAsCurrentShaderColor(Color.GREEN, 0.25F);
493493
RenderUtils.drawSolidBox(
494-
stack.peek().getPositionMatrix(),
494+
stack,
495495
finalPosition.add(RenderTasks.SMALL_FROM),
496496
finalPosition.add(RenderTasks.SMALL_TO));
497497
} else {
498498
Entity hitEntity = ((EntityHitResult) result).getEntity();
499499
RenderUtils.setAsCurrentShaderColor(Color.GREEN, 0.25F);
500500
Box box = RenderUtils.getLerpedBox(hitEntity, tickDelta);
501-
RenderUtils.drawSolidBox(stack.peek().getPositionMatrix(), box.getMinPos(), box.getMaxPos());
501+
RenderUtils.drawSolidBox(stack, box.getMinPos(), box.getMaxPos());
502502
}
503503
}
504504
}

src/main/java/me/matl114/mixins/versioned/MatrixStackMixin.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package me.matl114.mixins.versioned;
22

33
import net.minecraft.client.util.math.MatrixStack;
4+
import org.joml.Matrix3f;
45
import org.joml.Matrix4f;
56
import org.joml.Quaternionf;
67
import org.spongepowered.asm.mixin.Mixin;
@@ -38,6 +39,10 @@ public Matrix4f peek3D() {
3839
return this.peek().getPositionMatrix();
3940
}
4041

42+
public Matrix3f peekNormal(){
43+
return this.peek().getNormalMatrix();
44+
}
45+
4146
public void translate(float x, float y) {
4247
this.translate(x, y, 0);
4348
}

src/main/java/me/matl114/utils/RenderUtils.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,31 +110,27 @@ public static void drawLineVirtualCameraCoord(MatrixStack matrixStack, List<Vec3
110110

111111
public static void drawOutlinedBox(MatrixStack matrix, Vec3d from, Vec3d to) {
112112
Vec3d vec3d = getCameraPos();
113-
drawOutlinedBoxCameraCoord(matrix.peek().getPositionMatrix(), from.subtract(vec3d), to.subtract(vec3d));
113+
drawOutlinedBoxCameraCoord(matrix, from.subtract(vec3d), to.subtract(vec3d));
114114
}
115115

116116
public static void drawOutlinedBoxCameraCoord(MatrixStack matrix, Vec3d from, Vec3d to) {
117-
drawOutlinedBoxCameraCoord(matrix.peek().getPositionMatrix(), from, to);
118-
}
119-
120-
public static void drawOutlinedBoxCameraCoord(Matrix4f matrix, Vec3d from, Vec3d to) {
121117
VRender.getInstance().drawOutlinedBoxCameraCoord(matrix, from, to);
122118
}
123119

124120
public static void drawSolidBoxCameraCoord(Matrix4f matrix, Vec3d from, Vec3d to) {
125-
VRender.getInstance().drawSolidBoxCameraCoord(matrix, from, to);
121+
126122
}
127123

128-
public static void drawSolidBox(Matrix4f matrix, Vec3d from, Vec3d to) {
124+
public static void drawSolidBox(MatrixStack matrix, Vec3d from, Vec3d to) {
129125
Vec3d vec3d = getCameraPos();
130-
drawSolidBoxCameraCoord(matrix, from.subtract(vec3d), to.subtract(vec3d));
126+
VRender.getInstance().drawSolidBoxCameraCoord(matrix, from.subtract(vec3d), to.subtract(vec3d));
131127
}
132128

133-
public static void drawQuadCameraCoord(Matrix4f matrix4f, Vec3d a, Vec3d b, Vec3d c, Vec3d d) {
129+
public static void drawQuadCameraCoord(MatrixStack matrix4f, Vec3d a, Vec3d b, Vec3d c, Vec3d d) {
134130
VRender.getInstance().drawQuadCameraCoord(matrix4f, a, b, c, d);
135131
}
136132

137-
public static void drawQuad(Matrix4f matrix4f, Vec3d a, Vec3d b, Vec3d c, Vec3d d) {
133+
public static void drawQuad(MatrixStack matrix4f, Vec3d a, Vec3d b, Vec3d c, Vec3d d) {
138134
Vec3d vec3d = getCameraPos();
139135
drawQuadCameraCoord(matrix4f, a.subtract(vec3d), b.subtract(vec3d), c.subtract(vec3d), d.subtract(vec3d));
140136
}

src/main/java/me/matl114/versioned/api/MatrixStack.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.matl114.versioned.api;
22

3+
import org.joml.Matrix3f;
34
import org.joml.Matrix4f;
45
import org.joml.Quaternionf;
56

@@ -11,6 +12,8 @@ public interface MatrixStack {
1112

1213
public Matrix4f peek3D();
1314

15+
public Matrix3f peekNormal();
16+
1417
public void translate(float x, float y);
1518

1619
public void translateZ(float z);

src/main/java/me/matl114/versioned/api/VRender.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public static VRender getInstance() {
2020

2121
public void drawLineVirtualCameraCoord(MatrixStack matrixStack, List<Vec3d> pairs, Color color);
2222

23-
public void drawOutlinedBoxCameraCoord(Matrix4f matrix, Vec3d from, Vec3d to);
23+
public void drawOutlinedBoxCameraCoord(MatrixStack matrix, Vec3d from, Vec3d to);
2424

25-
public void drawSolidBoxCameraCoord(Matrix4f matrix, Vec3d from, Vec3d to);
25+
public void drawSolidBoxCameraCoord(MatrixStack matrix, Vec3d from, Vec3d to);
2626

27-
public void drawQuadCameraCoord(Matrix4f matrix4f, Vec3d a, Vec3d b, Vec3d c, Vec3d d);
27+
public void drawQuadCameraCoord(MatrixStack matrix4f, Vec3d a, Vec3d b, Vec3d c, Vec3d d);
2828

2929
public void setAsShaderColor(Color color, float opacity);
3030
}

src/main/java/me/matl114/versioned/impl/Render_v1_21_1.java

Lines changed: 12 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ public void drawLineVirtualCameraCoord(MatrixStack matrixStack, List<Vec3d> pair
2929
}
3030

3131
@Override
32-
public void drawOutlinedBoxCameraCoord(Matrix4f matrix, Vec3d from, Vec3d to) {
32+
public void drawOutlinedBoxCameraCoord(MatrixStack matrix, Vec3d from, Vec3d to) {
3333
Tessellator tessellator = RenderSystem.renderThreadTesselator();
3434
RenderSystem.setShader(GameRenderer::getPositionProgram);
3535
BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION);
36-
drawOutlinedBox(matrix, bufferBuilder, from, to);
36+
drawOutlinedBox(matrix.peek(), bufferBuilder, from, to);
3737
// Vec3d vec3d = new Vec3d(matrix.transformPosition((float) from.x, (float) from.y, (float) from.z, new
3838
// Vector3f()));
3939
// Vec3d vec3d1 = new Vec3d(matrix.transformPosition((float) to.x, (float) to.y, (float) to.z, new
@@ -43,23 +43,24 @@ public void drawOutlinedBoxCameraCoord(Matrix4f matrix, Vec3d from, Vec3d to) {
4343
}
4444

4545
@Override
46-
public void drawSolidBoxCameraCoord(Matrix4f matrix, Vec3d from, Vec3d to) {
46+
public void drawSolidBoxCameraCoord(MatrixStack matrix, Vec3d from, Vec3d to) {
4747
Tessellator tessellator = RenderSystem.renderThreadTesselator();
4848
RenderSystem.setShader(GameRenderer::getPositionProgram);
4949
BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
50-
drawSolidBox(matrix, bufferBuilder, from, to);
50+
drawSolidBox(matrix.peek(), bufferBuilder, from, to);
5151
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
5252
}
5353

5454
@Override
55-
public void drawQuadCameraCoord(Matrix4f matrix4f, Vec3d a, Vec3d b, Vec3d c, Vec3d d) {
55+
public void drawQuadCameraCoord(MatrixStack matrix4f, Vec3d a, Vec3d b, Vec3d c, Vec3d d) {
5656
Tessellator tessellator = RenderSystem.renderThreadTesselator();
5757
RenderSystem.setShader(GameRenderer::getPositionProgram);
5858
BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
59-
bufferBuilder.vertex(matrix4f, (float) a.x, (float) a.y, (float) a.z);
60-
bufferBuilder.vertex(matrix4f, (float) b.x, (float) b.y, (float) b.z);
61-
bufferBuilder.vertex(matrix4f, (float) c.x, (float) c.y, (float) c.z);
62-
bufferBuilder.vertex(matrix4f, (float) d.x, (float) d.y, (float) d.z);
59+
var matrix4 = matrix4f.peek();
60+
bufferBuilder.vertex(matrix4, (float) a.x, (float) a.y, (float) a.z);
61+
bufferBuilder.vertex(matrix4, (float) b.x, (float) b.y, (float) b.z);
62+
bufferBuilder.vertex(matrix4, (float) c.x, (float) c.y, (float) c.z);
63+
bufferBuilder.vertex(matrix4, (float) d.x, (float) d.y, (float) d.z);
6364
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
6465
}
6566

@@ -124,7 +125,7 @@ public static void cacheVertexAction(
124125
}
125126
}
126127

127-
public static void drawOutlinedBox(Matrix4f matrix, BufferBuilder bufferBuilder, Vec3d from, Vec3d to) {
128+
public static void drawOutlinedBox(MatrixStack.Entry matrix, BufferBuilder bufferBuilder, Vec3d from, Vec3d to) {
128129
float minX = (float) from.getX();
129130
float minY = (float) from.getY();
130131
float minZ = (float) from.getZ();
@@ -168,7 +169,7 @@ public static void drawOutlinedBox(Matrix4f matrix, BufferBuilder bufferBuilder,
168169
bufferBuilder.vertex(matrix, minX, maxY, minZ);
169170
}
170171

171-
public static void drawSolidBox(Matrix4f matrix, BufferBuilder bufferBuilder, Vec3d from, Vec3d to) {
172+
public static void drawSolidBox(MatrixStack.Entry matrix, BufferBuilder bufferBuilder, Vec3d from, Vec3d to) {
172173
float minX = (float) from.x;
173174
float minY = (float) from.y;
174175
float minZ = (float) from.z;
@@ -206,87 +207,4 @@ public static void drawSolidBox(Matrix4f matrix, BufferBuilder bufferBuilder, Ve
206207
bufferBuilder.vertex(matrix, minX, maxY, maxZ);
207208
bufferBuilder.vertex(matrix, minX, maxY, minZ);
208209
}
209-
210-
public static void drawOutlinedBox(MatrixStack stack, BufferBuilder bufferBuilder, Vec3d from, Vec3d to) {
211-
float minX = (float) from.getX();
212-
float minY = (float) from.getY();
213-
float minZ = (float) from.getZ();
214-
float maxX = (float) to.getX();
215-
float maxY = (float) to.getY();
216-
float maxZ = (float) to.getZ();
217-
bufferBuilder.vertex(minX, minY, minZ);
218-
bufferBuilder.vertex(maxX, minY, minZ);
219-
220-
bufferBuilder.vertex(maxX, minY, minZ);
221-
bufferBuilder.vertex(maxX, minY, maxZ);
222-
223-
bufferBuilder.vertex(maxX, minY, maxZ);
224-
bufferBuilder.vertex(minX, minY, maxZ);
225-
226-
bufferBuilder.vertex(minX, minY, maxZ);
227-
bufferBuilder.vertex(minX, minY, minZ);
228-
229-
bufferBuilder.vertex(minX, minY, minZ);
230-
bufferBuilder.vertex(minX, maxY, minZ);
231-
232-
bufferBuilder.vertex(maxX, minY, minZ);
233-
bufferBuilder.vertex(maxX, maxY, minZ);
234-
235-
bufferBuilder.vertex(maxX, minY, maxZ);
236-
bufferBuilder.vertex(maxX, maxY, maxZ);
237-
238-
bufferBuilder.vertex(minX, minY, maxZ);
239-
bufferBuilder.vertex(minX, maxY, maxZ);
240-
241-
bufferBuilder.vertex(minX, maxY, minZ);
242-
bufferBuilder.vertex(maxX, maxY, minZ);
243-
244-
bufferBuilder.vertex(maxX, maxY, minZ);
245-
bufferBuilder.vertex(maxX, maxY, maxZ);
246-
247-
bufferBuilder.vertex(maxX, maxY, maxZ);
248-
bufferBuilder.vertex(minX, maxY, maxZ);
249-
250-
bufferBuilder.vertex(minX, maxY, maxZ);
251-
bufferBuilder.vertex(minX, maxY, minZ);
252-
}
253-
254-
public static void drawSolidBox(BufferBuilder bufferBuilder, Vec3d from, Vec3d to) {
255-
float minX = (float) from.x;
256-
float minY = (float) from.y;
257-
float minZ = (float) from.z;
258-
float maxX = (float) to.x;
259-
float maxY = (float) to.y;
260-
float maxZ = (float) to.z;
261-
262-
bufferBuilder.vertex(minX, minY, minZ);
263-
bufferBuilder.vertex(maxX, minY, minZ);
264-
bufferBuilder.vertex(maxX, minY, maxZ);
265-
bufferBuilder.vertex(minX, minY, maxZ);
266-
267-
bufferBuilder.vertex(minX, maxY, minZ);
268-
bufferBuilder.vertex(minX, maxY, maxZ);
269-
bufferBuilder.vertex(maxX, maxY, maxZ);
270-
bufferBuilder.vertex(maxX, maxY, minZ);
271-
272-
bufferBuilder.vertex(minX, minY, minZ);
273-
bufferBuilder.vertex(minX, maxY, minZ);
274-
bufferBuilder.vertex(maxX, maxY, minZ);
275-
bufferBuilder.vertex(maxX, minY, minZ);
276-
277-
bufferBuilder.vertex(maxX, minY, minZ);
278-
bufferBuilder.vertex(maxX, maxY, minZ);
279-
bufferBuilder.vertex(maxX, maxY, maxZ);
280-
bufferBuilder.vertex(maxX, minY, maxZ);
281-
282-
bufferBuilder.vertex(minX, minY, maxZ);
283-
bufferBuilder.vertex(maxX, minY, maxZ);
284-
bufferBuilder.vertex(maxX, maxY, maxZ);
285-
bufferBuilder.vertex(minX, maxY, maxZ);
286-
287-
bufferBuilder.vertex(minX, minY, minZ);
288-
bufferBuilder.vertex(minX, minY, maxZ);
289-
bufferBuilder.vertex(minX, maxY, maxZ);
290-
bufferBuilder.vertex(minX, maxY, minZ);
291-
}
292210
}

0 commit comments

Comments
 (0)