Skip to content

Commit

Permalink
Merge branch 'CCBlueX:nextgen' into feat-autoarmor-savearmor
Browse files Browse the repository at this point in the history
  • Loading branch information
Katinuka authored Feb 22, 2025
2 parents 2cae357 + 528fd51 commit e0905b4
Show file tree
Hide file tree
Showing 13 changed files with 259 additions and 74 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ kotlin_version=2.1.0
# https://maven.fabricmc.net/net/fabricmc/fabric-language-kotlin/
fabric_kotlin_version=1.13.0+kotlin.2.1.0
# mcef
mcef_version=1.3.5-1.21.4
mcef_version=1.3.6-1.21.4
# mc-authlib
mc_authlib_version=1.4.1
# Recommended mods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,42 @@

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import net.ccbluex.liquidbounce.api.models.cosmetics.CosmeticCategory;
import net.ccbluex.liquidbounce.features.cosmetic.CosmeticService;
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleFreeCam;
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleRotations;
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleTrueSight;
import net.ccbluex.liquidbounce.features.module.modules.render.esp.ModuleESP;
import net.ccbluex.liquidbounce.interfaces.EntityRenderStateAddition;
import net.ccbluex.liquidbounce.render.engine.Color4b;
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
import net.ccbluex.liquidbounce.utils.aiming.data.Rotation;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
import net.minecraft.util.math.MathHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(LivingEntityRenderer.class)
public class MixinLivingEntityRenderer<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> {
public abstract class MixinLivingEntityRenderer<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> {

@Unique
private static final int ESP_TRUE_SIGHT_REQUIREMENT_COLOR = new Color4b(255, 255, 255, 255).alpha(100).toARGB();

@Shadow
public abstract Identifier getTexture(S state);

@Unique
private Pair<Rotation, Rotation> getOverwriteRotation(ModuleRotations.BodyPart bodyPart) {
Expand Down Expand Up @@ -107,14 +119,22 @@ private float hookPitch(float original, LivingEntity entity, S state, float tick
return original;
}

@ModifyExpressionValue(method = "render(Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;isVisible(Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;)Z"))
private boolean injectTrueSight(boolean original, @Local(argsOnly = true) S livingEntityRenderState) {
// Check if TrueSight is enabled and entities are enabled or ESP is enabled and in glow mode
if (ModuleTrueSight.INSTANCE.getRunning() && ModuleTrueSight.INSTANCE.getEntities() ||
ModuleESP.INSTANCE.getRunning() && ModuleESP.INSTANCE.requiresTrueSight(((LivingEntity) ((EntityRenderStateAddition) livingEntityRenderState).liquid_bounce$getEntity()))) {
return true;
@WrapOperation(method = "render(Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/EntityModel;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;III)V"))
private void injectTrueSight(EntityModel instance, MatrixStack matrixStack, VertexConsumer vertexConsumer, int light, int overlay, int color, Operation<Void> original, @Local(argsOnly = true) S livingEntityRenderState) {
var trueSightModule = ModuleTrueSight.INSTANCE;
var trueSight = trueSightModule.getRunning() && trueSightModule.getEntities();
if (ModuleTrueSight.canRenderEntities(livingEntityRenderState)) {
color = trueSight ? trueSightModule.getEntityColor().toARGB() : ESP_TRUE_SIGHT_REQUIREMENT_COLOR;
}
original.call(instance, matrixStack, vertexConsumer, light, overlay, color);
}

@ModifyReturnValue(method = "getRenderLayer", at = @At("RETURN"))
private RenderLayer injectTrueSight(RenderLayer original, S state, boolean showBody, boolean translucent, boolean showOutline) {
if (ModuleTrueSight.canRenderEntities(state) && !showBody && !translucent && !showOutline) {
state.invisible = false;
return RenderLayer.getItemEntityTranslucentCull(this.getTexture(state));
}
return original;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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.injection.mixins.minecraft.render.entity.feature;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleTrueSight;
import net.ccbluex.liquidbounce.render.engine.Color4b;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(FeatureRenderer.class)
public abstract class MixinFeatureRenderer {

@Unique
private static final int ESP_TRUE_SIGHT_REQUIREMENT_COLOR = new Color4b(255, 255, 255, 255).alpha(120).toARGB();

@WrapOperation(method = "renderModel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/EntityModel;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;III)V"))
private static void injectTrueSight(EntityModel instance, MatrixStack matrixStack, VertexConsumer vertexConsumer, int light, int overlay, int color, Operation<Void> original, @Local(argsOnly = true) LivingEntityRenderState state) {
var trueSightModule = ModuleTrueSight.INSTANCE;
var trueSight = trueSightModule.getRunning() && trueSightModule.getEntities();
if (ModuleTrueSight.canRenderEntities(state)) {
color = trueSight ? trueSightModule.getEntityFeatureLayerColor().toARGB() : ESP_TRUE_SIGHT_REQUIREMENT_COLOR;
}
original.call(instance, matrixStack, vertexConsumer, light, overlay, color);
}

@WrapOperation(method = "renderModel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayer;getEntityCutoutNoCull(Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/render/RenderLayer;"))
private static RenderLayer injectTrueSight(Identifier texture, Operation<RenderLayer> original, @Local(argsOnly = true) LivingEntityRenderState state) {
if (ModuleTrueSight.canRenderEntities(state)) {
return RenderLayer.getItemEntityTranslucentCull(texture);
}
return original.call(texture);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ object ModuleDebug : ClientModule("Debug", Category.RENDER) {
private val expireHandler = tickHandler {
val currentTime = System.currentTimeMillis()

debugParameters.entries.removeIf { (parameter, capture) ->
(currentTime - capture.time) / 1000 >= expireTime
debugParameters.entries.removeIf { (_, capture) ->
currentTime - capture.time >= expireTime * 1000
}
}

Expand All @@ -155,8 +155,6 @@ object ModuleDebug : ClientModule("Debug", Category.RENDER) {
return@handler
}

val width = mc.window.scaledWidth

renderEnvironmentForGUI {
fontRenderer.withBuffers { buffers ->
/**
Expand Down Expand Up @@ -220,27 +218,25 @@ object ModuleDebug : ClientModule("Debug", Category.RENDER) {

commit(buffers)
}


}
}
}

inline fun debugGeometry(owner: Any, name: String, lazyGeometry: () -> DebuggedGeometry) {
fun debugGeometry(owner: Any, name: String, geometry: DebuggedGeometry) {
// Do not take any new debugging while the module is off
if (!running) {
return
}

debugGeometry(owner, name, lazyGeometry.invoke())
debuggedGeometry[DebuggedGeometryOwner(owner, name)] = geometry
}

fun debugGeometry(owner: Any, name: String, geometry: DebuggedGeometry) {
// Do not take any new debugging while the module is off
if (!running) {
inline fun Any.debugGeometry(name: String, lazyGeometry: () -> DebuggedGeometry) {
if (!ModuleDebug.running) {
return
}

debuggedGeometry[DebuggedGeometryOwner(owner, name)] = geometry
debugGeometry(owner = this, name, lazyGeometry())
}

private data class DebuggedGeometryOwner(val owner: Any, val name: String)
Expand All @@ -251,20 +247,20 @@ object ModuleDebug : ClientModule("Debug", Category.RENDER) {

private val debugParameters = hashMapOf<DebuggedParameter, ParameterCapture>()

inline fun debugParameter(owner: Any, name: String, lazyValue: () -> Any) {
fun debugParameter(owner: Any, name: String, value: Any?) {
if (!running) {
return
}

debugParameter(owner, name, lazyValue.invoke())
debugParameters[DebuggedParameter(owner, name)] = ParameterCapture(value = value)
}

fun debugParameter(owner: Any, name: String, value: Any?) {
if (!running) {
inline fun Any.debugParameter(name: String, lazyValue: () -> Any) {
if (!ModuleDebug.running) {
return
}

debugParameters[DebuggedParameter(owner, name)] = ParameterCapture(value = value)
debugParameter(owner = this, name, lazyValue())
}

fun getArrayEntryColor(idx: Int, length: Int): Color4b {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ package net.ccbluex.liquidbounce.features.module.modules.render

import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.ClientModule
import net.ccbluex.liquidbounce.features.module.modules.render.esp.ModuleESP
import net.ccbluex.liquidbounce.interfaces.EntityRenderStateAddition
import net.ccbluex.liquidbounce.render.engine.Color4b
import net.minecraft.client.render.entity.state.LivingEntityRenderState
import net.minecraft.entity.LivingEntity

/**
* TrueSight module
Expand All @@ -30,4 +35,21 @@ import net.ccbluex.liquidbounce.features.module.ClientModule
object ModuleTrueSight : ClientModule("TrueSight", Category.RENDER) {
val barriers by boolean("Barriers", true)
val entities by boolean("Entities", true)
val entityColor by color("EntityColor", Color4b(255, 255, 255, 100))
val entityFeatureLayerColor by color("EntityFeatureLayerColor", Color4b(255, 255, 255, 120))

@JvmStatic
@Suppress("ComplexCondition")
fun canRenderEntities(state: LivingEntityRenderState): Boolean {
val enabled = this.running && entities;

val entity = (state as EntityRenderStateAddition).`liquid_bounce$getEntity`()
val livingEntity = entity as? LivingEntity

return ((enabled
|| livingEntity != null
&& ModuleESP.running
&& ModuleESP.requiresTrueSight(livingEntity))
&& entity.isInvisible)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.ClientModule
import net.ccbluex.liquidbounce.utils.inventory.HotbarItemSlot
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleDebug
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleDebug.debugGeometry
import net.ccbluex.liquidbounce.features.module.modules.world.fucker.isSelfBedChoices
import net.ccbluex.liquidbounce.render.engine.Color4b
import net.ccbluex.liquidbounce.utils.block.placer.BlockPlacer
Expand Down Expand Up @@ -148,7 +149,7 @@ object ModuleBedDefender : ClientModule("BedDefender", category = Category.WORLD
)
}

ModuleDebug.debugGeometry(this, "PlacementPosition") {
debugGeometry("PlacementPosition") {
ModuleDebug.DebugCollection(
updatePositions.map { (_, pos) ->
ModuleDebug.DebuggedPoint(pos.toCenterPos(), Color4b.RED.with(a = 100))
Expand Down
Loading

0 comments on commit e0905b4

Please sign in to comment.