Skip to content

Commit 9329c6f

Browse files
committed
Fix esp builder bounding box not shifted by position
1 parent 7631fa4 commit 9329c6f

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

common/src/main/kotlin/com/lambda/graphics/renderer/esp/builders/StaticESPBuilders.kt

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,42 +30,43 @@ import net.minecraft.util.math.Box
3030
import net.minecraft.util.shape.VoxelShape
3131
import java.awt.Color
3232

33-
fun StaticESPRenderer.buildMesh(
33+
fun StaticESPRenderer.ofShape(
3434
pos: BlockPos,
35-
state: BlockState,
3635
filledColor: Color,
3736
outlineColor: Color,
3837
sides: Int = DirectionMask.ALL,
3938
outlineMode: DirectionMask.OutlineMode = DirectionMask.OutlineMode.OR
4039
) = runSafe {
41-
val shape = state.getOutlineShape(world, pos)
42-
buildMesh(shape, filledColor, outlineColor, sides, outlineMode)
40+
val shape = pos.blockState(world).getOutlineShape(world, pos)
41+
ofShape(pos, shape, filledColor, outlineColor, sides, outlineMode)
4342
}
4443

45-
fun StaticESPRenderer.buildMesh(
44+
fun StaticESPRenderer.ofShape(
4645
pos: BlockPos,
46+
state: BlockState,
4747
filledColor: Color,
4848
outlineColor: Color,
4949
sides: Int = DirectionMask.ALL,
5050
outlineMode: DirectionMask.OutlineMode = DirectionMask.OutlineMode.OR
5151
) = runSafe {
52-
val shape = pos.blockState(world).getOutlineShape(world, pos)
53-
buildMesh(shape, filledColor, outlineColor, sides, outlineMode)
52+
val shape = state.getOutlineShape(world, pos)
53+
ofShape(pos, shape, filledColor, outlineColor, sides, outlineMode)
5454
}
5555

56-
fun StaticESPRenderer.buildMesh(
56+
fun StaticESPRenderer.ofShape(
57+
pos: BlockPos,
5758
shape: VoxelShape,
5859
filledColor: Color,
5960
outlineColor: Color,
6061
sides: Int = DirectionMask.ALL,
6162
outlineMode: DirectionMask.OutlineMode = DirectionMask.OutlineMode.OR
6263
) {
63-
shape.boundingBoxes
64-
.forEach { build(it,filledColor, outlineColor, sides, outlineMode) }
64+
shape.boundingBoxes.forEach {
65+
ofBox(it.offset(pos), filledColor, outlineColor, sides, outlineMode)
66+
}
6567
}
6668

67-
68-
fun StaticESPRenderer.build(
69+
fun StaticESPRenderer.ofBox(
6970
box: Box,
7071
filledColor: Color,
7172
outlineColor: Color,
@@ -76,26 +77,26 @@ fun StaticESPRenderer.build(
7677
buildOutline(box, outlineColor, sides, outlineMode)
7778
}
7879

79-
fun StaticESPRenderer.buildFilledMesh(
80+
fun StaticESPRenderer.buildFilledShape(
8081
pos: BlockPos,
8182
state: BlockState,
8283
color: Color,
8384
sides: Int = DirectionMask.ALL,
8485
) = runSafe {
8586
val shape = state.getOutlineShape(world, pos)
86-
buildFilledMesh(shape, color, sides)
87+
buildFilledShape(shape, color, sides)
8788
}
8889

89-
fun StaticESPRenderer.buildFilledMesh(
90+
fun StaticESPRenderer.buildFilledShape(
9091
pos: BlockPos,
9192
color: Color,
9293
sides: Int = DirectionMask.ALL,
9394
) = runSafe {
9495
val shape = pos.blockState(world).getOutlineShape(world, pos)
95-
buildFilledMesh(shape, color, sides)
96+
buildFilledShape(shape, color, sides)
9697
}
9798

98-
fun StaticESPRenderer.buildFilledMesh(
99+
fun StaticESPRenderer.buildFilledShape(
99100
shape: VoxelShape,
100101
color: Color,
101102
sides: Int = DirectionMask.ALL,
@@ -111,28 +112,28 @@ fun StaticESPRenderer.buildFilled(
111112
sides: Int = DirectionMask.ALL
112113
) = buildFilled(box, color, color, sides)
113114

114-
fun StaticESPRenderer.buildOutlineMesh(
115+
fun StaticESPRenderer.buildOutlineShape(
115116
pos: BlockPos,
116117
state: BlockState,
117118
color: Color,
118119
sides: Int = DirectionMask.ALL,
119120
outlineMode: DirectionMask.OutlineMode = DirectionMask.OutlineMode.OR
120121
) = runSafe {
121122
val shape = state.getOutlineShape(world, pos)
122-
buildOutlineMesh(shape, color, sides, outlineMode)
123+
buildOutlineShape(shape, color, sides, outlineMode)
123124
}
124125

125-
fun StaticESPRenderer.buildOutlineMesh(
126+
fun StaticESPRenderer.buildOutlineShape(
126127
pos: BlockPos,
127128
color: Color,
128129
sides: Int = DirectionMask.ALL,
129130
outlineMode: DirectionMask.OutlineMode = DirectionMask.OutlineMode.OR
130131
) = runSafe {
131132
val shape = pos.blockState(world).getOutlineShape(world, pos)
132-
buildOutlineMesh(shape, color, sides, outlineMode)
133+
buildOutlineShape(shape, color, sides, outlineMode)
133134
}
134135

135-
fun StaticESPRenderer.buildOutlineMesh(
136+
fun StaticESPRenderer.buildOutlineShape(
136137
shape: VoxelShape,
137138
color: Color,
138139
sides: Int = DirectionMask.ALL,

0 commit comments

Comments
 (0)