diff --git a/gradle.properties b/gradle.properties index 4e3fdfe..7dd32d6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,10 +11,10 @@ kotlinVersion=2.0.0 progresoVersion=0.3 # fabric -minecraftVersion=1.20.6 -fabricVersion=0.99.4+1.20.6 +minecraftVersion=1.21 +fabricVersion=0.100.4+1.21 fabricLoomVersion=1.6-SNAPSHOT -yarnMappings=1.20.6+build.3 +yarnMappings=1.21+build.7 loaderVersion=0.15.11 # other diff --git a/progreso-client/src/main/java/org/progreso/client/mixins/gui/MixinInGameHud.java b/progreso-client/src/main/java/org/progreso/client/mixins/gui/MixinInGameHud.java index 0564e2b..0364e4b 100644 --- a/progreso-client/src/main/java/org/progreso/client/mixins/gui/MixinInGameHud.java +++ b/progreso-client/src/main/java/org/progreso/client/mixins/gui/MixinInGameHud.java @@ -2,6 +2,7 @@ import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.render.RenderTickCounter; import org.progreso.client.Client; import org.progreso.client.events.render.Render2DEvent; import org.spongepowered.asm.mixin.Mixin; @@ -15,7 +16,13 @@ public abstract class MixinInGameHud { method = "render", at = @At("TAIL") ) - public void renderHook(DrawContext context, float tickDelta, CallbackInfo callbackInfo) { + public void renderHook( + DrawContext context, + RenderTickCounter tickCounter, + CallbackInfo callbackInfo + ) { + Client.getMc().getClient().getProfiler().push("progreso_2d_render"); Client.EVENT_BUS.post(new Render2DEvent(context)); + Client.getMc().getClient().getProfiler().pop(); } } diff --git a/progreso-client/src/main/java/org/progreso/client/mixins/network/MixinClientPlayerInteractionManager.java b/progreso-client/src/main/java/org/progreso/client/mixins/network/MixinClientPlayerInteractionManager.java index 4bc0cdb..a1f29ab 100644 --- a/progreso-client/src/main/java/org/progreso/client/mixins/network/MixinClientPlayerInteractionManager.java +++ b/progreso-client/src/main/java/org/progreso/client/mixins/network/MixinClientPlayerInteractionManager.java @@ -1,13 +1,17 @@ package org.progreso.client.mixins.network; import net.minecraft.client.network.ClientPlayerInteractionManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import org.progreso.client.Client; import org.progreso.client.events.block.DamageBlockEvent; +import org.progreso.client.events.player.AttackEntityEvent; 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; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ClientPlayerInteractionManager.class) @@ -21,4 +25,15 @@ public void attackBlockHook(BlockPos pos, Direction direction, CallbackInfoRetur callbackInfoReturnable.cancel(); } } + + @Inject( + method = "attackEntity", + at = @At("HEAD"), + cancellable = true + ) + public void attackEntityHook(PlayerEntity player, Entity target, CallbackInfo callbackInfo) { + if (Client.EVENT_BUS.post(new AttackEntityEvent(target))) { + callbackInfo.cancel(); + } + } } 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 index 467418e..5d1ad9a 100644 --- 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 @@ -2,6 +2,7 @@ import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.client.render.GameRenderer; +import net.minecraft.client.render.RenderTickCounter; import net.minecraft.client.util.math.MatrixStack; import org.joml.Matrix4f; import org.objectweb.asm.Opcodes; @@ -15,7 +16,7 @@ @Mixin(GameRenderer.class) public abstract class MixinGameRenderer { @Inject( - method = "renderWorld(FJ)V", + method = "renderWorld", at = @At( value = "FIELD", target = "Lnet/minecraft/client/render/GameRenderer;renderHand:Z", @@ -24,12 +25,12 @@ public abstract class MixinGameRenderer { ) ) public void renderWorldHook( - float tickDelta, - long limitTime, - CallbackInfo ci, - @Local(ordinal = 1) Matrix4f matrix4f2 + RenderTickCounter tickCounter, + CallbackInfo callbackInfo, + @Local(ordinal = 1) Matrix4f matrix4f2, + @Local(ordinal = 1) float tickDelta ) { - Client.getMc().getClient().getProfiler().push("progreso_render"); + Client.getMc().getClient().getProfiler().push("progreso_3d_render"); MatrixStack matrixStack = new MatrixStack(); matrixStack.multiplyPositionMatrix(matrix4f2); Client.EVENT_BUS.post(new Render3DEvent(matrixStack, tickDelta)); diff --git a/progreso-client/src/main/kotlin/org/progreso/client/Client.kt b/progreso-client/src/main/kotlin/org/progreso/client/Client.kt index f5792d5..23d6a0e 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/Client.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/Client.kt @@ -118,8 +118,6 @@ class Client : ClientModInitializer { } class MinecraftClientWrapper(val client: MinecraftClient) { - val tickDelta get() = client.tickDelta - val world get() = client.world!! val player get() = client.player!! val textRenderer get() = client.textRenderer!! diff --git a/progreso-client/src/main/kotlin/org/progreso/client/events/player/AttackEntityEvent.kt b/progreso-client/src/main/kotlin/org/progreso/client/events/player/AttackEntityEvent.kt new file mode 100644 index 0000000..a1591d5 --- /dev/null +++ b/progreso-client/src/main/kotlin/org/progreso/client/events/player/AttackEntityEvent.kt @@ -0,0 +1,6 @@ +package org.progreso.client.events.player + +import net.minecraft.entity.Entity +import org.progreso.api.event.Event + +data class AttackEntityEvent(val entity: Entity) : Event() \ No newline at end of file diff --git a/progreso-client/src/main/kotlin/org/progreso/client/gui/clickgui/element/elements/ColorElement.kt b/progreso-client/src/main/kotlin/org/progreso/client/gui/clickgui/element/elements/ColorElement.kt index fb8d5be..09732ef 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/gui/clickgui/element/elements/ColorElement.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/gui/clickgui/element/elements/ColorElement.kt @@ -3,10 +3,7 @@ package org.progreso.client.gui.clickgui.element.elements import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.systems.RenderSystem import net.minecraft.client.gui.DrawContext -import net.minecraft.client.render.GameRenderer -import net.minecraft.client.render.Tessellator -import net.minecraft.client.render.VertexFormat -import net.minecraft.client.render.VertexFormats +import net.minecraft.client.render.* import org.progreso.api.setting.settings.ColorSetting import org.progreso.api.setting.settings.NumberSetting import org.progreso.client.gui.clickgui.element.AbstractChildElement @@ -122,53 +119,46 @@ class ColorElement( RenderSystem.setShader(GameRenderer::getPositionColorProgram) - val buffer = Tessellator.getInstance().buffer - buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR) + var buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR) buffer .vertex(matrix, x, y, 0f) .color(1f, 1f, 1f, 1f) - .next() buffer .vertex(matrix, x, y + height, 0f) .color(1f, 1f, 1f, 1f) - .next() buffer .vertex(matrix, x + width, y + height, 0f) .color(red, green, blue, alpha) - .next() buffer .vertex(matrix, x + width, y, 0f) .color(red, green, blue, alpha) - .next() - Tessellator.getInstance().draw() - buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR) + BufferRenderer.drawWithGlobalProgram(buffer.end()) + + buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR) buffer .vertex(matrix, x, y, 0f) .color(0f, 0f, 0f, 0f) - .next() buffer .vertex(matrix, x, y + height, 0f) .color(0f, 0f, 0f, 1f) - .next() buffer .vertex(matrix, x + width, y + height, 0f) .color(0f, 0f, 0f, 1f) - .next() buffer .vertex(matrix, x + width, y, 0f) .color(0f, 0f, 0f, 0f) - .next() - Tessellator.getInstance().draw() + BufferRenderer.drawWithGlobalProgram(buffer.end()) + context.matrices.pop() RenderSystem.setShaderColor(1f, 1f, 1f, 1f) diff --git a/progreso-client/src/main/kotlin/org/progreso/client/modules/combat/KillAura.kt b/progreso-client/src/main/kotlin/org/progreso/client/modules/combat/KillAura.kt index 3c3e834..51d4987 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/modules/combat/KillAura.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/modules/combat/KillAura.kt @@ -7,6 +7,8 @@ import net.minecraft.entity.passive.IronGolemEntity import net.minecraft.entity.passive.PassiveEntity import net.minecraft.entity.passive.SnowGolemEntity import net.minecraft.entity.player.PlayerEntity +import net.minecraft.item.AxeItem +import net.minecraft.item.MaceItem import net.minecraft.item.SwordItem import org.progreso.api.module.AbstractModule import org.progreso.client.Client.Companion.mc @@ -18,9 +20,13 @@ import org.progreso.client.util.player.attack @AbstractModule.AutoRegister object KillAura : AbstractModule() { private val distance by setting("Distance", 4, 1..6) - private val onlySword by setting("OnlySword", true) private val target by setting("Target", Target.Distance) + private val weapons = setting("Weapons") + private val axe by weapons.setting("Axe", false) + private val sword by weapons.setting("Sword", true) + private val mace by weapons.setting("Mace", false) + private val targets = setting("Targets") private val players by targets.setting("Players", true) private val monsters by targets.setting("Monsters", false) @@ -28,8 +34,11 @@ object KillAura : AbstractModule() { init { safeEventListener { _ -> - if (onlySword && mc.player.mainHandStack.item !is SwordItem) { - return@safeEventListener + when (mc.player.mainHandStack.item) { + is AxeItem -> if (!axe) return@safeEventListener + is SwordItem -> if (!sword) return@safeEventListener + is MaceItem -> if (!mace) return@safeEventListener + else -> return@safeEventListener } val entity = mc.world.entities diff --git a/progreso-client/src/main/kotlin/org/progreso/client/modules/misc/AutoTool.kt b/progreso-client/src/main/kotlin/org/progreso/client/modules/misc/AutoTool.kt index e447b2c..1fc4ae4 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/modules/misc/AutoTool.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/modules/misc/AutoTool.kt @@ -3,6 +3,7 @@ package org.progreso.client.modules.misc import net.minecraft.enchantment.EnchantmentHelper import net.minecraft.enchantment.Enchantments import net.minecraft.item.ItemStack +import net.minecraft.registry.RegistryKeys import net.minecraft.util.math.BlockPos import org.progreso.api.module.AbstractModule import org.progreso.client.Client.Companion.mc @@ -29,7 +30,10 @@ object AutoTool : AbstractModule() { var speed = stack.getMiningSpeedMultiplier(mc.world.getBlockState(pos)) if (speed > 1.0f) { - speed += EnchantmentHelper.getLevel(Enchantments.EFFICIENCY, stack) + speed += EnchantmentHelper.getLevel( + mc.world.registryManager.get(RegistryKeys.ENCHANTMENT).getEntry(Enchantments.EFFICIENCY).get(), + stack + ) } return speed diff --git a/progreso-client/src/main/kotlin/org/progreso/client/util/player/Interaction.kt b/progreso-client/src/main/kotlin/org/progreso/client/util/player/Interaction.kt index 1003bda..1eb25da 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/util/player/Interaction.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/util/player/Interaction.kt @@ -5,8 +5,12 @@ import net.minecraft.entity.LivingEntity import net.minecraft.util.Hand import org.progreso.client.Client.Companion.mc -fun ClientPlayerInteractionManager.attack(entity: LivingEntity, checkStrength: Boolean = true) { - if (checkStrength && mc.player.getAttackCooldownProgress(mc.tickDelta) != 1.0f) { +fun ClientPlayerInteractionManager.attack( + entity: LivingEntity, + checkStrength: Boolean = true, + tickDelta: Float = 0.5f +) { + if (checkStrength && mc.player.getAttackCooldownProgress(tickDelta) != 1.0f) { return } 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 95577e6..58f3815 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 @@ -4,10 +4,7 @@ import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.systems.RenderSystem import net.minecraft.client.font.* import net.minecraft.client.gui.DrawContext -import net.minecraft.client.render.GameRenderer -import net.minecraft.client.render.Tessellator -import net.minecraft.client.render.VertexFormat -import net.minecraft.client.render.VertexFormats +import net.minecraft.client.render.* import net.minecraft.resource.ResourceManager import net.minecraft.util.Identifier import org.progreso.client.Client @@ -53,15 +50,14 @@ fun Render2DContext.drawCircle( segments: Int, radius: Double ) { - val buffer = Tessellator.getInstance().buffer val matrix = context.matrices.peek().positionMatrix val angleStep = Math.toRadians(angleTo - angleFrom) / segments RenderSystem.setShader { GameRenderer.getPositionProgram() } - buffer.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION) - buffer.vertex(matrix, centerX.toFloat(), centerY.toFloat(), 0f).next() + val buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION) + buffer.vertex(matrix, centerX.toFloat(), centerY.toFloat(), 0f) for (i in segments downTo 0) { val theta = Math.toRadians(angleFrom) + i * angleStep @@ -69,10 +65,10 @@ fun Render2DContext.drawCircle( matrix, (centerX - cos(theta) * radius).toFloat(), (centerY - sin(theta) * radius).toFloat(), 0f - ).next() + ) } - Tessellator.getInstance().draw() + BufferRenderer.drawWithGlobalProgram(buffer.end()) } fun createTextRenderer( @@ -82,12 +78,12 @@ fun createTextRenderer( namespace: String = "progreso" ): TextRenderer? { val font = - TrueTypeFontLoader(Identifier(namespace, "$fontName.ttf"), size, 2f, TrueTypeFontLoader.Shift.NONE, "") + TrueTypeFontLoader(Identifier.of(namespace, "$fontName.ttf"), size, 2f, TrueTypeFontLoader.Shift.NONE, "") .build() .left() if (font.isPresent) { - val fontStorage = FontStorage(Client.mc.client.textureManager, Identifier("progreso")) + val fontStorage = FontStorage(Client.mc.client.textureManager, Identifier.of("progreso")) fontStorage.setFonts( listOf(Font.FontFilterPair(font.get().load(resourceManager), FontFilterType.FilterMap.NO_FILTER)), emptySet() diff --git a/progreso-client/src/main/kotlin/org/progreso/client/util/render/Render3D.kt b/progreso-client/src/main/kotlin/org/progreso/client/util/render/Render3D.kt index 61cbd34..298a87f 100644 --- a/progreso-client/src/main/kotlin/org/progreso/client/util/render/Render3D.kt +++ b/progreso-client/src/main/kotlin/org/progreso/client/util/render/Render3D.kt @@ -2,10 +2,7 @@ package org.progreso.client.util.render import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.systems.RenderSystem -import net.minecraft.client.render.GameRenderer -import net.minecraft.client.render.Tessellator -import net.minecraft.client.render.VertexFormat -import net.minecraft.client.render.VertexFormats +import net.minecraft.client.render.* import net.minecraft.client.util.math.MatrixStack import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Box @@ -59,12 +56,10 @@ fun Render3DContext.withColor(color: Color, block: Render3DContext.() -> Unit) { } fun Render3DContext.drawOutlinedBox(box: Box) { - val matrix = matrices.peek().positionMatrix - val buffer = Tessellator.getInstance().buffer - RenderSystem.setShader(GameRenderer::getPositionProgram) - buffer.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION) + val matrix = matrices.peek().positionMatrix + val buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION) val vertices = listOf( Vec3d(box.minX, box.minY, box.minZ), @@ -99,19 +94,17 @@ fun Render3DContext.drawOutlinedBox(box: Box) { vec3d.x.toFloat(), vec3d.y.toFloat(), vec3d.z.toFloat() - ).next() + ) } - Tessellator.getInstance().draw() + BufferRenderer.drawWithGlobalProgram(buffer.end()) } fun Render3DContext.drawSolidBox(box: Box) { - val matrix = matrices.peek().positionMatrix - val buffer = Tessellator.getInstance().buffer - - RenderSystem.setShader { GameRenderer.getPositionProgram() } + RenderSystem.setShader(GameRenderer::getPositionProgram) - buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION) + val matrix = matrices.peek().positionMatrix + val buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION) val vertices = listOf( Vec3d(box.minX, box.minY, box.minZ), @@ -146,8 +139,8 @@ fun Render3DContext.drawSolidBox(box: Box) { vec3d.x.toFloat(), vec3d.y.toFloat(), vec3d.z.toFloat() - ).next() + ) } - Tessellator.getInstance().draw() + BufferRenderer.drawWithGlobalProgram(buffer.end()) } \ No newline at end of file