-
-
Notifications
You must be signed in to change notification settings - Fork 513
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
feat: VoidESP #5199
Changes from 1 commit
7b9ea67
349399a
8236660
91e7e45
8989f70
144a2f9
d609090
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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() | ||
|
||
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() | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't do that. Look in BlockESP how it's done. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That is not the problem. You scan the region around the player every tick. This is inefficient. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I didn't realize that you meant that, sorry. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But in my profiler this doesn't spend long time to check. The HoleESP-like scanning might make the code more complicated |
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix naming please