@@ -3,16 +3,20 @@ package com.lambda.client.module.modules.render
3
3
import com.lambda.client.LambdaMod
4
4
import com.lambda.client.event.SafeClientEvent
5
5
import com.lambda.client.event.events.PacketEvent
6
+ import com.lambda.client.event.events.RenderRadarEvent
6
7
import com.lambda.client.event.events.RenderWorldEvent
7
8
import com.lambda.client.module.Category
8
9
import com.lambda.client.module.Module
10
+ import com.lambda.client.util.BaritoneUtils
9
11
import com.lambda.client.util.EntityUtils.getInterpolatedPos
10
12
import com.lambda.client.util.FolderUtils
11
13
import com.lambda.client.util.TickTimer
12
14
import com.lambda.client.util.TimeUnit
13
15
import com.lambda.client.util.color.ColorHolder
14
16
import com.lambda.client.util.graphics.GlStateUtils
15
17
import com.lambda.client.util.graphics.LambdaTessellator
18
+ import com.lambda.client.util.graphics.RenderUtils2D
19
+ import com.lambda.client.util.math.Vec2d
16
20
import com.lambda.client.util.text.MessageSendHelper
17
21
import com.lambda.client.util.threads.safeListener
18
22
import com.lambda.client.util.math.VectorUtils.distanceTo
@@ -43,6 +47,9 @@ object NewChunks : Module(
43
47
) {
44
48
private val relative by setting(" Relative" , false , description = " Renders the chunks at relative Y level to player" )
45
49
private val renderMode by setting(" Render Mode" , RenderMode .BOTH )
50
+ private val chunkGridColor by setting(" Grid Color" , ColorHolder (255 , 0 , 0 , 100 ), true , { renderMode != RenderMode .WORLD })
51
+ private val distantChunkColor by setting(" Distant Chunk Color" , ColorHolder (100 , 100 , 100 , 100 ), true , { renderMode != RenderMode .WORLD }, " Chunks that are not in render distance and not in baritone cache" )
52
+ private val newChunkColor by setting(" New Chunk Color" , ColorHolder (255 , 0 , 0 , 100 ), true , { renderMode != RenderMode .WORLD })
46
53
private val saveNewChunks by setting(" Save New Chunks" , false )
47
54
private val saveOption by setting(" Save Option" , SaveOption .EXTRA_FOLDER , { saveNewChunks })
48
55
private val saveInRegionFolder by setting(" In Region" , false , { saveNewChunks })
@@ -106,6 +113,42 @@ object NewChunks : Module(
106
113
GlStateUtils .depth(true )
107
114
}
108
115
116
+ safeListener<RenderRadarEvent > {
117
+ if (renderMode == RenderMode .WORLD ) return @safeListener
118
+
119
+ val playerOffset = Vec2d ((player.posX - (player.chunkCoordX shl 4 )), (player.posZ - (player.chunkCoordZ shl 4 )))
120
+ val chunkDist = (it.radius * it.scale).toInt() shr 4
121
+
122
+ for (chunkX in - chunkDist.. chunkDist) {
123
+ for (chunkZ in - chunkDist.. chunkDist) {
124
+ val pos0 = getChunkPos(chunkX, chunkZ, playerOffset, it.scale)
125
+ val pos1 = getChunkPos(chunkX + 1 , chunkZ + 1 , playerOffset, it.scale)
126
+
127
+ if (isSquareInRadius(pos0, pos1, it.radius)) {
128
+ val chunk = world.getChunk(player.chunkCoordX + chunkX, player.chunkCoordZ + chunkZ)
129
+ val isCachedChunk =
130
+ BaritoneUtils .primary?.worldProvider?.currentWorld?.cachedWorld?.isCached(
131
+ (player.chunkCoordX + chunkX) shl 4 , (player.chunkCoordZ + chunkZ) shl 4
132
+ ) ? : false
133
+
134
+ if (! chunk.isLoaded && ! isCachedChunk) {
135
+ RenderUtils2D .drawRectFilled(it.vertexHelper, pos0, pos1, distantChunkColor)
136
+ }
137
+ RenderUtils2D .drawRectOutline(it.vertexHelper, pos0, pos1, 0.3f , chunkGridColor)
138
+ }
139
+ }
140
+ }
141
+
142
+ chunks.keys.forEach { chunk ->
143
+ val pos0 = getChunkPos(chunk.x - player.chunkCoordX, chunk.z - player.chunkCoordZ, playerOffset, it.scale)
144
+ val pos1 = getChunkPos(chunk.x - player.chunkCoordX + 1 , chunk.z - player.chunkCoordZ + 1 , playerOffset, it.scale)
145
+
146
+ if (isSquareInRadius(pos0, pos1, it.radius)) {
147
+ RenderUtils2D .drawRectFilled(it.vertexHelper, pos0, pos1, newChunkColor)
148
+ }
149
+ }
150
+ }
151
+
109
152
safeListener<PacketEvent .PostReceive > { event ->
110
153
if (event.packet is SPacketChunkData
111
154
&& ! event.packet.isFullChunk
@@ -284,6 +327,17 @@ object NewChunks : Module(
284
327
return ending.toIntOrNull() != null
285
328
}
286
329
330
+ // p2.x > p1.x and p2.y > p1.y is assumed
331
+ private fun isSquareInRadius (p1 : Vec2d , p2 : Vec2d , radius : Float ): Boolean {
332
+ val x = if (p1.x + p2.x > 0 ) p2.x else p1.x
333
+ val y = if (p1.y + p2.y > 0 ) p2.y else p1.y
334
+ return Vec2d (x, y).length() < radius
335
+ }
336
+
337
+ private fun getChunkPos (x : Int , z : Int , playerOffset : Vec2d , scale : Float ): Vec2d {
338
+ return Vec2d ((x shl 4 ).toDouble(), (z shl 4 ).toDouble()).minus(playerOffset).div(scale.toDouble())
339
+ }
340
+
287
341
private fun saveNewChunk (log : PrintWriter ? , data : String ) {
288
342
log!! .println (data)
289
343
}
0 commit comments