Skip to content

Commit 55b9743

Browse files
committed
Merge branch 'master' into syncedPlayerInventoryManager
2 parents 09693ed + 1142bd0 commit 55b9743

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ forgeVersion=14.23.5.2860
1010
mappingsChannel=stable
1111
mappingsVersion=39-1.12
1212

13-
kotlinVersion=1.6.20
13+
kotlinVersion=1.6.21
1414
kotlinxCoroutinesVersion=1.6.1

src/main/kotlin/com/lambda/client/module/modules/movement/NoSlowDown.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.lambda.client.event.events.PacketEvent
55
import com.lambda.client.module.Category
66
import com.lambda.client.module.Module
77
import com.lambda.client.util.EntityUtils.flooredPosition
8+
import com.lambda.client.util.MovementUtils.isMoving
89
import com.lambda.client.util.threads.safeListener
910
import com.lambda.mixin.world.MixinBlockSoulSand
1011
import com.lambda.mixin.world.MixinBlockWeb
@@ -41,6 +42,9 @@ object NoSlowDown : Module(
4142
private val shield by setting("Shield", true, { !allItems })
4243

4344
private var savedClickWindow = CPacketClickWindow()
45+
46+
private const val upSpoofDistance = 0.0656
47+
4448
/*
4549
* InputUpdateEvent is called just before the player is slowed down @see EntityPlayerSP.onLivingUpdate)
4650
* We'll abuse this fact, and multiply moveStrafe and moveForward by 5 to nullify the *0.2f hardcoded by Mojang.
@@ -60,6 +64,8 @@ object NoSlowDown : Module(
6064
&& player.onGround
6165
&& it.packet is CPacketClickWindow
6266
&& it.packet != savedClickWindow
67+
&& player.isMoving
68+
&& world.getCollisionBoxes(player, player.entityBoundingBox.offset(0.0, upSpoofDistance, 0.0)).isEmpty()
6369
) {
6470
savedClickWindow = it.packet
6571

@@ -69,7 +75,7 @@ object NoSlowDown : Module(
6975
player.connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SPRINTING))
7076
}
7177

72-
player.connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + 0.0626, player.posZ, false))
78+
player.connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + upSpoofDistance, player.posZ, false))
7379
player.connection.sendPacket(it.packet)
7480

7581
if (player.isSprinting) {

src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ package com.lambda.client.module.modules.render
33
import com.lambda.client.LambdaMod
44
import com.lambda.client.event.SafeClientEvent
55
import com.lambda.client.event.events.PacketEvent
6+
import com.lambda.client.event.events.RenderRadarEvent
67
import com.lambda.client.event.events.RenderWorldEvent
78
import com.lambda.client.module.Category
89
import com.lambda.client.module.Module
10+
import com.lambda.client.util.BaritoneUtils
911
import com.lambda.client.util.EntityUtils.getInterpolatedPos
1012
import com.lambda.client.util.FolderUtils
1113
import com.lambda.client.util.TickTimer
1214
import com.lambda.client.util.TimeUnit
1315
import com.lambda.client.util.color.ColorHolder
1416
import com.lambda.client.util.graphics.GlStateUtils
1517
import com.lambda.client.util.graphics.LambdaTessellator
18+
import com.lambda.client.util.graphics.RenderUtils2D
19+
import com.lambda.client.util.math.Vec2d
1620
import com.lambda.client.util.text.MessageSendHelper
1721
import com.lambda.client.util.threads.safeListener
1822
import com.lambda.client.util.math.VectorUtils.distanceTo
@@ -43,6 +47,9 @@ object NewChunks : Module(
4347
) {
4448
private val relative by setting("Relative", false, description = "Renders the chunks at relative Y level to player")
4549
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 })
4653
private val saveNewChunks by setting("Save New Chunks", false)
4754
private val saveOption by setting("Save Option", SaveOption.EXTRA_FOLDER, { saveNewChunks })
4855
private val saveInRegionFolder by setting("In Region", false, { saveNewChunks })
@@ -106,6 +113,42 @@ object NewChunks : Module(
106113
GlStateUtils.depth(true)
107114
}
108115

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+
109152
safeListener<PacketEvent.PostReceive> { event ->
110153
if (event.packet is SPacketChunkData
111154
&& !event.packet.isFullChunk
@@ -284,6 +327,17 @@ object NewChunks : Module(
284327
return ending.toIntOrNull() != null
285328
}
286329

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+
287341
private fun saveNewChunk(log: PrintWriter?, data: String) {
288342
log!!.println(data)
289343
}

0 commit comments

Comments
 (0)