Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
oh
Browse files Browse the repository at this point in the history
  • Loading branch information
homchom committed Feb 17, 2024
1 parent f596507 commit 05aa5b5
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/main/java/io/github/homchom/recode/feature/visual/CodeSearch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import io.github.homchom.recode.hypercube.state.isInMode
import io.github.homchom.recode.mc
import io.github.homchom.recode.mod.features.commands.CodeSearcher
import io.github.homchom.recode.render.OutlineBlockEntitiesEvent
import io.github.homchom.recode.render.rgba
import io.github.homchom.recode.render.RGBA
import net.minecraft.world.level.block.entity.SignBlockEntity
import kotlin.math.sqrt

Expand All @@ -20,17 +20,15 @@ object FCodeSearch {
}
}

private fun Power.outlineBlockEntities() {
listenEach(OutlineBlockEntitiesEvent) { context ->
if (!currentDFState.isInMode(PlotMode.Dev)) return@listenEach
for (element in context) {
val blockEntity = element.blockEntity
if (blockEntity is SignBlockEntity && CodeSearcher.isSignMatch(blockEntity)) {
val distance = sqrt(blockEntity.getBlockPos().distSqr(mc.cameraEntity!!.blockPosition()))
// TODO: test if alpha actually makes a difference
val alpha = (distance.coerceIn(1.0, 15.0) * 17).toInt()
element.outlineColor = rgba(255, 255, 255, alpha)
}
private fun Power.outlineBlockEntities() = listenEach(OutlineBlockEntitiesEvent) { context ->
if (!currentDFState.isInMode(PlotMode.Dev)) return@listenEach
for (element in context) {
val blockEntity = element.blockEntity
if (blockEntity is SignBlockEntity && CodeSearcher.isSignMatch(blockEntity)) {
val distance = sqrt(blockEntity.getBlockPos().distSqr(mc.cameraEntity!!.blockPosition()))
// TODO: test if alpha actually makes a difference
val alpha = (distance.coerceIn(1.0, 15.0) * 17).toInt()
element.outlineColor = RGBA(255, 255, 255, alpha)
}
}
}
Expand Down

0 comments on commit 05aa5b5

Please sign in to comment.