Skip to content

Commit

Permalink
feat: add HoleESP
Browse files Browse the repository at this point in the history
  • Loading branch information
RemainingToast committed Jun 6, 2023
1 parent 9cae22d commit 15df3c6
Show file tree
Hide file tree
Showing 17 changed files with 311 additions and 81 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}"

implementation "com.github.QuantumClient:Energy:${project.events_version}"
implementation "com.google.guava:guava:${project.guava_version}"
/*include modImplementation("com.github.0x3C50:Renderer:${project.renderer_version}")*/
include modImplementation("com.github.QuantumClient:Energy:${project.events_version}")
include modImplementation("com.google.guava:guava:${project.guava_version}")
}

base {
Expand Down
4 changes: 3 additions & 1 deletion capes.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"3aeb9ab5-02d7-4848-9c83-d03152afcb91": "CONTRIBUTOR",
"a68b9c6e-1606-4b0c-934f-198300d77d2b": "CONTRIBUTOR"
"a68b9c6e-1606-4b0c-934f-198300d77d2b": "CONTRIBUTOR",
"bef61fae-6f08-4f54-8ed2-bb2d9e0a8386": "PLUS",
"1cfb5d19-4b07-4d62-8a4f-a049f6850a2a": "PLUS"
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ org.gradle.jvmargs=-Xmx1G

# Other Libraries
events_version=1.0
guava_version=30.1.1-jre
guava_version=30.1.1-jre
renderer_version=master-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ public class FontAccessor {
* To use the fontrenderer, use FontAccessor.fontRenderer.drawString(args);
*/
public static StringRenderer fontRenderer;

/*public static FontRenderer _fontRenderer;*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public class MixinTitleScreen {
@Mutable
@Shadow @Final private static Identifier EDITION_TITLE_TEXTURE;

private static final GLSLSandboxShader shader = new GLSLSandboxShader("/assets/toastclient/shaders/mandelbrot.vsh");

@Inject(
at = {@At("RETURN")},
method = {"render"}
Expand Down
14 changes: 11 additions & 3 deletions src/main/kotlin/dev/toastmc/toastclient/ToastClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package dev.toastmc.toastclient
import dev.toastmc.toastclient.api.config.ConfigUtil
import dev.toastmc.toastclient.api.managers.command.CommandManager
import dev.toastmc.toastclient.api.managers.module.ModuleManager
import dev.toastmc.toastclient.api.util.font.FontAccessor
import dev.toastmc.toastclient.api.util.font.StringRenderer
import dev.toastmc.toastclient.api.util.entity.CapeUtil
import net.fabricmc.api.ModInitializer
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents
Expand All @@ -22,7 +20,17 @@ open class ToastClient : ModInitializer, IToastClient {

logger.info("Started loading $nameVersion")

FontAccessor.fontRenderer = StringRenderer(18f, "/assets/toastclient/font/${FontAccessor.fontName}")
/*FontAccessor.fontRenderer = StringRenderer(18f, "/assets/toastclient/font/${FontAccessor.fontName}")*/

/*val font = Font.createFont(
Font.PLAIN,
javaClass.getResourceAsStream("/assets/toastclient/font/${FontAccessor.fontName}"),
)
FontAccessor._fontRenderer = FontRenderer(
arrayOf(font),
9f
)*/

ModuleManager.init()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ object ModuleManager : IToastClient {
Velocity,
/** Render **/
FullBright,
HoleESP,
NameTags,
NoFog,
NoRender,
Expand Down
8 changes: 6 additions & 2 deletions src/main/kotlin/dev/toastmc/toastclient/api/util/Commons.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.toastmc.toastclient.api.util

import dev.toastmc.toastclient.api.util.font.FontAccessor
import dev.toastmc.toastclient.impl.module.client.Font
import dev.toastmc.toastclient.mixin.client.IChatHud
import net.minecraft.client.MinecraftClient
Expand Down Expand Up @@ -32,6 +31,11 @@ fun capitalize(str: String): String {
}

fun getStringWidth(string: String): Int {
return if (Font.isEnabled()) FontAccessor.fontRenderer.getWidth(string)
return if (Font.isEnabled()) {
/*FontAccessor.fontRenderer.getWidth(string)*/

/*FontAccessor._fontRenderer.getStringWidth(string).toInt()*/
return 0
}
else mc.textRenderer.getWidth(string)
}
17 changes: 17 additions & 0 deletions src/main/kotlin/dev/toastmc/toastclient/api/util/WorldUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,18 @@ object WorldUtil {
return blocks
}

fun getCube(center: Vec3d, range: Int): List<BlockPos> {
val cube = mutableListOf<BlockPos>()
(-range..range).forEach { x ->
(-range..range).forEach { y ->
(-range..range).forEach { z ->
cube.add(center.blockPos.add(BlockPos(x, y, z)))
}
}
}
return cube
}

val BEDS = listOf(
Blocks.BLACK_BED,
Blocks.BLUE_BED,
Expand Down Expand Up @@ -545,6 +557,7 @@ object WorldUtil {
return true
}

// TODO: Double Holes
fun BlockPos.isHole(
airOnly: Boolean = false,
vararg acceptableBlocks: Block = arrayOf(Blocks.OBSIDIAN, Blocks.BEDROCK)
Expand All @@ -562,6 +575,10 @@ object WorldUtil {
) && this.isSurrounded(*acceptableBlocks)
}

fun World.getHoles(center: Vec3d, range: Int, airOnly: Boolean): List<BlockPos> {
return getCube(center, range).filter { it.isHole(airOnly) }.toList()
}

val BlockPos.isCrystalSpot: Boolean
get() = (this.block == Blocks.BEDROCK || this.block == Blocks.OBSIDIAN)
&& this.up().isAir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package dev.toastmc.toastclient.api.util.render

import com.mojang.blaze3d.systems.RenderSystem
import dev.toastmc.toastclient.api.util.ToastColor
import dev.toastmc.toastclient.api.util.asString
import dev.toastmc.toastclient.api.util.font.FontAccessor
import dev.toastmc.toastclient.api.util.mc
import dev.toastmc.toastclient.impl.module.client.Font
import net.minecraft.client.gui.DrawableHelper
Expand Down Expand Up @@ -46,13 +44,24 @@ interface DrawableExtensions {
matrices.scale(scale, scale, 1f)
startSmooth()
if (Font.isEnabled()) {
FontAccessor.fontRenderer.drawString(
/*FontAccessor.fontRenderer.drawString(
text.asString(),
(centerX - FontAccessor.fontRenderer.getWidth(text.asString()) / 2f),
(y + -FontAccessor.fontRenderer.getHeight(text.asString()) / 2f),
color.aBGRPackedInt,
true
)
)*/

/*FontAccessor._fontRenderer.drawString(
matrices,
text.asString(),
(centerX - FontAccessor._fontRenderer.getStringWidth(text.asString()) / 2f),
(y + - FontAccessor._fontRenderer.getStringHeight(text.asString()) / 2f),
color.red.toFloat(),
color.green.toFloat(),
color.blue.toFloat(),
color.alpha.toFloat()
)*/
} else {
matrices.translate((centerX / scale).toDouble(), ((y + mc.textRenderer.fontHeight / 2f) / scale).toDouble(), 0.0)
DrawableHelper.drawCenteredText(matrices, mc.textRenderer, text, 0, -mc.textRenderer.fontHeight / 2, color.aBGRPackedInt)
Expand Down Expand Up @@ -85,13 +94,24 @@ interface DrawableExtensions {
matrices.scale(scale, scale, 1f)
startSmooth()
if (Font.isEnabled()) {
FontAccessor.fontRenderer.drawString(
/*FontAccessor.fontRenderer.drawString(
text.asString(),
x.toFloat(),
(y + -FontAccessor.fontRenderer.getHeight(text.asString()) / 2f),
color.aBGRPackedInt,
true
)
)*/

/*FontAccessor._fontRenderer.drawString(
matrices,
text.asString(),
x.toFloat(),
(y + - FontAccessor._fontRenderer.getStringHeight(text.asString()) / 2f),
color.red.toFloat(),
color.green.toFloat(),
color.blue.toFloat(),
color.alpha.toFloat()
)*/
} else {
matrices.translate((x / scale).toDouble(), ((y + mc.textRenderer.fontHeight / 2f) / scale).toDouble(), z)
mc.textRenderer.drawWithShadow(matrices, text, 0f, -mc.textRenderer.fontHeight / 2f, color.aBGRPackedInt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,140 @@ interface RenderExtensions {
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z1).color(r, g, b, a).next()
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z1).color(r, g, b, a).next()
} else {
line(matrix, vertex, x1, y1, z1, x2, y1, z1, r, g, b, a)
line(matrix, vertex, x2, y1, z1, x2, y1, z2, r, g, b, a)
line(matrix, vertex, x2, y1, z2, x1, y1, z2, r, g, b, a)
line(matrix, vertex, x1, y1, z2, x1, y1, z1, r, g, b, a)

line(matrix, vertex, x1, y1, z1, x1, y2, z1, r, g, b, a)
line(matrix, vertex, x2, y1, z1, x2, y2, z1, r, g, b, 0f)
line(matrix, vertex, x2, y1, z1, x2, y2, z1, r, g, b, a)
line(matrix, vertex, x2, y1, z2, x2, y2, z2, r, g, b, 0f)
line(matrix, vertex, x2, y1, z2, x2, y2, z2, r, g, b, a)
line(matrix, vertex, x1, y1, z2, x1, y2, z2, r, g, b, 0f)
line(matrix, vertex, x1, y1, z2, x1, y2, z2, r, g, b, a)

line(matrix, vertex, x1, y2, z1, x2, y2, z1, r, g, b, a)
line(matrix, vertex, x2, y2, z1, x2, y2, z2, r, g, b, a)
line(matrix, vertex, x2, y2, z2, x1, y2, z2, r, g, b, a)
line(matrix, vertex, x1, y2, z2, x1, y2, z1, r, g, b, a)
// Bottom face
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z1).color(r, g, b, a).next() // Bottom left
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z1).color(r, g, b, a).next() // Bottom right
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z2).color(r, g, b, a).next() // Top right
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z2).color(r, g, b, a).next() // Top left

// Top face
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z2).color(r, g, b, a).next() // Top left
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z2).color(r, g, b, a).next() // Top right
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z1).color(r, g, b, a).next() // Bottom right
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z1).color(r, g, b, a).next() // Bottom left

// Front face
// vertex.vertex(matrix.peek().positionMatrix, x2, y1, z1).color(r, g, b, a).next() // Bottom right
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z1).color(r, g, b, a).next() // Top right
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z1).color(r, g, b, a).next() // Top left
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z1).color(r, g, b, a).next() // Bottom left

