Skip to content

Commit 3911050

Browse files
committed
Show Max Beacon Range setting in RadiusESP
1 parent ea9c3fc commit 3911050

1 file changed

Lines changed: 28 additions & 11 deletions

File tree

  • src/main/kotlin/com/lambda/module/modules/render

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

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import com.lambda.util.math.setAlpha
3535
import com.lambda.util.world.toBlockPos
3636
import net.minecraft.block.Blocks
3737
import net.minecraft.block.entity.BeaconBlockEntity
38+
import net.minecraft.block.entity.BlockEntity
3839
import net.minecraft.util.math.Box
3940
import java.awt.Color
4041

@@ -48,6 +49,7 @@ object RadiusESP : Module(
4849
private const val OUTLINE_GROUP = "Outline"
4950

5051
private val beacons by setting("Beacons", true).onValueChange(::rebuildMesh)
52+
private val showMaxBeaconRange by setting("Show Max Beacon Range", true) { beacons }.onValueChange(::rebuildMesh)
5153
private val spawners by setting("Spawners", true).onValueChange(::rebuildMesh)
5254

5355
@Group(RENDER_GROUP) private val beaconColor by setting("Beacon Color", Color(0, 255, 255, 255)) { beacons }.onValueChange(::rebuildMesh)
@@ -87,23 +89,38 @@ object RadiusESP : Module(
8789
chunks.get(chunk)?.blockEntities?.values?.forEach { blockEntity ->
8890
val beacon = blockEntity as? BeaconBlockEntity ?: return@forEach
8991
val level = beacon.level
90-
val radius = (level * 10) + 10.0
91-
val box =
92-
Box(blockEntity.pos).expand(radius)
93-
.stretch(0.0, world.height.toDouble(), 0.0)
94-
renderBox(box, beaconColor)
92+
if (!showMaxBeaconRange) {
93+
withBeaconBox(blockEntity, level) { box ->
94+
renderBox(box, beaconColor)
95+
}
96+
return@runSafe
97+
}
98+
99+
withBeaconBox(blockEntity, 4) { box ->
100+
renderBox(box, beaconColor)
101+
}
95102
}
96103
}
97104
}
98105
}
99106
}
100107

101-
private fun RenderBuilder.renderBox(box: Box, color: Color) =
102-
box(box, worldLineConfig) {
103-
colors(color.setAlpha(fillAlpha), color)
104-
if (!fill) hideFill()
105-
if (!outline) hideOutline()
106-
}
108+
private fun SafeContext.withBeaconBox(blockEntity: BlockEntity, level: Int, block: (Box) -> Unit) {
109+
val radius = (level * 10) + 10.0
110+
val box =
111+
Box(blockEntity.pos).expand(radius)
112+
.stretch(0.0, world.height.toDouble(), 0.0)
113+
block(box)
114+
}
115+
116+
private fun RenderBuilder.renderBox(
117+
box: Box,
118+
color: Color
119+
) = box(box, worldLineConfig) {
120+
colors(color.setAlpha(fillAlpha), color)
121+
if (!fill) hideFill()
122+
if (!outline) hideOutline()
123+
}
107124

108125
private fun rebuildMesh(ctx: SafeContext, from: Any? = null, to: Any? = null): Unit = chunkedRenderer.rebuild()
109126
}

0 commit comments

Comments
 (0)