Skip to content

Commit

Permalink
Updated to Fabric 1.20.6, added HoleESP
Browse files Browse the repository at this point in the history
  • Loading branch information
ya-ilya committed Jun 2, 2024
1 parent c354b91 commit 423eaeb
Show file tree
Hide file tree
Showing 21 changed files with 170 additions and 70 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
plugins {
kotlin("jvm") apply false
id("fabric-loom") apply false
}
19 changes: 9 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ org.gradle.caching=true

# kotlin
kotlin.code.style=official
kotlin.experimental.tryK2=true
kotlinVersion=1.9.10
kotlinVersion=2.0.0

# progreso
progresoVersion=0.3

# fabric
minecraftVersion=1.20.4
fabricVersion=0.96.11+1.20.4
fabricLoomVersion=1.5-SNAPSHOT
yarnMappings=1.20.4+build.3
loaderVersion=0.15.7
minecraftVersion=1.20.6
fabricVersion=0.99.4+1.20.6
fabricLoomVersion=1.6-SNAPSHOT
yarnMappings=1.20.6+build.3
loaderVersion=0.15.11

# other
gsonVersion=2.10.1
websocketVersion=1.5.3
gsonVersion=2.11.0
websocketVersion=1.5.6
reflectionsVersion=0.10.2
brigadierVersion=1.1.8
brigadierVersion=1.2.9
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ class SettingArgumentType : ArgumentType<String> {
builder: SuggestionsBuilder
): CompletableFuture<Suggestions> {
return Api.COMMAND.suggestMatching(
try { getSettingPaths(ModuleArgumentType[context]) } catch (ex: Exception) { emptyList() },
try {
getSettingPaths(ModuleArgumentType[context])
} catch (ex: Exception) {
emptyList()
},
builder
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ abstract class AbstractWidgetBuilder<Context, Widget> {
listeners.init = block
}

fun render(block: Widget.(Context, Int, Int) -> Unit) {
fun render(block: Widget.(Context, Int, Int, Float) -> Unit) {
listeners.render = block
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.progreso.api.gui.data

data class BuilderListeners<Context, Widget>(
var init: Widget.() -> Unit = { },
var render: Widget.(Context, Int, Int) -> Unit = { _, _, _ -> },
var render: Widget.(Context, Int, Int, Float) -> Unit = { _, _, _, _ -> },
var mouseClicked: Widget.(Int, Int, Int) -> Unit = { _, _, _ -> },
var mouseReleased: Widget.(Int, Int, Int) -> Unit = { _, _, _ -> }
)
6 changes: 3 additions & 3 deletions progreso-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ group = "org.progreso"
version = progresoVersion

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

base {
Expand Down Expand Up @@ -89,7 +89,7 @@ tasks {
}

withType<JavaCompile>().configureEach {
options.release.set(17)
options.release.set(21)
}

shadowJar {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.progreso.client.mixins.render;

import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import org.joml.Matrix4f;
import org.objectweb.asm.Opcodes;
import org.progreso.client.Client;
import org.progreso.client.events.render.Render3DEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(GameRenderer.class)
public abstract class MixinGameRenderer {
@Inject(
method = "renderWorld(FJ)V",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/client/render/GameRenderer;renderHand:Z",
opcode = Opcodes.GETFIELD,
ordinal = 0
)
)
public void renderWorldHook(
float tickDelta,
long limitTime,
CallbackInfo ci,
@Local(ordinal = 1) Matrix4f matrix4f2
) {
Client.getMc().getClient().getProfiler().push("progreso_render");
MatrixStack matrixStack = new MatrixStack();
matrixStack.multiplyPositionMatrix(matrix4f2);
Client.EVENT_BUS.post(new Render3DEvent(matrixStack, tickDelta));
Client.getMc().getClient().getProfiler().pop();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.progreso.client.util.render.createTextRendererFromProgresoResource
import java.awt.Color

fun createDefaultTextRenderer(): TextRenderer {
return createTextRenderer("vitala", 11f)!!
return createTextRenderer("vitala", 9f)!!
}

var customTextRenderer = run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ButtonBuilder : AbstractButtonBuilder<DrawContext, ButtonWidget>() {
}

override fun renderWidget(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
listeners.render(this, context, mouseX, mouseY)
listeners.render(this, context, mouseX, mouseY, delta)

super.renderWidget(context, mouseX, mouseY, delta)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ElementListBuilder<E : ElementListWidget.Entry<E>>
return this@ElementListBuilder.itemWidth
}

override fun getScrollbarPositionX(): Int {
override fun getScrollbarX(): Int {
return x + width - 6
}

Expand All @@ -51,7 +51,7 @@ class ElementListBuilder<E : ElementListWidget.Entry<E>>
}

override fun renderWidget(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
listeners.render(this, context, mouseX, mouseY)
listeners.render(this, context, mouseX, mouseY, delta)

super.renderWidget(context, mouseX, mouseY, delta)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ScreenBuilder : AbstractScreenBuilder<DrawContext, Screen>() {
}

override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
listeners.render(this, context, mouseX, mouseY)
listeners.render(this, context, mouseX, mouseY, delta)

super.render(context, mouseX, mouseY, delta)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TextFieldBuilder : AbstractTextFieldBuilder<DrawContext, TextFieldWidget>(
}

override fun renderWidget(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
listeners.render(this, context, mouseX, mouseY)
listeners.render(this, context, mouseX, mouseY, delta)

super.renderWidget(context, mouseX, mouseY, delta)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class ProgresoAltsScreen(private val alts: Set<AltAccount>) : TitledScreen(i18n
thread.interrupt()
}

render { context, _, _ ->
render { context, mouseX, mouseY, delta ->
if (result.set) {
val (status, account) = result.pair ?: return@render close()

Expand All @@ -166,7 +166,7 @@ class ProgresoAltsScreen(private val alts: Set<AltAccount>) : TitledScreen(i18n

val text = i18n("gui.alts.label.add_microsoft_alt_link")

renderBackgroundTexture(context)
renderBackground(context, mouseX, mouseY, delta)
context.drawText(
textRenderer,
text,
Expand All @@ -189,8 +189,8 @@ class ProgresoAltsScreen(private val alts: Set<AltAccount>) : TitledScreen(i18n
}
}

render { context, _, _ ->
renderBackgroundTexture(context)
render { context, mouseX, mouseY, delta ->
renderBackground(context, mouseX, mouseY, delta)
context.drawText(
textRenderer,
errorI18n,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ProgresoPluginsScreen(private val plugins: Set<AbstractPlugin>) : TitledSc
)

var lastSelected: AbstractPlugin? = null
list.render { _, _, _ ->
list.render { _, _, _, _ ->
if (selectedPlugin != lastSelected) {
lastSelected = selectedPlugin
children().clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ open class TitledScreen(title: String) : Screen(Text.of(title)) {
constructor(title: String = "", i18n: String) : this(i18n(i18n))

override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
renderBackgroundTexture(context)
renderBackground(context, mouseX, mouseY, delta)
super.render(context, mouseX, mouseY, delta)
context.drawText(
textRenderer,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.progreso.client.modules.render

import net.minecraft.block.Blocks
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Box
import net.minecraft.util.math.Direction
import org.progreso.api.module.AbstractModule
import org.progreso.client.Client.Companion.mc
import org.progreso.client.events.misc.TickEvent
import org.progreso.client.events.render.Render3DEvent
import org.progreso.client.events.safeEventListener
import org.progreso.client.gui.clickgui.element.elements.ColorElement.Companion.copy
import org.progreso.client.util.render.*
import org.progreso.client.util.world.getBlocksInRadius
import java.awt.Color

@AbstractModule.AutoRegister
object HoleESP : AbstractModule() {
private val DEFAULT_BOX = Box(0.0, 0.0, 0.0, 1.0, 1.0, 1.0)

private val radius by setting("Radius", 5, 3..25)
private val color by setting("Color", Color.RED)

private val holeDirections = Direction.entries.filter { it != Direction.UP }
private val holes = mutableListOf<BlockPos>()

init {
safeEventListener<TickEvent> {
holes.clear()

for (pos in mc.world.getBlocksInRadius(radius, mc.player.blockPos)) {
if (isHole(pos)) {
holes.add(pos)
}
}
}

safeEventListener<Render3DEvent> { event ->
for (pos in holes) {
render3D(event.matrices) {
withPosition(pos) {
withColor(color.copy(50)) {
drawSolidBox(DEFAULT_BOX)
}

withColor(color.copy(100)) {
drawOutlinedBox(DEFAULT_BOX)
}
}
}
}
}
}

private fun isHole(pos: BlockPos): Boolean {
if (!isAir(pos)) return false
if (!holeDirections.map { pos.offset(it) }.all { isObsidianOrBedrock(it) }) return false
if (!isAir(pos.offset(Direction.UP))) return false
return true
}

private fun isAir(pos: BlockPos): Boolean {
return mc.world.getBlockState(pos).block == Blocks.AIR
}

private fun isObsidianOrBedrock(pos: BlockPos): Boolean {
return mc.world.getBlockState(pos).block.let { it == Blocks.OBSIDIAN || it == Blocks.BEDROCK }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package org.progreso.client.util.render

import com.mojang.blaze3d.platform.GlStateManager
import com.mojang.blaze3d.systems.RenderSystem
import net.minecraft.client.font.FontStorage
import net.minecraft.client.font.TextRenderer
import net.minecraft.client.font.TrueTypeFontLoader
import net.minecraft.client.font.*
import net.minecraft.client.gui.DrawContext
import net.minecraft.client.render.GameRenderer
import net.minecraft.client.render.Tessellator
Expand Down Expand Up @@ -90,7 +88,10 @@ fun createTextRenderer(

if (font.isPresent) {
val fontStorage = FontStorage(Client.mc.client.textureManager, Identifier("progreso"))
fontStorage.setFonts(listOf(font.get().load(resourceManager)))
fontStorage.setFonts(
listOf(Font.FontFilterPair(font.get().load(resourceManager), FontFilterType.FilterMap.NO_FILTER)),
emptySet()
)
return TextRenderer({ fontStorage }, false)
}

Expand Down
Loading

0 comments on commit 423eaeb

Please sign in to comment.