// Back face
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z2).color(r, g, b, a).next() // Bottom left
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z2).color(r, g, b, a).next() // Top left
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z2).color(r, g, b, a).next() // Top right
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z2).color(r, g, b, a).next() // Bottom right

// Right face
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z1).color(r, g, b, a).next() // Bottom front
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z1).color(r, g, b, a).next() // Top front
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z2).color(r, g, b, a).next() // Top back
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z2).color(r, g, b, a).next() // Bottom back

// Left face
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z2).color(r, g, b, a).next() // Bottom back
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z2).color(r, g, b, a).next() // Top back
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z1).color(r, g, b, a).next() // Top front
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z1).color(r, g, b, a).next() // Bottom front
}
}

fun hollowBox(
matrix: MatrixStack,
vertex: VertexConsumer,
box: Box,
filled: Boolean,
r: Float,
g: Float,
b: Float,
a: Float,
) {
val x1 = box.minX.toFloat()
val y1 = box.minY.toFloat()
val z1 = box.minZ.toFloat()
val x2 = box.maxX.toFloat()
val y2 = box.maxY.toFloat()
val z2 = box.maxZ.toFloat()

if (filled) {
// Bottom face
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z1).color(r, g, b, a).next() // Bottom left
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z2).color(r, g, b, a).next() // Top left
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z2).color(r, g, b, a).next() // Top right
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z1).color(r, g, b, a).next() // Bottom right

