Skip to content

Feature: LightLevels module#276

Merged
beanbag44 merged 9 commits into1.21.11from
feature/light-levels
Mar 23, 2026
Merged

Feature: LightLevels module#276
beanbag44 merged 9 commits into1.21.11from
feature/light-levels

Conversation

@beanbag44
Copy link
Member

adds renders to show when the light level gets below a given threshold on spawnable blocks. Has two modes; chunked and radius. Chunked will scan the entire loaded render distance, and radius will scan a smaller radius around the player

Copy link
Contributor

@IceTank IceTank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I eat sand

Comment on lines +52 to +57
.onValueChange { _, _ -> chunkedRenderer.clear(); refreshChunkedRenderer(this) }
private val minLightLevel by setting("Min Light Level", 0, 0..15).onValueChange(::refreshChunkedRenderer)
private val renderMode by setting("Render Mode", RenderMode.Square).onValueChange(::refreshChunkedRenderer)
private val color by setting("Color", Color.RED).onValueChange(::refreshChunkedRenderer)
private val size by setting("Size", 14, 1..16).onValueChange(::refreshChunkedRenderer)
private val fill by setting("Fill", false) { renderMode == RenderMode.Square }.group(Group.Fill).onValueChange(::refreshChunkedRenderer)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either put .onValueChange in a newline or not. You are doing both.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case is makes more sense to have them on the same line as it is the same onValueChange repeated for most of the render settings and is small. Unique onValueChange's should be put on a new line as they offer new logic which should be more visible and readable. This is why the onValueChange is on a new line for the mode setting

Radius
}

private enum class RenderMode {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe extend NamedEnum and Describable ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its too simple. Its clear that selecting Cross would render crosses, and likewise for the others

tickedRenderer("LightLevels Ticked Renderer", { depthTest }) {
if (mode != Mode.Radius) return@tickedRenderer
runSafe {
val playerPos = mc.gameRenderer.camera.pos.flooredBlockPos
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why flooredBlockPos? Why not more accurate with double values?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it makes no difference. If you add 8 to 1.9999 and then floor it, it gives you the same value as 8 + 1. This would only be somewhat worth it if our range settings werent whole integers, but theres not much point in that

// }
@Inject(method = "onLightUpdate", at = @At("RETURN"))
private void injectOnLightUpdate(LightType type, ChunkSectionPos pos, CallbackInfo ci) {
if (LightLevels.INSTANCE.isEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make an event?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its a pretty niche mixin; doubt any other modules would need it. If the time comes we can always change it

@beanbag44 beanbag44 merged commit 0d7f7d8 into 1.21.11 Mar 23, 2026
@github-project-automation github-project-automation bot moved this from Backlog to Done in Kanban Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants