Skip to content

Commit 374e84c

Browse files
committed
modify chunk border debug rendering to render around the freecam position if enabled
1 parent 1466a22 commit 374e84c

3 files changed

Lines changed: 46 additions & 9 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2026 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.mixin.render;
19+
20+
import com.lambda.Lambda;
21+
import com.lambda.module.modules.render.Freecam;
22+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
23+
import net.minecraft.client.render.debug.ChunkBorderDebugRenderer;
24+
import net.minecraft.util.math.ChunkSectionPos;
25+
import org.spongepowered.asm.mixin.Mixin;
26+
import org.spongepowered.asm.mixin.injection.At;
27+
28+
@Mixin(ChunkBorderDebugRenderer.class)
29+
public class ChunkBorderDebugRendererMixin {
30+
@ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/ChunkSectionPos;from(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/math/ChunkSectionPos;"))
31+
private ChunkSectionPos modifyChunkSectionPos(ChunkSectionPos original) {
32+
if (Freecam.INSTANCE.isDisabled()) return original;
33+
var camera = Lambda.getMc().gameRenderer.getCamera();
34+
return ChunkSectionPos.from(camera.getBlockPos());
35+
}
36+
}

src/main/kotlin/com/lambda/module/modules/render/Freecam.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@ object Freecam : Module(
230230
}
231231
}
232232

233+
private fun SafeContext.findFollowTarget(): PlayerEntity? {
234+
if (player.gameMode != GameMode.SPECTATOR) {
235+
return player
236+
}
237+
val players = world.players.filter { it !is ClientPlayerEntity }
238+
return players.minByOrNull { it.eyePos.squaredDistanceTo(position) }
239+
}
240+
233241
private enum class FreecamRotationMode(override val displayName: String, override val description: String) : NamedEnum, Describable {
234242
None("None", "No rotation changes"),
235243
LookAtTarget("Look At Target", "Look at the block or entity under your crosshair"),
@@ -240,12 +248,4 @@ object Freecam : Module(
240248
Free("Free", "Move the camera freely with keyboard input"),
241249
FollowPlayer("Follow Player", "Camera follows a player as if attached by an invisible string");
242250
}
243-
244-
private fun SafeContext.findFollowTarget(): PlayerEntity? {
245-
if (player.gameMode != GameMode.SPECTATOR) {
246-
return player
247-
}
248-
val players = world.players.filter { it !is ClientPlayerEntity }
249-
return players.minByOrNull { it.eyePos.squaredDistanceTo(position) }
250-
}
251251
}

src/main/resources/lambda.mixins.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"CrashReportMixin",
88
"MinecraftClientMixin",
99
"baritone.BaritonePlayerContextMixin",
10-
"baritone.LookBehaviourMixin",
1110
"baritone.ComeCommandMixin",
11+
"baritone.LookBehaviourMixin",
1212
"client.sound.SoundSystemMixin",
1313
"entity.ClientPlayerEntityMixin",
1414
"entity.ClientPlayInteractionManagerMixin",
@@ -41,6 +41,7 @@
4141
"render.ChatHudMixin",
4242
"render.ChatInputSuggestorMixin",
4343
"render.ChatScreenMixin",
44+
"render.ChunkBorderDebugRendererMixin",
4445
"render.ChunkOcclusionDataBuilderMixin",
4546
"render.DrawContextMixin",
4647
"render.ElytraFeatureRendererMixin",

0 commit comments

Comments
 (0)