Skip to content

Commit 2cb074b

Browse files
committed
Transparency for block color extraction. Also made nether portals, end portals and enderchests have custom colors cuz they were all gray :(.
1 parent f529eaa commit 2cb074b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import com.lambda.module.tag.ModuleTag
2929
import com.lambda.threading.runSafe
3030
import com.lambda.util.extension.blockColor
3131
import com.lambda.util.extension.getBlockState
32+
import com.lambda.util.math.setAlpha
3233
import com.lambda.util.world.toBlockPos
3334
import net.minecraft.block.Blocks
3435
import net.minecraft.client.render.model.BlockStateModel
@@ -77,12 +78,13 @@ object BlockESP : Module(
7778

7879
runSafe {
7980
val extractedColor = blockColor(state, position.toBlockPos())
81+
val finalColor = Color(extractedColor.red, extractedColor.green, extractedColor.blue, faceColor.alpha)
8082
val pos = position.toBlockPos()
8183
val shape = state.getOutlineShape(world, pos)
8284
val worldBox = if (shape.isEmpty) Box(pos) else shape.boundingBox.offset(pos)
8385
box(worldBox) {
8486
if (drawFaces)
85-
filled(if (useBlockColor) extractedColor else faceColor, sides)
87+
filled(if (useBlockColor) finalColor else faceColor, sides)
8688
if (drawOutlines)
8789
outline(if (useBlockColor) extractedColor else BlockESP.outlineColor, sides, BlockESP.outlineMode)
8890
}

src/main/kotlin/com/lambda/util/extension/World.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,15 @@ fun SafeContext.collisionShape(state: BlockState, pos: BlockPos): VoxelShape =
5353
fun SafeContext.outlineShape(state: BlockState, pos: BlockPos) =
5454
state.getOutlineShape(world, pos).offset(pos)
5555

56-
fun SafeContext.blockColor(state: BlockState, pos: BlockPos) =
57-
Color(state.getMapColor(world, pos).color)
56+
fun SafeContext.blockColor(state: BlockState, pos: BlockPos): Color {
57+
return when (state.block) {
58+
Blocks.ENDER_CHEST -> Color(0xFF00FF)
59+
Blocks.NETHER_PORTAL -> Color(0xaa00aa)
60+
Blocks.END_PORTAL -> Color(0xFF00FF)
61+
else ->
62+
Color(state.getMapColor(world, pos).color, false)
63+
}
64+
}
5865

5966
fun World.getBlockState(x: Int, y: Int, z: Int): BlockState {
6067
if (isOutOfHeightLimit(y)) return Blocks.VOID_AIR.defaultState

0 commit comments

Comments
 (0)