From 423eaeb31fd73bea8d4766704c4aaee755de97c1 Mon Sep 17 00:00:00 2001 From: ya-ilya Date: Sun, 2 Jun 2024 13:06:15 +0300 Subject: [PATCH] Updated to Fabric 1.20.6, added HoleESP --- build.gradle.kts | 1 + gradle.properties | 19 +++-- gradle/wrapper/gradle-wrapper.properties | 2 +- .../command/arguments/SettingArgumentType.kt | 6 +- .../progreso/api/gui/AbstractWidgetBuilder.kt | 2 +- .../progreso/api/gui/data/BuilderListeners.kt | 2 +- progreso-client/build.gradle.kts | 6 +- .../mixins/render/MixinGameRenderer.java | 38 ++++++++++ .../mixins/render/MixinWorldRenderer.java | 35 ---------- .../org/progreso/client/gui/Extensions.kt | 2 +- .../client/gui/builders/ButtonBuilder.kt | 2 +- .../client/gui/builders/ElementListBuilder.kt | 4 +- .../client/gui/builders/ScreenBuilder.kt | 2 +- .../client/gui/builders/TextFieldBuilder.kt | 2 +- .../gui/minecraft/ProgresoAltsScreen.kt | 8 +-- .../gui/minecraft/ProgresoPluginsScreen.kt | 2 +- .../gui/minecraft/common/TitledScreen.kt | 2 +- .../progreso/client/modules/render/HoleESP.kt | 69 +++++++++++++++++++ .../progreso/client/util/render/Render2D.kt | 9 +-- .../org/progreso/client/util/world/World.kt | 25 ++++++- .../src/main/resources/progreso.mixins.json | 2 +- 21 files changed, 170 insertions(+), 70 deletions(-) create mode 100644 progreso-client/src/main/java/org/progreso/client/mixins/render/MixinGameRenderer.java delete mode 100644 progreso-client/src/main/java/org/progreso/client/mixins/render/MixinWorldRenderer.java create mode 100644 progreso-client/src/main/kotlin/org/progreso/client/modules/render/HoleESP.kt diff --git a/build.gradle.kts b/build.gradle.kts index 5d01732..18887b7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,4 @@ plugins { kotlin("jvm") apply false + id("fabric-loom") apply false } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index ad62f69..4e3fdfe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 \ No newline at end of file +brigadierVersion=1.2.9 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index acb2526..e2eec53 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 \ No newline at end of file diff --git a/progreso-api/src/main/kotlin/org/progreso/api/command/arguments/SettingArgumentType.kt b/progreso-api/src/main/kotlin/org/progreso/api/command/arguments/SettingArgumentType.kt index 6a40574..5a4abe2 100644 --- a/progreso-api/src/main/kotlin/org/progreso/api/command/arguments/SettingArgumentType.kt +++ b/progreso-api/src/main/kotlin/org/progreso/api/command/arguments/SettingArgumentType.kt @@ -71,7 +71,11 @@ class SettingArgumentType : ArgumentType { builder: SuggestionsBuilder ): CompletableFuture { return Api.COMMAND.suggestMatching( - try { getSettingPaths(ModuleArgumentType[context]) } catch (ex: Exception) { emptyList() }, + try { + getSettingPaths(ModuleArgumentType[context]) + } catch (ex: Exception) { + emptyList() + }, builder ) } diff --git a/progreso-api/src/main/kotlin/org/progreso/api/gui/AbstractWidgetBuilder.kt b/progreso-api/src/main/kotlin/org/progreso/api/gui/AbstractWidgetBuilder.kt index bb91ac0..13ffccc 100644 --- a/progreso-api/src/main/kotlin/org/progreso/api/gui/AbstractWidgetBuilder.kt +++ b/progreso-api/src/main/kotlin/org/progreso/api/gui/AbstractWidgetBuilder.kt @@ -21,7 +21,7 @@ abstract class AbstractWidgetBuilder { listeners.init = block } - fun render(block: Widget.(Context, Int, Int) -> Unit) { + fun render(block: Widget.(Context, Int, Int, Float) -> Unit) { listeners.render = block } diff --git a/progreso-api/src/main/kotlin/org/progreso/api/gui/data/BuilderListeners.kt b/progreso-api/src/main/kotlin/org/progreso/api/gui/data/BuilderListeners.kt index e128586..5adfec4 100644 --- a/progreso-api/src/main/kotlin/org/progreso/api/gui/data/BuilderListeners.kt +++ b/progreso-api/src/main/kotlin/org/progreso/api/gui/data/BuilderListeners.kt @@ -2,7 +2,7 @@ package org.progreso.api.gui.data data class BuilderListeners( 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 = { _, _, _ -> } ) \ No newline at end of file diff --git a/progreso-client/build.gradle.kts b/progreso-client/build.gradle.kts index d3f008b..e2cd7ee 100644 --- a/progreso-client/build.gradle.kts +++ b/progreso-client/build.gradle.kts @@ -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 { @@ -89,7 +89,7 @@ tasks { } withType().configureEach { - options.release.set(17) + options.release.set(21) } shadowJar { diff --git a/progreso-client/src/main/java/org/progreso/client/mixins/render/MixinGameRenderer.java b/progreso-client/src/main/java/org/progreso/client/mixins/render/MixinGameRenderer.java new file mode 100644 index 0000000..467418e --- /dev/null +++ b/progreso-client/src/main/java/org/progreso/client/mixins/render/MixinGameRenderer.java @@ -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(); + } +} diff --git a/progreso-client/src/main/java/org/progreso/client/mixins/render/MixinWorldRenderer.java b/progreso-client/src/main/java/org/progreso/client/mixins/render/MixinWorldRenderer.java deleted file mode 100644 index 7a4f0ea..0000000 --- a/progreso-client/src/main/java/org/progreso/client/mixins/render/MixinWorldRenderer.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.progreso.client.mixins.render; - -import net.minecraft.client.render.Camera; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.render.LightmapTextureManager; -import net.minecraft.client.render.WorldRenderer; -import net.minecraft.client.util.math.MatrixStack; -import org.joml.Matrix4f; -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(WorldRenderer.class) -public abstract class MixinWorldRenderer { - @Inject( - method = "render", - at = @At("RETURN") - ) - public void renderHook( - MatrixStack matrices, - float tickDelta, - long limitTime, - boolean renderBlockOutline, - Camera camera, - GameRenderer gameRenderer, - LightmapTextureManager lightmapTextureManager, - Matrix4f projectionMatrix, - CallbackInfo callbackInfo - ) { - Client.EVENT_BUS.post(new Render3DEvent(matrices, tickDelta)); - } -} diff --git a/progreso-client/src/main/kotlin/org/progreso/client/gui/Extensions.kt b/progreso-client/src/main/kotlin/org/progreso/client/gui/Extensions.kt index 44bb505..3939e72 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/gui/Extensions.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/gui/Extensions.kt @@ -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 { diff --git a/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/ButtonBuilder.kt b/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/ButtonBuilder.kt index 0c0e32e..467a13d 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/ButtonBuilder.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/ButtonBuilder.kt @@ -36,7 +36,7 @@ class ButtonBuilder : AbstractButtonBuilder() { } 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) } diff --git a/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/ElementListBuilder.kt b/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/ElementListBuilder.kt index e1e3460..3b47008 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/ElementListBuilder.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/ElementListBuilder.kt @@ -29,7 +29,7 @@ class ElementListBuilder> return this@ElementListBuilder.itemWidth } - override fun getScrollbarPositionX(): Int { + override fun getScrollbarX(): Int { return x + width - 6 } @@ -51,7 +51,7 @@ class ElementListBuilder> } 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) } diff --git a/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/ScreenBuilder.kt b/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/ScreenBuilder.kt index 6cc9112..d4ff16d 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/ScreenBuilder.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/ScreenBuilder.kt @@ -24,7 +24,7 @@ class ScreenBuilder : AbstractScreenBuilder() { } 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) } diff --git a/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/TextFieldBuilder.kt b/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/TextFieldBuilder.kt index 08057a4..992530f 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/TextFieldBuilder.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/gui/builders/TextFieldBuilder.kt @@ -39,7 +39,7 @@ class TextFieldBuilder : AbstractTextFieldBuilder( } 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) } diff --git a/progreso-client/src/main/kotlin/org/progreso/client/gui/minecraft/ProgresoAltsScreen.kt b/progreso-client/src/main/kotlin/org/progreso/client/gui/minecraft/ProgresoAltsScreen.kt index 9ec7012..77e87d0 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/gui/minecraft/ProgresoAltsScreen.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/gui/minecraft/ProgresoAltsScreen.kt @@ -150,7 +150,7 @@ class ProgresoAltsScreen(private val alts: Set) : TitledScreen(i18n thread.interrupt() } - render { context, _, _ -> + render { context, mouseX, mouseY, delta -> if (result.set) { val (status, account) = result.pair ?: return@render close() @@ -166,7 +166,7 @@ class ProgresoAltsScreen(private val alts: Set) : TitledScreen(i18n val text = i18n("gui.alts.label.add_microsoft_alt_link") - renderBackgroundTexture(context) + renderBackground(context, mouseX, mouseY, delta) context.drawText( textRenderer, text, @@ -189,8 +189,8 @@ class ProgresoAltsScreen(private val alts: Set) : TitledScreen(i18n } } - render { context, _, _ -> - renderBackgroundTexture(context) + render { context, mouseX, mouseY, delta -> + renderBackground(context, mouseX, mouseY, delta) context.drawText( textRenderer, errorI18n, diff --git a/progreso-client/src/main/kotlin/org/progreso/client/gui/minecraft/ProgresoPluginsScreen.kt b/progreso-client/src/main/kotlin/org/progreso/client/gui/minecraft/ProgresoPluginsScreen.kt index 0a7c5b4..a349f84 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/gui/minecraft/ProgresoPluginsScreen.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/gui/minecraft/ProgresoPluginsScreen.kt @@ -46,7 +46,7 @@ class ProgresoPluginsScreen(private val plugins: Set) : TitledSc ) var lastSelected: AbstractPlugin? = null - list.render { _, _, _ -> + list.render { _, _, _, _ -> if (selectedPlugin != lastSelected) { lastSelected = selectedPlugin children().clear() diff --git a/progreso-client/src/main/kotlin/org/progreso/client/gui/minecraft/common/TitledScreen.kt b/progreso-client/src/main/kotlin/org/progreso/client/gui/minecraft/common/TitledScreen.kt index b9aea61..4daed00 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/gui/minecraft/common/TitledScreen.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/gui/minecraft/common/TitledScreen.kt @@ -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, diff --git a/progreso-client/src/main/kotlin/org/progreso/client/modules/render/HoleESP.kt b/progreso-client/src/main/kotlin/org/progreso/client/modules/render/HoleESP.kt new file mode 100644 index 0000000..adbf787 --- /dev/null +++ b/progreso-client/src/main/kotlin/org/progreso/client/modules/render/HoleESP.kt @@ -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() + + init { + safeEventListener { + holes.clear() + + for (pos in mc.world.getBlocksInRadius(radius, mc.player.blockPos)) { + if (isHole(pos)) { + holes.add(pos) + } + } + } + + safeEventListener { 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 } + } +} \ No newline at end of file diff --git a/progreso-client/src/main/kotlin/org/progreso/client/util/render/Render2D.kt b/progreso-client/src/main/kotlin/org/progreso/client/util/render/Render2D.kt index 7b09ba7..95577e6 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/util/render/Render2D.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/util/render/Render2D.kt @@ -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 @@ -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) } diff --git a/progreso-client/src/main/kotlin/org/progreso/client/util/world/World.kt b/progreso-client/src/main/kotlin/org/progreso/client/util/world/World.kt index bcb8d38..ebc195b 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/util/world/World.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/util/world/World.kt @@ -1,6 +1,7 @@ package org.progreso.client.util.world import net.minecraft.block.entity.BlockEntity +import net.minecraft.util.math.BlockPos import net.minecraft.util.math.ChunkPos import net.minecraft.world.World import net.minecraft.world.chunk.WorldChunk @@ -38,4 +39,26 @@ val World.loadedChunks: Stream .limit((diameter * diameter).toLong()) .filter { isChunkLoaded(it.x, it.z) } .map { getChunk(it.x, it.z) } - } \ No newline at end of file + } + +fun World.getBlocksInRadius(radius: Int, pos: BlockPos): List { + return getBlocksInRadius(radius, radius, radius, pos) +} + +fun World.getBlocksInRadius(xRadius: Int, yRadius: Int, zRadius: Int, pos: BlockPos): List { + val poses = mutableListOf() + + for (x in -xRadius..xRadius) { + for (z in -zRadius..zRadius) { + for (y in -yRadius..yRadius) { + val blockPos = pos.add(x, y, z) + + if (getBlockState(blockPos) != null) { + poses.add(blockPos) + } + } + } + } + + return poses +} \ No newline at end of file diff --git a/progreso-client/src/main/resources/progreso.mixins.json b/progreso-client/src/main/resources/progreso.mixins.json index c05e579..d9c5e5a 100644 --- a/progreso-client/src/main/resources/progreso.mixins.json +++ b/progreso-client/src/main/resources/progreso.mixins.json @@ -20,7 +20,7 @@ "network.MixinClientPlayerInteractionManager", "network.MixinClientPlayNetworkHandler", "render.MixinLightmapTextureManager", - "render.MixinWorldRenderer", + "render.MixinGameRenderer", "sound.MixinSoundSystem" ] } \ No newline at end of file