// Top face
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z1).color(r, g, b, a).next() // Bottom left
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z1).color(r, g, b, a).next() // Bottom right
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z2).color(r, g, b, a).next() // Top right
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z2).color(r, g, b, a).next() // Top left

// Front face
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z1).color(r, g, b, a).next() // Bottom left
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z1).color(r, g, b, a).next() // Top left
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z1).color(r, g, b, a).next() // Top right
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z1).color(r, g, b, a).next() // Bottom right

// Back face
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z2).color(r, g, b, a).next() // Bottom right
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z2).color(r, g, b, a).next() // Top right
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z2).color(r, g, b, a).next() // Top left
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z2).color(r, g, b, a).next() // Bottom left

// Right face
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z1).color(r, g, b, a).next() // Bottom front
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z1).color(r, g, b, a).next() // Top front
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z2).color(r, g, b, a).next() // Top back
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z2).color(r, g, b, a).next() // Bottom back

// Left face
// vertex.vertex(matrix.peek().positionMatrix, x1, y1, z2).color(r, g, b, a).next() // Bottom back
// vertex.vertex(matrix.peek().positionMatrix, x1, y2, z2).color(r, g, b, a).next() // Top back
// vertex.vertex(matrix.peek().positionMatrix, x1, y2, z1).color(r, g, b, a).next() // Top front
// vertex.vertex(matrix.peek().positionMatrix, x1, y1, z1).color(r, g, b, a).next() // Bottom front
} else {
// ...
// Same code for drawing the outlines of the box as before
// ... TODO: Abstract
// Bottom face
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z1).color(r, g, b, a).next() // Bottom left
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z1).color(r, g, b, a).next() // Bottom right
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z2).color(r, g, b, a).next() // Top right
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z2).color(r, g, b, a).next() // Top left

