Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: VoidESP #5199

Merged
merged 7 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ object ModuleManager : EventListener, Iterable<ClientModule> by modules {
ModuleTracers,
ModuleTrajectories,
ModuleTrueSight,
ModuleVoidESP,
ModuleXRay,
ModuleDebug,
ModuleZoom,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/*
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
*
* Copyright (c) 2015 - 2025 CCBlueX
*
* LiquidBounce is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiquidBounce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
*/
package net.ccbluex.liquidbounce.features.module.modules.render

import it.unimi.dsi.fastutil.longs.LongOpenHashSet
import it.unimi.dsi.fastutil.longs.LongSet
import net.ccbluex.liquidbounce.event.events.PlayerTickEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.ClientModule
import net.ccbluex.liquidbounce.render.engine.Color4b
import net.ccbluex.liquidbounce.utils.block.Region
import net.ccbluex.liquidbounce.utils.render.placement.PlacementRenderer
import net.minecraft.block.SideShapeType
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.world.chunk.Chunk

/**
* VoidESP module
*
* Highlight all surrounding positions that may be void.
*
* @author MukjepScarlet
*/

object ModuleVoidESP : ClientModule("VoidESP", Category.RENDER) {

override val baseKey: String
get() = "liquidbounce.module.voidEsp"

private val yThreshold by int("YThreshold", 16, 3..32)
private val rangeSide by int("RangeSide", 3, 0..32)
private val rangeFacing by int("RangeFacing", 8, 1..32)

private val renderer = tree(
PlacementRenderer("Render", true, this, keep = true,
defaultColor = Color4b(255, 0, 0, 90)
)
)

private var lastTickPositions: LongSet = LongSet.of()

override fun disable() {
lastTickPositions = LongSet.of()
renderer.clearSilently()
}

private val mutable = BlockPos.Mutable()
private val mutable1 = BlockPos.Mutable()
Copy link
Contributor

Choose a reason for hiding this comment

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

fix naming please


private fun Chunk.canBlockStandOn(pos: BlockPos): Boolean {
return this.getBlockState(pos).isSideSolid(this, pos, Direction.UP, SideShapeType.CENTER)
}

/**
* Search positions around.
*/
private fun search(): LongSet {
val positions = LongOpenHashSet()

// Find the first place where the player can stand
val startPos = mutable1.set(player.blockPos, Direction.DOWN)
var chunk = world.getChunk(startPos)
var flag = false
for (i in 0 until yThreshold) {
if (chunk.canBlockStandOn(startPos)) {
flag = true
break
}
startPos.y--
}

if (!flag) {
return LongSet.of()
}

val facing = player.horizontalFacing
val side = facing.rotateYClockwise()

val from = mutable.set(startPos)
.move(facing, rangeFacing).move(side.opposite, rangeSide)
val to = mutable1.set(startPos)
.move(facing.opposite, rangeFacing).move(side, rangeSide)

Region(from, to).forEach {
chunk = world.getChunk(it)

if (chunk.canBlockStandOn(it)) {
return@forEach
}

mutable.set(it)

repeat(yThreshold) { _ ->
mutable.y--

if (chunk.canBlockStandOn(mutable)) {
return@forEach
}

if (mutable.y <= chunk.bottomY) {
positions.add(it.asLong())
return@forEach
}
}

positions.add(it.asLong())
}

return positions
}

private val tickHandler = handler<PlayerTickEvent> {
val positions = search()

// Invalidate last tick positions
with(lastTickPositions.longIterator()) {
while (hasNext()) {
val longValue = nextLong()
if (longValue !in positions) {
renderer.removeBlock(mutable.set(longValue))
}
}
}

// Add this tick positions
with(positions.longIterator()) {
while (hasNext()) {
val longValue = nextLong()
renderer.addBlock(mutable.set(longValue))
}
}

lastTickPositions = positions

// Update cull data
renderer.updateAll()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't do that. Look in BlockESP how it's done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The BlockESP does not have animations for changes, so I asked @ccetl about how to use the PlacementRenderer

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't do that. Look in BlockESP how it's done.

BlockESP doesn't have animations nor culling which is especially important if the blocks disappear / appear in a short distance. But to some degree i agree, you don't have to introduce a separate list here as the renderer has in/current lists already. But IMO it's fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

The BlockESP does not have animations for changes, so I asked @ccetl about how to use the PlacementRenderer

That is not the problem. You scan the region around the player every tick. This is inefficient.

Copy link
Contributor

@ccetl ccetl Jan 6, 2025

Choose a reason for hiding this comment

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

Ah I didn't realize that you meant that, sorry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The BlockESP does not have animations for changes, so I asked @ccetl about how to use the PlacementRenderer

That is not the problem. You scan the region around the player every tick. This is inefficient.

But in my profiler this doesn't spend long time to check. The HoleESP-like scanning might make the code more complicated


}
1 change: 1 addition & 0 deletions src/main/resources/resources/liquidbounce/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@
"liquidbounce.module.vehicleBoost.description": "Boost you when leaving a vehicle.",
"liquidbounce.module.vehicleOneHit.description": "Allows you to break any vehicle with a single hit.",
"liquidbounce.module.velocity.description": "Modifies the amount of velocity you take.",
"liquidbounce.module.voidEsp.description": "Highlight all surrounding positions that may be void.",
"liquidbounce.module.xRay.description": "Only renders selected blocks.",
"liquidbounce.module.zoom.description": "Allows you to make everything in your world appear smaller or bigger.",
"liquidbounce.module.antiHunger.description": "Prevents you from getting hungry.",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/resources/liquidbounce/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@
"liquidbounce.module.vehicleBoost.description": "在你离开载具时将你加速。",
"liquidbounce.module.vehicleOneHit.description": "允许你一击打掉船/矿车。",
"liquidbounce.module.velocity.description": "改变你在受击时的击退程度。",
"liquidbounce.module.voidEsp.description": "高亮显示周围所有可能为虚空的位置。",
"liquidbounce.module.xRay.description": "仅渲染选定的方块。",
"liquidbounce.module.zoom.description": "允许你以更大或更小的视角看世界上的一切。",
"liquidbounce.module.antiHunger.description": "防止你饥饿。",
Expand Down
Loading