// Top face
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z2).color(r, g, b, a).next() // Top left
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z2).color(r, g, b, a).next() // Top right
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z1).color(r, g, b, a).next() // Bottom right
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z1).color(r, g, b, a).next() // Bottom left

// Front face
// vertex.vertex(matrix.peek().positionMatrix, x2, y1, z1).color(r, g, b, a).next() // Bottom right
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z1).color(r, g, b, a).next() // Top right
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z1).color(r, g, b, a).next() // Top left
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z1).color(r, g, b, a).next() // Bottom left

// Back face
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z2).color(r, g, b, a).next() // Bottom left
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z2).color(r, g, b, a).next() // Top left
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z2).color(r, g, b, a).next() // Top right
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z2).color(r, g, b, a).next() // Bottom right

// Right face
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z1).color(r, g, b, a).next() // Bottom front
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z1).color(r, g, b, a).next() // Top front
vertex.vertex(matrix.peek().positionMatrix, x2, y2, z2).color(r, g, b, a).next() // Top back
vertex.vertex(matrix.peek().positionMatrix, x2, y1, z2).color(r, g, b, a).next() // Bottom back

// Left face
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z2).color(r, g, b, a).next() // Bottom back
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z2).color(r, g, b, a).next() // Top back
vertex.vertex(matrix.peek().positionMatrix, x1, y2, z1).color(r, g, b, a).next() // Top front
vertex.vertex(matrix.peek().positionMatrix, x1, y1, z1).color(r, g, b, a).next() // Bottom front
}
}


fun line(
matrix: MatrixStack,
vertexConsumer: VertexConsumer,
Expand Down
Loading

0 comments on commit 15df3c6

Please sign in to comment.