diff --git a/.gitignore b/.gitignore index 84d451a7522..a7db835cc8b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ /run/ /mcef/ /logs/ +/.kotlin/ diff --git a/build.gradle b/build.gradle index 903c341bb00..135d1c2eec3 100644 --- a/build.gradle +++ b/build.gradle @@ -28,9 +28,11 @@ plugins { id "org.jetbrains.dokka" version "1.9.10" } -archivesBaseName = project.archives_base_name -version = project.mod_version -group = project.maven_group +base { + archivesBaseName = project.archives_base_name + version = project.mod_version + group = project.maven_group +} configurations { includeDependency diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml index 4fdb3162468..b55d7a3f540 100644 --- a/config/detekt/baseline.xml +++ b/config/detekt/baseline.xml @@ -18,8 +18,6 @@ BracesOnIfStatements:FlyGrim2859V.kt$FlyGrim2859V$if BracesOnIfStatements:ItemImageAtlas.kt$ItemImageAtlas$if BracesOnIfStatements:ModuleAntiExploit.kt$ModuleAntiExploit$if - BracesOnIfStatements:ModuleAutoBow.kt$ModuleAutoBow$else - BracesOnIfStatements:ModuleAutoBow.kt$ModuleAutoBow$if BracesOnIfStatements:ModuleAutoFarm.kt$ModuleAutoFarm$if BracesOnIfStatements:ModuleBlockESP.kt$ModuleBlockESP.Glow$if BracesOnIfStatements:ModuleBlockESP.kt$ModuleBlockESP.Outline$if @@ -87,7 +85,6 @@ LongMethod:CommandScript.kt$CommandScript$override fun createCommand(): Command LongMethod:CommandXRay.kt$CommandXRay$override fun createCommand(): Command LongMethod:InteropFunctionRegistry.kt$internal fun registerInteropFunctions(node: Node) - LongMethod:LiquidBounce.kt$LiquidBounce.ClientResourceReloader$override fun reload(manager: ResourceManager) LongMethod:ModuleManager.kt$ModuleManager$fun registerInbuilt() LongMethod:RegistryFunctions.kt$@Suppress("UNUSED_PARAMETER") fun getRegistries(requestObject: RequestObject) LongMethod:Value.kt$Value$open fun setByString(string: String) @@ -98,7 +95,6 @@ LongParameterList:Region.kt$Region$(minX: Int, minY: Int, minZ: Int, maxX: Int, maxY: Int, maxZ: Int) LongParameterList:RotationsUtil.kt$RotationManager$( rotation: Rotation, considerInventory: Boolean = true, configurable: RotationsConfigurable, priority: Priority, provider: ClientModule, whenReached: RestrictedSingleUseAction? = null ) LongParameterList:RotationsUtil.kt$RotationManager$( vecRotation: VecRotation, entity: Entity? = null, considerInventory: Boolean = true, configurable: RotationsConfigurable, priority: Priority, provider: ClientModule ) - LongParameterList:ScriptNetworkUtil.kt$ScriptNetworkUtil$(x: Double, y: Double, z: Double, yaw: Float, pitch: Float, onGround: Boolean) LongParameterList:TargetFinding.kt$BlockPlacementTargetFindingOptions$( val offsetsToInvestigate: List<Vec3i>, val stackToPlaceWith: ItemStack, val facePositionFactory: FaceTargetPositionFactory, val offsetPriorityGetter: (Vec3i) -> Double, val playerPositionOnPlacement: Vec3d, val playerPoseOnPlacement: EntityPose = EntityPose.STANDING, val allowPointingAway: Boolean = false ) LongParameterList:ThemeManager.kt$ThemeManager$(context: DrawContext, width: Int, height: Int, mouseX: Int, mouseY: Int, delta: Float) LoopWithTooManyJumpStatements:BlockPlacer.kt$BlockPlacer$while @@ -121,7 +117,6 @@ PrintStackTrace:CommandManager.kt$CommandManager$e ReturnCount:IntegrationListener.kt$IntegrationListener$private fun handleScreenSituation(screen: Screen?): Boolean ReturnCount:SpeedAntiCornerBump.kt$SpeedAntiCornerBump$fun getSuggestedJumpDelay( simulatedPlayer: SimulatedPlayer, n: Int = 2, ): Int? - SpreadOperator:ModuleVomit.kt$ModuleVomit$( *emptySlots.map { slot -> CreativeInventoryAction.performFillSlot(randomStack, slot) } .toTypedArray(), *emptySlots.map { slot -> ClickInventoryAction.performThrow(null, slot) } .toTypedArray() ) StringLiteralDuplication:AutoQueueGommeDuels.kt$AutoQueueGommeDuels$"AutoPlay" StringLiteralDuplication:ScriptSetting.kt$ScriptSetting$"default" SwallowedException:ClientInteropServer.kt$ClientInteropServer$e: Exception @@ -152,7 +147,6 @@ UnusedParameter:ClientApi.kt$ClientApi$settings: String UnusedParameter:CommandConfig.kt$CommandConfig$validator: (ClientModule) -> Boolean = { true } UnusedParameter:CommandLocalConfig.kt$CommandLocalConfig$validator: (ClientModule) -> Boolean = { true } - UnusedParameter:FaceTargetPositionFactory.kt$StabilizedRotationTargetPositionFactory$face: Face UnusedParameter:ModuleManager.kt$ModuleManager$args: List<String> UnusedPrivateProperty:NoFallBlink.kt$NoFallBlink$i diff --git a/gradle.properties b/gradle.properties index bc7823d2c17..929d4381b5b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,13 +20,13 @@ kotlin.code.style=official org.gradle.jvmargs=-Xms1024m -Xmx4096m # Fabric Properties # Check these on https://fabricmc.net/versions.html -minecraft_version=1.21.1 -yarn_mappings=1.21.1+build.3 +minecraft_version=1.21.4 +yarn_mappings=1.21.4+build.1 loader_version=0.16.9 min_loader_version=0.16.5 # Fabric API -fabric_version=0.110.0+1.21.1 +fabric_version=0.111.0+1.21.4 # Loom loom_version=1.9-SNAPSHOT # Mod Properties @@ -39,10 +39,10 @@ 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.1-1.21.1 +mcef_version=1.3.0-1.21.4 # mc-authlib mc_authlib_version=1.4.1 # Recommended mods -mod_menu_version=11.0.3 -sodium_version=mc1.21.1-0.6.0-fabric -viafabricplus_version=3.4.9 +mod_menu_version=13.0.0-beta.1 +sodium_version=mc1.21.4-0.6.5-fabric +viafabricplus_version=3.6.1 diff --git a/src/main/java/net/ccbluex/liquidbounce/common/ChunkUpdateFlag.java b/src/main/java/net/ccbluex/liquidbounce/common/ChunkUpdateFlag.java index bc3e9b13f32..b709b24ec83 100644 --- a/src/main/java/net/ccbluex/liquidbounce/common/ChunkUpdateFlag.java +++ b/src/main/java/net/ccbluex/liquidbounce/common/ChunkUpdateFlag.java @@ -1,3 +1,21 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ package net.ccbluex.liquidbounce.common; public class ChunkUpdateFlag { diff --git a/src/main/java/net/ccbluex/liquidbounce/common/GlobalFramebuffer.java b/src/main/java/net/ccbluex/liquidbounce/common/GlobalFramebuffer.java new file mode 100644 index 00000000000..11b08dfa1ee --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/common/GlobalFramebuffer.java @@ -0,0 +1,65 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ +package net.ccbluex.liquidbounce.common; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gl.Framebuffer; + +import java.util.ArrayList; +import java.util.List; + +/** + * Modifies {@link MinecraftClient#getFramebuffer()} to return an own framebuffer so that minecraft writes results + * to that framebuffer and not the main framebuffer. + * + * @author ccetl + */ +public class GlobalFramebuffer { + + public final static List stack = new ArrayList<>(2); + + private static Framebuffer spoofedFramebuffer; + + public static Framebuffer getSpoofedFramebuffer() { + return spoofedFramebuffer; + } + + public static void push(Framebuffer spoofedFramebuffer) { + if (GlobalFramebuffer.spoofedFramebuffer != null) { + stack.addLast(GlobalFramebuffer.spoofedFramebuffer); + } + + GlobalFramebuffer.spoofedFramebuffer = spoofedFramebuffer; + } + + public static void pop() { + if (stack.isEmpty()) { + spoofedFramebuffer = null; + return; + } + + spoofedFramebuffer = stack.getLast(); + } + + public static void clear() { + stack.clear(); + spoofedFramebuffer = null; + } + +} diff --git a/src/main/java/net/ccbluex/liquidbounce/common/OutlineFlag.java b/src/main/java/net/ccbluex/liquidbounce/common/OutlineFlag.java index 03d1f0d81de..a7f7286a5b9 100644 --- a/src/main/java/net/ccbluex/liquidbounce/common/OutlineFlag.java +++ b/src/main/java/net/ccbluex/liquidbounce/common/OutlineFlag.java @@ -15,7 +15,6 @@ * * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . - * */ package net.ccbluex.liquidbounce.common; diff --git a/src/main/java/net/ccbluex/liquidbounce/common/TweakedMethods.java b/src/main/java/net/ccbluex/liquidbounce/common/TweakedMethods.java index fd20afc351f..3325935b6a7 100644 --- a/src/main/java/net/ccbluex/liquidbounce/common/TweakedMethods.java +++ b/src/main/java/net/ccbluex/liquidbounce/common/TweakedMethods.java @@ -16,7 +16,6 @@ * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . */ - package net.ccbluex.liquidbounce.common; import net.ccbluex.liquidbounce.features.module.modules.exploit.ModuleGhostHand; @@ -66,4 +65,5 @@ public static BlockHitResult tweakedRaycast(BlockView blockView, RaycastContext return BlockHitResult.createMissed(contextx.getEnd(), Direction.getFacing(vec3d.x, vec3d.y, vec3d.z), BlockPos.ofFloored(contextx.getEnd())); }); } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/authlib/MixinMinecraftClient.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/authlib/MixinMinecraftClient.java index 9913a31465f..da4840413e6 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/authlib/MixinMinecraftClient.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/authlib/MixinMinecraftClient.java @@ -31,7 +31,7 @@ import java.net.Proxy; @Mixin(value = MinecraftClient.class, remap = false) -public class MixinMinecraftClient { +public abstract class MixinMinecraftClient { @ModifyExpressionValue(method = "createUrlConnection", at = @At( value = "FIELD", diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/blaze3d/MixinRenderSystem.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/blaze3d/MixinRenderSystem.java new file mode 100644 index 00000000000..c5d6253c27d --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/blaze3d/MixinRenderSystem.java @@ -0,0 +1,38 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ +package net.ccbluex.liquidbounce.injection.mixins.blaze3d; + +import com.mojang.blaze3d.systems.RenderSystem; +import net.ccbluex.liquidbounce.features.module.modules.render.ModuleCustomAmbience; +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(value = RenderSystem.class, remap = false) +public abstract class MixinRenderSystem { + + @Inject(method = "clearColor", at = @At(value = "HEAD"), cancellable = true) + private static void injectFog(float red, float green, float blue, float alpha, CallbackInfo ci) { + if (ModuleCustomAmbience.FogConfigurable.INSTANCE.modifyClearColor()) { + ci.cancel(); + } + } + +} diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlock.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlock.java index 94adcff40c5..ef3eb8ca855 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlock.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlock.java @@ -25,9 +25,7 @@ import net.ccbluex.liquidbounce.features.module.modules.render.ModuleXRay; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.world.BlockView; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -35,10 +33,10 @@ public class MixinBlock { @ModifyReturnValue(method = "shouldDrawSide", at = @At("RETURN")) - private static boolean injectXRay(boolean original, BlockState state, BlockView world, BlockPos pos, Direction side, BlockPos otherPos) { + private static boolean injectXRay(boolean original, BlockState state, BlockState otherState, Direction side) { var xRay = ModuleXRay.INSTANCE; if (xRay.getRunning()) { - return xRay.shouldRender(state, pos); + return xRay.shouldRender(state, otherState, side); } return original; diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlockCollisionSpliterator.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlockCollisionSpliterator.java index c24d9ecb7af..f45333b8077 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlockCollisionSpliterator.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlockCollisionSpliterator.java @@ -47,7 +47,7 @@ public class MixinBlockCollisionSpliterator { */ @ModifyExpressionValue(method = "computeNext", at = @At( value = "INVOKE", - target = "Lnet/minecraft/block/BlockState;getCollisionShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;" + target = "Lnet/minecraft/block/ShapeContext;getCollisionShape(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/CollisionView;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/shape/VoxelShape;" )) private VoxelShape hookCollisionShape(VoxelShape original, @Local BlockState blockState) { if (this.pos == null || ShapeFlag.noShapeChange) { diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlockView.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlockView.java index a00c5b1800e..885e2d424f8 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlockView.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/block/MixinBlockView.java @@ -46,6 +46,7 @@ static T raycast(Vec3d start, Vec3d end, C context, BiFunction> cir) { cir.getReturnValue().setValue(2); } } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinInput.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinInput.java index b6d62f643ae..b2b8396568b 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinInput.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinInput.java @@ -22,6 +22,7 @@ import net.ccbluex.liquidbounce.features.module.modules.combat.criticals.ModuleCriticals; import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleSprint; import net.minecraft.client.input.Input; +import net.minecraft.util.PlayerInput; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -29,23 +30,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Input.class) -public class MixinInput { - @Shadow - public boolean pressingRight; - @Shadow - public boolean pressingLeft; - @Shadow - public boolean pressingBack; - @Shadow - public boolean pressingForward; +public abstract class MixinInput { + @Shadow public float movementForward; + @Shadow public float movementSideways; - @Shadow - public boolean jumping; - @Shadow public boolean sneaking; + @Shadow + public PlayerInput playerInput; @Inject(method = "hasForwardMovement", cancellable = true, at = @At("RETURN")) private void hookOmnidirectionalSprintA(final CallbackInfoReturnable callbackInfoReturnable) { diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyboardInput.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyboardInput.java index 8c06f236c89..1f9fbca3280 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyboardInput.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinKeyboardInput.java @@ -34,10 +34,12 @@ import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.option.GameOptions; import net.minecraft.client.option.KeyBinding; +import net.minecraft.util.PlayerInput; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Final; 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; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; @@ -59,29 +61,29 @@ private boolean hookInventoryMove(KeyBinding keyBinding) { ? InputTracker.INSTANCE.isPressedOnAny(keyBinding) : keyBinding.isPressed(); } - @Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/KeyboardInput;pressingBack:Z", ordinal = 0)) - private void hookInventoryMoveSprint(boolean slowDown, float f, CallbackInfo ci) { + /** + * At settings.backKey.isPressed() + */ + @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;isPressed()Z", ordinal = 1)) + private void hookInventoryMoveSprint(CallbackInfo ci) { if (ModuleInventoryMove.INSTANCE.shouldHandleInputs(this.settings.sprintKey)) { this.settings.sprintKey.setPressed(InputTracker.INSTANCE.isPressedOnAny(this.settings.sprintKey)); } } - @Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/KeyboardInput;sneaking:Z", shift = At.Shift.AFTER), allow = 1) - private void injectMovementInputEvent(boolean slowDown, float f, CallbackInfo ci) { - var event = new MovementInputEvent(new DirectionalInput(this.pressingForward, this.pressingBack, this.pressingLeft, this.pressingRight), this.jumping, this.sneaking); + @Inject(method = "tick", at = @At("RETURN")) + private void injectMovementInputEvent(CallbackInfo ci) { + var event = new MovementInputEvent(new DirectionalInput(this.playerInput.forward(), this.playerInput.backward(), this.playerInput.left(), this.playerInput.right()), this.playerInput.jump(), this.playerInput.sneak()); EventManager.INSTANCE.callEvent(event); var directionalInput = event.getDirectionalInput(); - this.pressingForward = directionalInput.getForwards(); - this.pressingBack = directionalInput.getBackwards(); - this.pressingLeft = directionalInput.getLeft(); - this.pressingRight = directionalInput.getRight(); + playerInput = new PlayerInput(directionalInput.getForwards(), directionalInput.getBackwards(), directionalInput.getLeft(), directionalInput.getRight(), playerInput.jump(), playerInput.sneak(), playerInput.sprint()); this.movementForward = KeyboardInput.getMovementMultiplier(directionalInput.getForwards(), directionalInput.getBackwards()); this.movementSideways = KeyboardInput.getMovementMultiplier(directionalInput.getLeft(), directionalInput.getRight()); - this.fixStrafeMovement(); + this.liquid_bounce$fixStrafeMovement(); if (ModuleSuperKnockback.INSTANCE.shouldStopMoving()) { this.movementForward = 0f; @@ -93,11 +95,11 @@ private void injectMovementInputEvent(boolean slowDown, float f, CallbackInfo ci } } - this.jumping = event.getJumping(); - this.sneaking = event.getSneaking(); + playerInput = new PlayerInput(playerInput.forward(), playerInput.backward(), playerInput.left(), playerInput.right(), event.getJump(), event.getSneak(), playerInput.sprint()); } - private void fixStrafeMovement() { + @Unique + private void liquid_bounce$fixStrafeMovement() { ClientPlayerEntity player = MinecraftClient.getInstance().player; RotationManager rotationManager = RotationManager.INSTANCE; Rotation rotation = rotationManager.getCurrentRotation(); diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinMinecraftClient.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinMinecraftClient.java index bdd0652b459..99d9dc45edd 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinMinecraftClient.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinMinecraftClient.java @@ -21,6 +21,7 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import net.ccbluex.liquidbounce.LiquidBounce; +import net.ccbluex.liquidbounce.common.GlobalFramebuffer; import net.ccbluex.liquidbounce.event.EventManager; import net.ccbluex.liquidbounce.event.events.*; import net.ccbluex.liquidbounce.features.misc.HideAppearance; @@ -37,6 +38,7 @@ import net.ccbluex.liquidbounce.utils.combat.CombatManager; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gl.Framebuffer; import net.minecraft.client.gui.screen.AccessibilityOnboardingScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.TitleScreen; @@ -56,9 +58,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyConstant; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -314,14 +314,6 @@ private void hookWorldChangeEvent(ClientWorld world, CallbackInfo ci) { EventManager.INSTANCE.callEvent(new WorldChangeEvent(world)); } - /** - * Removes frame rate limit - */ - @ModifyConstant(method = "getFramerateLimit", constant = @Constant(intValue = 60)) - private int getFramerateLimit(int original) { - return getWindow().getFramerateLimit(); - } - @Inject(method = "render", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentFps:I", ordinal = 0, shift = At.Shift.AFTER)) private void hookFpsChange(CallbackInfo ci) { @@ -369,4 +361,12 @@ private boolean injectFixAttackCooldownOnVirtualBrowserScreen(MinecraftClient in this.currentScreen instanceof ModuleClickGui.ClickScreen); } + @Inject(method = "getFramebuffer", at = @At("HEAD"), cancellable = true) + private void hookSpoofFramebuffer(CallbackInfoReturnable cir) { + var framebuffer = GlobalFramebuffer.getSpoofedFramebuffer(); + if (framebuffer != null) { + cir.setReturnValue(framebuffer); + } + } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinMouse.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinMouse.java index 2502c959f2b..d67524a496b 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinMouse.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinMouse.java @@ -52,8 +52,8 @@ private void hookMouseScroll(long window, double horizontal, double vertical, Ca } @Inject(method = "onMouseScroll", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSpectator()Z", shift = At.Shift.BEFORE), cancellable = true) - private void hookMouseScroll(long window, double horizontal, double vertical, CallbackInfo ci, @Local(ordinal = 2) int k) { - if (EventManager.INSTANCE.callEvent(new MouseScrollInHotbarEvent(k)).isCancelled()) { + private void hookMouseScroll(long window, double horizontal, double vertical, CallbackInfo ci, @Local(ordinal = 0) int i) { + if (EventManager.INSTANCE.callEvent(new MouseScrollInHotbarEvent(i)).isCancelled()) { ci.cancel(); } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinTextHandler.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinTextHandler.java index 04681ab0d77..ee245589ddd 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinTextHandler.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinTextHandler.java @@ -15,7 +15,6 @@ * * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . - * */ package net.ccbluex.liquidbounce.injection.mixins.minecraft.client; diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinTranslationStorage.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinTranslationStorage.java index 31e97f606e8..23c74ad46d7 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinTranslationStorage.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinTranslationStorage.java @@ -1,3 +1,21 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ package net.ccbluex.liquidbounce.injection.mixins.minecraft.client; import net.ccbluex.liquidbounce.utils.client.VanillaTranslationRecognizer; diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinWindow.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinWindow.java index 5eed0f1020a..9354e7f91d7 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinWindow.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinWindow.java @@ -16,7 +16,6 @@ * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . */ - package net.ccbluex.liquidbounce.injection.mixins.minecraft.client; import net.ccbluex.liquidbounce.LiquidBounce; diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinWorld.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinWorld.java index 2ed04d2c734..ecd8f4e9cfc 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinWorld.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/client/MixinWorld.java @@ -16,7 +16,6 @@ * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . */ - package net.ccbluex.liquidbounce.injection.mixins.minecraft.client; import com.llamalad7.mixinextras.injector.ModifyReturnValue; diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinAbstractHorseEntity.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinAbstractHorseEntity.java index 933afd30e4f..db0b708338e 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinAbstractHorseEntity.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinAbstractHorseEntity.java @@ -18,7 +18,6 @@ * * */ - package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity; import com.llamalad7.mixinextras.injector.ModifyReturnValue; diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinClientPlayerEntity.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinClientPlayerEntity.java index 46586f9d2a8..b4eb9a3d22c 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinClientPlayerEntity.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinClientPlayerEntity.java @@ -16,7 +16,6 @@ * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . */ - package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; @@ -195,9 +194,9 @@ private boolean hookNetherClosingScreen(boolean original) { /** * Hook custom sneaking multiplier */ - @ModifyArg(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick(ZF)V", ordinal = 0), index = 1) - private float hookCustomSneakingMultiplier(float slowDownFactor) { - final PlayerSneakMultiplier playerSneakMultiplier = new PlayerSneakMultiplier(slowDownFactor); + @ModifyExpressionValue(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getAttributeValue(Lnet/minecraft/registry/entry/RegistryEntry;)D")) + private double hookCustomSneakingMultiplier(double original) { + var playerSneakMultiplier = new PlayerSneakMultiplier(original); EventManager.INSTANCE.callEvent(playerSneakMultiplier); return playerSneakMultiplier.getMultiplier(); } @@ -290,7 +289,7 @@ private boolean hookFreeCamPreventCreativeFly(boolean original) { return !ModuleFreeCam.INSTANCE.getRunning() && original; } - @ModifyVariable(method = "sendMovementPackets", at = @At("STORE"), ordinal = 2) + @ModifyVariable(method = "sendMovementPackets", at = @At("STORE"), ordinal = 1) private boolean hookFreeCamPreventRotations(boolean bl4) { return (!ModuleFreeCam.INSTANCE.shouldDisableRotations() || ModuleRotations.INSTANCE.shouldSendCustomRotation()) && bl4; } @@ -308,20 +307,21 @@ private boolean hookAutoSprint(boolean original) { @ModifyExpressionValue(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isWalking()Z")) private boolean hookOmnidirectionalSprintB(boolean original) { - return isOmniWalking(); + return liquid_bounce$isOmniWalking(); } - @ModifyExpressionValue(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasStatusEffect(Lnet/minecraft/registry/entry/RegistryEntry;)Z")) + @ModifyExpressionValue(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isBlind()Z")) private boolean hookSprintIgnoreBlindness(boolean original) { return !ModuleSprint.INSTANCE.shouldIgnoreBlindness() && original; } @ModifyExpressionValue(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isWalking()Z")) private boolean hookOmnidirectionalSprintC(boolean original) { - return isOmniWalking(); + return liquid_bounce$isOmniWalking(); } - private boolean isOmniWalking() { + @Unique + private boolean liquid_bounce$isOmniWalking() { boolean hasMovement = Math.abs(input.movementForward) > 1.0E-5F || Math.abs(input.movementSideways) > 1.0E-5F; boolean isWalking = (double) Math.abs(input.movementForward) >= 0.8 || (double) Math.abs(input.movementSideways) >= 0.8; boolean modifiedIsWalking = this.isSubmergedInWater() ? hasMovement : isWalking; diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinLivingEntity.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinLivingEntity.java index b6c17a16c27..f5f3579dbaf 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinLivingEntity.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinLivingEntity.java @@ -22,11 +22,8 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import net.ccbluex.liquidbounce.config.types.NoneChoice; import net.ccbluex.liquidbounce.event.EventManager; -import net.ccbluex.liquidbounce.event.events.PacketEvent; import net.ccbluex.liquidbounce.event.events.PlayerAfterJumpEvent; import net.ccbluex.liquidbounce.event.events.PlayerJumpEvent; -import net.ccbluex.liquidbounce.event.events.TransferOrigin; -import net.ccbluex.liquidbounce.features.command.commands.ingame.fakeplayer.FakePlayer; import net.ccbluex.liquidbounce.features.module.modules.movement.*; import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind; import net.ccbluex.liquidbounce.features.module.modules.render.ModuleRotations; @@ -34,24 +31,20 @@ import net.ccbluex.liquidbounce.utils.aiming.RotationManager; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.network.packet.s2c.play.EntityStatusS2CPacket; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; import net.minecraft.util.Hand; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; 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; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.Slice; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -69,7 +62,7 @@ public abstract class MixinLivingEntity extends MixinEntity { public abstract float getJumpVelocity(); @Shadow - protected abstract void jump(); + public abstract void jump(); @Shadow public abstract boolean hasStatusEffect(RegistryEntry effect); @@ -82,27 +75,53 @@ public abstract class MixinLivingEntity extends MixinEntity { @Shadow public abstract void setHealth(float health); - @Shadow - public abstract boolean addStatusEffect(StatusEffectInstance effect); @Shadow - public abstract boolean isFallFlying(); - + public abstract boolean isGliding(); /** - * Hook anti levitation module + * Disable [StatusEffects.LEVITATION] effect when [ModuleAntiLevitation] is enabled */ - @Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;hasStatusEffect(Lnet/minecraft/registry/entry/RegistryEntry;)Z")) - public boolean hookTravelStatusEffect(LivingEntity instance, RegistryEntry effect) { - if ((effect == StatusEffects.LEVITATION || effect == StatusEffects.SLOW_FALLING) && ModuleAntiLevitation.INSTANCE.getRunning()) { - if (instance.hasStatusEffect(effect)) { - instance.fallDistance = 0f; - } + @ModifyExpressionValue( + method = "travelMidAir", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/entity/LivingEntity;getStatusEffect(Lnet/minecraft/registry/entry/RegistryEntry;)Lnet/minecraft/entity/effect/StatusEffectInstance;", + ordinal = 0 + ), + require = 1, + allow = 1 + ) + public StatusEffectInstance hookTravelStatusEffect(StatusEffectInstance original) { + // If we get anyting other than levitation, the injection went wrong + assert original != StatusEffects.LEVITATION; + + if (ModuleAntiLevitation.INSTANCE.getRunning()) { + return null; + } + return original; + } + + /** + * Disable [StatusEffects.SLOW_FALLING] effect when [ModuleAntiLevitation] is enabled + */ + @ModifyExpressionValue( + method = "getEffectiveGravity", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/entity/LivingEntity;hasStatusEffect(Lnet/minecraft/registry/entry/RegistryEntry;)Z", + ordinal = 0 + ), + require = 1, + allow = 1 + ) + public boolean hookTravelStatusEffect(boolean original) { + if (ModuleAntiLevitation.INSTANCE.getRunning()) { return false; } - return instance.hasStatusEffect(effect); + return original; } @Inject(method = "hasStatusEffect", at = @At("HEAD"), cancellable = true) @@ -113,6 +132,19 @@ private void hookAntiNausea(RegistryEntry effect, CallbackInfoRetu } } + @Inject(method = "jump", at = @At("HEAD"), cancellable = true) + private void hookJumpEvent(CallbackInfo ci) { + if ((Object) this != MinecraftClient.getInstance().player) { + return; + } + + final PlayerJumpEvent jumpEvent = new PlayerJumpEvent(getJumpVelocity()); + EventManager.INSTANCE.callEvent(jumpEvent); + if (jumpEvent.isCancelled()) { + ci.cancel(); + } + } + @ModifyExpressionValue(method = "jump", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getJumpVelocity()F")) private float hookJumpEvent(float original) { if (((Object) this) != MinecraftClient.getInstance().player) { @@ -189,15 +221,15 @@ private void hookAirJump(CallbackInfo callbackInfo) { @Unique private boolean previousElytra = false; - @Inject(method = "tickFallFlying", at = @At("TAIL")) + @Inject(method = "tickGliding", at = @At("TAIL")) public void recastIfLanded(CallbackInfo callbackInfo) { if ((Object) this != MinecraftClient.getInstance().player) { return; } - var elytra = isFallFlying(); + var elytra = isGliding(); if (ModuleElytraRecast.INSTANCE.getRunning() && previousElytra && !elytra) { - MinecraftClient.getInstance().getSoundManager().stopSounds(SoundEvents.ITEM_ELYTRA_FLYING.getId(), + MinecraftClient.getInstance().getSoundManager().stopSounds(SoundEvents.ITEM_ELYTRA_FLYING.id(), SoundCategory.PLAYERS); ModuleElytraRecast.INSTANCE.recastElytra(); jumpingCooldown = 0; @@ -236,9 +268,9 @@ private float hookBodyRotationsB(float original) { } /** - * Fall flying using modified-rotation + * Gliding using modified-rotation */ - @ModifyExpressionValue(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getPitch()F")) + @ModifyExpressionValue(method = "calcGlidingVelocity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getPitch()F")) private float hookModifyFallFlyingPitch(float original) { if ((Object) this != MinecraftClient.getInstance().player) { return original; @@ -256,9 +288,9 @@ private float hookModifyFallFlyingPitch(float original) { } /** - * Fall flying using modified-rotation + * Gliding using modified-rotation */ - @ModifyExpressionValue(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getRotationVector()Lnet/minecraft/util/math/Vec3d;")) + @ModifyExpressionValue(method = "calcGlidingVelocity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getRotationVector()Lnet/minecraft/util/math/Vec3d;")) private Vec3d hookModifyFallFlyingRotationVector(Vec3d original) { if ((Object) this != MinecraftClient.getInstance().player) { return original; @@ -275,38 +307,4 @@ private Vec3d hookModifyFallFlyingRotationVector(Vec3d original) { return rotation.getRotationVec(); } - /** - * Allows instances of {@link FakePlayer} to pop infinite totems and - * bypass {@link net.minecraft.registry.tag.DamageTypeTags.BYPASSES_INVULNERABILITY} - * damage sources. - */ - @SuppressWarnings({"JavadocReference", "UnreachableCode"}) - @Inject(method = "tryUseTotem", at = @At(value = "HEAD"), cancellable = true) - private void hookTryUseTotem(DamageSource source, CallbackInfoReturnable cir) { - if (LivingEntity.class.cast(this) instanceof FakePlayer) { - addStatusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 900, 1)); - addStatusEffect(new StatusEffectInstance(StatusEffects.ABSORPTION, 100, 1)); - addStatusEffect(new StatusEffectInstance(StatusEffects.FIRE_RESISTANCE, 800, 0)); - setHealth(1.0F); - - EntityStatusS2CPacket packet = new EntityStatusS2CPacket(LivingEntity.class.cast(this), (byte) 35); - PacketEvent event = new PacketEvent(TransferOrigin.RECEIVE, packet, true); - EventManager.INSTANCE.callEvent(event); - if (!event.isCancelled()) { - packet.apply(MinecraftClient.getInstance().getNetworkHandler()); - } - - cir.setReturnValue(true); - } - } - - /** - * Allows instances of {@link FakePlayer} to get attacked. - */ - @SuppressWarnings("ConstantValue") - @Redirect(method = "damage", at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;isClient:Z", ordinal = 0)) - private boolean hookDamage(World world) { - return !(LivingEntity.class.cast(this) instanceof FakePlayer) && world.isClient; - } - } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinPlayerEntity.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinPlayerEntity.java index 833a02f178d..f58827a581b 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinPlayerEntity.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinPlayerEntity.java @@ -24,7 +24,6 @@ import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import net.ccbluex.liquidbounce.event.EventManager; import net.ccbluex.liquidbounce.event.events.PlayerEquipmentChangeEvent; -import net.ccbluex.liquidbounce.event.events.PlayerJumpEvent; import net.ccbluex.liquidbounce.event.events.PlayerSafeWalkEvent; import net.ccbluex.liquidbounce.event.events.PlayerStrideEvent; import net.ccbluex.liquidbounce.features.command.commands.ingame.fakeplayer.FakePlayer; @@ -76,8 +75,6 @@ private float hookStrideForce(float strideForce) { /** * Hook safe walk event - * - * @return */ @ModifyReturnValue(method = "clipAtLedge", at = @At("RETURN")) private boolean hookSafeWalk(boolean original) { @@ -125,19 +122,6 @@ private void hookNoClip(CallbackInfo ci) { } } - @Inject(method = "jump", at = @At("HEAD"), cancellable = true) - private void hookJumpEvent(CallbackInfo ci) { - if ((Object) this != MinecraftClient.getInstance().player) { - return; - } - - final PlayerJumpEvent jumpEvent = new PlayerJumpEvent(getJumpVelocity()); - EventManager.INSTANCE.callEvent(jumpEvent); - if (jumpEvent.isCancelled()) { - ci.cancel(); - } - } - @ModifyExpressionValue(method = "getBlockBreakingSpeed", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;hasStatusEffect(Lnet/minecraft/registry/entry/RegistryEntry;)Z")) private boolean injectFatigueNoSlow(boolean original) { diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinPlayerEntityAccessor.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinPlayerEntityAccessor.java index 158e6a547f9..bb26197f12c 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinPlayerEntityAccessor.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinPlayerEntityAccessor.java @@ -26,6 +26,7 @@ @Mixin(PlayerEntity.class) public interface MixinPlayerEntityAccessor { + /* * Used to get the TrackedData of the arm */ @@ -33,4 +34,5 @@ public interface MixinPlayerEntityAccessor { static TrackedData getTrackedMainArm() { throw new AssertionError(); } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/fluid/MixinFlowableFluid.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/fluid/MixinFlowableFluid.java index e1f127d4edd..199a2d4d6cc 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/fluid/MixinFlowableFluid.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/fluid/MixinFlowableFluid.java @@ -40,4 +40,5 @@ private boolean hookLiquidPush(boolean original) { EventManager.INSTANCE.callEvent(fluidPushEvent); return !fluidPushEvent.isCancelled(); } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinChatInputSuggestor.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinChatInputSuggestor.java index 52993a4428f..231c5ac2939 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinChatInputSuggestor.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinChatInputSuggestor.java @@ -48,7 +48,7 @@ public abstract class MixinChatInputSuggestor { @Shadow @Nullable private ChatInputSuggestor.@Nullable SuggestionWindow window; - @Inject(method = "refresh", at = @At(value = "INVOKE", target = "Lcom/mojang/brigadier/StringReader;canRead()Z"), cancellable = true) + @Inject(method = "refresh", at = @At(value = "INVOKE", target = "Lcom/mojang/brigadier/StringReader;canRead()Z", remap = false), cancellable = true) private void injectAutoCompletionB(CallbackInfo ci) { if (this.textField.getText().startsWith(CommandManager.Options.INSTANCE.getPrefix())) { this.pendingSuggestions = CommandManager.INSTANCE.autoComplete(this.textField.getText(), this.textField.getCursor()); diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinHandledScreen.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinHandledScreen.java index 29f91aad3b4..72bf6a3e139 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinHandledScreen.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinHandledScreen.java @@ -20,4 +20,5 @@ private void cancelMouseClick(Slot slot, int slotId, int button, SlotActionType ci.cancel(); } } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinInGameHud.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinInGameHud.java index 97ab96149f5..a039f358f5a 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinInGameHud.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinInGameHud.java @@ -28,7 +28,7 @@ import net.ccbluex.liquidbounce.integration.theme.component.ComponentOverlay; import net.ccbluex.liquidbounce.integration.theme.component.FeatureTweak; import net.ccbluex.liquidbounce.integration.theme.component.types.IntegratedComponent; -import net.ccbluex.liquidbounce.render.engine.UIRenderer; +import net.ccbluex.liquidbounce.render.engine.UiRenderer; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; @@ -52,8 +52,8 @@ public abstract class MixinInGameHud { @Final - @Shadow - private static Identifier PUMPKIN_BLUR; + @Unique + private static final Identifier liquid_bounce$PUMPKIN_BLUR = Identifier.ofVanilla("misc/pumpkinblur"); @Final @Shadow @@ -76,7 +76,7 @@ public abstract class MixinInGameHud { */ @Inject(method = "renderMainHud", at = @At("HEAD")) private void hookRenderEventStart(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { - UIRenderer.INSTANCE.startUIOverlayDrawing(context, tickCounter.getTickDelta(false)); + UiRenderer.INSTANCE.startUIOverlayDrawing(context, tickCounter.getTickDelta(false)); // Draw after overlay event var component = ComponentOverlay.getComponentWithTweak(FeatureTweak.TWEAK_HOTBAR); @@ -93,7 +93,7 @@ private void injectPumpkinBlur(DrawContext context, Identifier texture, float op return; } - if (module.getPumpkinBlur() && PUMPKIN_BLUR.equals(texture)) { + if (module.getPumpkinBlur() && liquid_bounce$PUMPKIN_BLUR.equals(texture)) { callback.cancel(); return; } @@ -120,7 +120,7 @@ private void hookRenderPortalOverlay(CallbackInfo ci) { } - @Inject(method = "renderScoreboardSidebar", at = @At("HEAD"), cancellable = true) + @Inject(method = "renderScoreboardSidebar*", at = @At("HEAD"), cancellable = true) private void renderScoreboardSidebar(CallbackInfo ci) { if (ComponentOverlay.isTweakEnabled(FeatureTweak.DISABLE_SCOREBOARD)) { ci.cancel(); @@ -230,4 +230,12 @@ private Perspective hookPerspectiveEventOnMiscOverlays(Perspective original) { return EventManager.INSTANCE.callEvent(new PerspectiveEvent(original)).getPerspective(); } + @Inject(method = "renderNauseaOverlay", at = @At("HEAD"), cancellable = true) + private void hookNauseaOverlay(DrawContext context, float distortionStrength, CallbackInfo ci) { + var antiBlind = ModuleAntiBlind.INSTANCE; + if (antiBlind.getRunning() && antiBlind.getAntiNausea()) { + ci.cancel(); + } + } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinScreen.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinScreen.java index 88113a4b4ee..a47fb81279a 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinScreen.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinScreen.java @@ -20,8 +20,8 @@ import com.llamalad7.mixinextras.sugar.Local; import net.ccbluex.liquidbounce.features.misc.HideAppearance; -import net.ccbluex.liquidbounce.utils.client.RunnableClickEvent; import net.ccbluex.liquidbounce.integration.theme.ThemeManager; +import net.ccbluex.liquidbounce.utils.client.RunnableClickEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; @@ -41,7 +41,6 @@ @Mixin(Screen.class) public abstract class MixinScreen { - @Shadow protected abstract void remove(Element child); @@ -81,7 +80,7 @@ private void renderBackgroundTexture(DrawContext context, int mouseX, int mouseY /** * Allows the execution of {@link RunnableClickEvent}. */ - @Inject(method = "handleTextClick", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", ordinal = 2, shift = At.Shift.BEFORE), cancellable = true) + @Inject(method = "handleTextClick", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", ordinal = 2, shift = At.Shift.BEFORE, remap = false), cancellable = true) private void hookExecuteClickEvents(Style style, CallbackInfoReturnable cir, @Local ClickEvent clickEvent) { if (clickEvent instanceof RunnableClickEvent runnableClickEvent) { runnableClickEvent.run(); diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinSignText.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinSignText.java deleted file mode 100644 index 382767d17b7..00000000000 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinSignText.java +++ /dev/null @@ -1,40 +0,0 @@ -package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui; - -import net.ccbluex.liquidbounce.utils.client.SignTranslationFixKt; -import net.minecraft.block.entity.SignText; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(SignText.class) -public class MixinSignText { - - - @Shadow - @Final - private Text[] messages; - - /** - * Fixes a vulnerability where the server can find out about the installed mods via translated text. - *

- * This is not the same fix as by https://modrinth.com/mod/moddetectionpreventer/ even if it fixes the same issue. - * In order to prevent further issues, we completely disallow creating a sign text with unknown translatable. - */ - @Inject(method = "([Lnet/minecraft/text/Text;[Lnet/minecraft/text/Text;Lnet/minecraft/util/DyeColor;Z)V", at = @At("RETURN")) - private void injectSignVulnerabilityFix(CallbackInfo ci) { - for (int i = 0; i < this.messages.length; i++) { - var msg = this.messages[i]; - - if (msg == null) { - continue; - } - - this.messages[i] = SignTranslationFixKt.filterNonVanillaText(msg); - } - } - -} diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinSplashOverlay.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinSplashOverlay.java index c8d526204e9..20bd714ac1d 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinSplashOverlay.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinSplashOverlay.java @@ -28,6 +28,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.SplashOverlay; +import net.minecraft.client.render.RenderLayer; import net.minecraft.resource.ResourceReload; import net.minecraft.util.Identifier; import net.minecraft.util.math.ColorHelper; @@ -36,6 +37,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.util.function.Function; import java.util.function.IntSupplier; /** @@ -65,7 +67,7 @@ public class MixinSplashOverlay { private void hookInit(CallbackInfo ci) { if (!HideAppearance.INSTANCE.isHidingNow()) { EventManager.INSTANCE.callEvent(new SplashOverlayEvent(true)); - BRAND_ARGB = () -> ColorHelper.Argb.getArgb(255, 24, 26, 27); + BRAND_ARGB = () -> ColorHelper.getArgb(255, 24, 26, 27); } else { BRAND_ARGB = () -> MinecraftClient.getInstance().options.getMonochromeLogo().getValue() ? MONOCHROME_BLACK : MOJANG_RED; } @@ -110,13 +112,10 @@ private void render(DrawContext context, int mouseX, int mouseY, float delta, Ca EventManager.INSTANCE.callEvent(new ScreenRenderEvent(context, delta)); } - @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIFFIIII)V")) - private boolean drawTexture(DrawContext instance, Identifier texture, int x, int y, int width, int height, - float u, float v, int regionWidth, int regionHeight, int textureWidth, int textureHeight) { + @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Ljava/util/function/Function;Lnet/minecraft/util/Identifier;IIFFIIIIIII)V")) + private boolean drawTexture(DrawContext instance, Function renderLayers, Identifier sprite, int x, int y, float u, float v, int width, int height, int regionWidth, int regionHeight, int textureWidth, int textureHeight, int color) { // do not draw texture - only when hiding return HideAppearance.INSTANCE.isHidingNow(); } - - } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinStringHelper.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinStringHelper.java index 3856a2c4075..0525e4fe740 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinStringHelper.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/MixinStringHelper.java @@ -16,11 +16,8 @@ * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . */ - package net.ccbluex.liquidbounce.injection.mixins.minecraft.gui; - -import net.minecraft.SharedConstants; import net.minecraft.util.StringHelper; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; @@ -30,9 +27,11 @@ public class MixinStringHelper { /** * @author superblaubeere27 + * @reason . */ @Overwrite public static boolean isValidChar(char chr) { return chr >= ' ' && chr != 127; } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/custom/MixinDisconnectedScreen.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/custom/MixinDisconnectedScreen.java index 7fd5b21b164..53ad696967d 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/custom/MixinDisconnectedScreen.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/gui/custom/MixinDisconnectedScreen.java @@ -74,7 +74,7 @@ private void injectButtons(final CallbackInfo callback) { addDrawableChild(disconnectButton); } - @Inject(method = "initTabNavigation", at = @At("HEAD")) + @Inject(method = "refreshWidgetPositions", at = @At("HEAD")) private void moveButtons(final CallbackInfo callback) { if (disconnectButton != null) { // fixes button position diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinArmorItem.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinArmorItem.java new file mode 100644 index 00000000000..23c21cd4cdf --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinArmorItem.java @@ -0,0 +1,57 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ +package net.ccbluex.liquidbounce.injection.mixins.minecraft.item; + +import net.ccbluex.liquidbounce.interfaces.ArmorItemAdditions; +import net.minecraft.item.ArmorItem; +import net.minecraft.item.Item; +import net.minecraft.item.equipment.ArmorMaterial; +import net.minecraft.item.equipment.EquipmentType; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ArmorItem.class) +public abstract class MixinArmorItem implements ArmorItemAdditions { + + @Unique + private ArmorMaterial liquid_bounce$armorMaterial; + + @Unique + private EquipmentType liquid_bounce$type; + + @Inject(method = "", at = @At("RETURN")) + public void hookCatchArgs(ArmorMaterial material, EquipmentType type, Item.Settings settings, CallbackInfo ci) { + this.liquid_bounce$armorMaterial = material; + this.liquid_bounce$type = type; + } + + @Override + public ArmorMaterial liquid_bounce$getMaterial() { + return liquid_bounce$armorMaterial; + } + + @Override + public EquipmentType liquid_bounce$getType() { + return liquid_bounce$type; + } + +} diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinHeldItemRenderer.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinHeldItemRenderer.java index aa06393f26d..57ad2695abe 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinHeldItemRenderer.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinHeldItemRenderer.java @@ -15,7 +15,6 @@ * * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . - * */ package net.ccbluex.liquidbounce.injection.mixins.minecraft.item; @@ -30,11 +29,13 @@ import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.HeldItemRenderer; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.item.SwordItem; +import net.minecraft.item.consume.UseAction; import net.minecraft.util.Arm; import net.minecraft.util.Hand; -import net.minecraft.util.UseAction; import net.minecraft.util.math.RotationAxis; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -78,7 +79,7 @@ private void hideShield(AbstractClientPlayerEntity player, float tickDelta, floa @Redirect(method = "renderFirstPersonItem", at = @At( value = "INVOKE", - target = "Lnet/minecraft/item/ItemStack;getUseAction()Lnet/minecraft/util/UseAction;", + target = "Lnet/minecraft/item/ItemStack;getUseAction()Lnet/minecraft/item/consume/UseAction;", ordinal = 0 )) private UseAction hookUseAction(ItemStack instance) { @@ -138,7 +139,7 @@ private int hookItemUseItem(AbstractClientPlayerEntity instance) { @ModifyArg(method = "renderFirstPersonItem", at = @At( value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applyEquipOffset(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Arm;F)V", - ordinal = 4 + ordinal = 3 ), index = 2) private float applyEquipOffset(float equipProgress) { if (ModuleAnimations.INSTANCE.getRunning() && !ModuleAnimations.INSTANCE.getEquipOffset()) { @@ -148,8 +149,24 @@ private float applyEquipOffset(float equipProgress) { return equipProgress; } + /** + * This transformation was previously a VFP option but got now added to minecraft directly. + * View the code that was used to disable the VFP option here: + * https://github.com/CCBlueX/LiquidBounce/blob/e5a0dbf5458b063d3028e69e04762b8b25b998b5/src/main/java/net/ccbluex/liquidbounce/utils/client/vfp/VfpCompatibility.java#L44 + */ + @ModifyExpressionValue(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getItem()Lnet/minecraft/item/Item;")) + private Item preventConflictingCode(Item item) { + // only applies to sword items, + // so that future items won't be affected if minecraft decides to actually make use out of this + if (item instanceof SwordItem) { + return Items.SHIELD; // makes the instanceof return true and therefore not do the transformation + } + + return item; + } + @Inject(method = "renderFirstPersonItem", - slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getUseAction()Lnet/minecraft/util/UseAction;")), + slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getUseAction()Lnet/minecraft/item/consume/UseAction;")), at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applyEquipOffset(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Arm;F)V", ordinal = 2, shift = At.Shift.AFTER)) private void transformLegacyBlockAnimations(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinItem.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinItem.java index a3e49089588..1555a656049 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinItem.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinItem.java @@ -24,13 +24,14 @@ import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleSwordBlock; import net.ccbluex.liquidbounce.utils.aiming.RotationManager; import net.minecraft.client.MinecraftClient; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.ConsumableComponent; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; +import net.minecraft.item.consume.UseAction; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; -import net.minecraft.util.UseAction; import net.minecraft.util.math.Vec3d; import net.minecraft.world.RaycastContext; import net.minecraft.world.World; @@ -44,12 +45,17 @@ public class MixinItem { @Inject(method = "use", at = @At("HEAD"), cancellable = true) private void hookSwordUse(World world, PlayerEntity user, Hand hand, - CallbackInfoReturnable> cir) { + CallbackInfoReturnable cir) { // Hooks sword use - only if main hand (otherwise this makes no sense on 1.8) if (((Object) this) instanceof SwordItem && ModuleSwordBlock.INSTANCE.getRunning() && !ModuleSwordBlock.INSTANCE.getOnlyVisual() && hand == Hand.MAIN_HAND) { var itemStack = user.getStackInHand(hand); user.setCurrentHand(hand); - cir.setReturnValue(TypedActionResult.consume(itemStack)); + ConsumableComponent consumableComponent = itemStack.get(DataComponentTypes.CONSUMABLE); + if (consumableComponent == null) { + return; + } + + cir.setReturnValue(consumableComponent.consume(user, itemStack, hand)); } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinItemStack.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinItemStack.java index 40a8851ab0c..74e80f5e1dc 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinItemStack.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinItemStack.java @@ -49,4 +49,5 @@ void injectLoreQueryEvent(TooltipContext context, @Nullable PlayerEntity player, EventManager.INSTANCE.callEvent(event); cir.setReturnValue(event.getLore()); } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinMiningToolItem.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinMiningToolItem.java new file mode 100644 index 00000000000..9120292f5a5 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/item/MixinMiningToolItem.java @@ -0,0 +1,48 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ +package net.ccbluex.liquidbounce.injection.mixins.minecraft.item; + +import net.ccbluex.liquidbounce.interfaces.MiningToolItemAddition; +import net.minecraft.item.Item; +import net.minecraft.item.MiningToolItem; +import net.minecraft.item.ToolMaterial; +import net.minecraft.registry.tag.TagKey; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(MiningToolItem.class) +public abstract class MixinMiningToolItem implements MiningToolItemAddition { + + @Unique + private ToolMaterial liquid_bounce$material; + + @Inject(method = "", at = @At("RETURN")) + public void hookCatchArgs(ToolMaterial material, TagKey effectiveBlocks, float attackDamage, float attackSpeed, Item.Settings settings, CallbackInfo ci) { + this.liquid_bounce$material = material; + } + + @Override + public ToolMaterial liquid_bounce$getMaterial() { + return liquid_bounce$material; + } + +} diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinClientLoginNetworkHandlerMixin.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinClientLoginNetworkHandlerMixin.java index 93faa18e4ed..1f72c0ccd79 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinClientLoginNetworkHandlerMixin.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinClientLoginNetworkHandlerMixin.java @@ -28,12 +28,11 @@ import net.minecraft.util.Formatting; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(ClientLoginNetworkHandler.class) public class MixinClientLoginNetworkHandlerMixin { - @ModifyExpressionValue(method = "onSuccess", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/ClientBrandRetriever;getClientModName()Ljava/lang/String;")) + @ModifyExpressionValue(method = "onSuccess", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/ClientBrandRetriever;getClientModName()Ljava/lang/String;", remap = false)) private String getClientModName(String original) { return ModuleSpoofer.INSTANCE.clientBrand(original); } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinClientPlayNetworkHandler.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinClientPlayNetworkHandler.java index 88468a2910e..a616316c741 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinClientPlayNetworkHandler.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinClientPlayNetworkHandler.java @@ -20,6 +20,7 @@ package net.ccbluex.liquidbounce.injection.mixins.minecraft.network; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.sugar.Local; import net.ccbluex.liquidbounce.common.ChunkUpdateFlag; import net.ccbluex.liquidbounce.config.types.Choice; import net.ccbluex.liquidbounce.event.EventManager; @@ -47,11 +48,10 @@ 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.ModifyArgs; import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import org.spongepowered.asm.mixin.injection.invoke.arg.Args; + +import java.util.Optional; @Mixin(ClientPlayNetworkHandler.class) public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkHandler { @@ -82,25 +82,24 @@ private void onChunkDeltaUpdateEnd(ChunkDeltaUpdateS2CPacket packet, CallbackInf ChunkUpdateFlag.chunkUpdate = false; } - @ModifyArgs(method = "onExplosion", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/Vec3d;add(DDD)Lnet/minecraft/util/math/Vec3d;")) - private void onExplosionVelocity(Args args) { - double x = args.get(0); - double y = args.get(1); - double z = args.get(2); - - if (ModuleAntiExploit.INSTANCE.getRunning() && ModuleAntiExploit.INSTANCE.getLimitExplosionStrength()) { - double fixedX = MathHelper.clamp(x, -10.0, 10.0); - double fixedY = MathHelper.clamp(y, -10.0, 10.0); - double fixedZ = MathHelper.clamp(z, -10.0, 10.0); - - if (fixedX != x || fixedY != y || fixedZ != z) { + @SuppressWarnings("OptionalUsedAsFieldOrParameterType") + @ModifyExpressionValue(method = "onExplosion", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/ExplosionS2CPacket;playerKnockback()Ljava/util/Optional;")) + private Optional onExplosionVelocity(Optional original) { + var present = original.isPresent(); + if (present && ModuleAntiExploit.INSTANCE.getRunning() && ModuleAntiExploit.INSTANCE.getLimitExplosionStrength()) { + var vec = original.get(); + double fixedX = MathHelper.clamp(vec.x, -10.0, 10.0); + double fixedY = MathHelper.clamp(vec.y, -10.0, 10.0); + double fixedZ = MathHelper.clamp(vec.z, -10.0, 10.0); + + if (fixedX != vec.x || fixedY != vec.y || fixedZ != vec.z) { ModuleAntiExploit.INSTANCE.notifyAboutExploit("Limited too strong explosion", true); - args.set(0, fixedX); - args.set(1, fixedY); - args.set(2, fixedZ); + return Optional.of(new Vec3d(fixedX, fixedY, fixedZ)); } } + + return original; } @ModifyExpressionValue(method = "onParticle", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/ParticleS2CPacket;getCount()I", ordinal = 1)) @@ -121,18 +120,6 @@ private float onParticleSpeed(float original) { return original; } - @ModifyExpressionValue(method = "onExplosion", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/ExplosionS2CPacket;getRadius()F")) - private float onExplosionWorld(float original) { - if (ModuleAntiExploit.INSTANCE.getRunning() && ModuleAntiExploit.INSTANCE.getLimitExplosionRange()) { - float radius = MathHelper.clamp(original, -1000.0f, 1000.0f); - if (radius != original) { - ModuleAntiExploit.INSTANCE.notifyAboutExploit("Limited too big TNT explosion radius", true); - return radius; - } - } - return original; - } - @ModifyExpressionValue(method = "onGameStateChange", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/GameStateChangeS2CPacket;getReason()Lnet/minecraft/network/packet/s2c/play/GameStateChangeS2CPacket$Reason;")) private GameStateChangeS2CPacket.Reason onGameStateChange(GameStateChangeS2CPacket.Reason original) { if (ModuleAntiExploit.INSTANCE.getRunning() && original == GameStateChangeS2CPacket.DEMO_MESSAGE_SHOWN && ModuleAntiExploit.INSTANCE.getCancelDemo()) { @@ -158,19 +145,19 @@ private void injectHealthUpdate(HealthUpdateS2CPacket packet, CallbackInfo ci) { } } - @Inject(method = "onPlayerPositionLook", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;setVelocity(DDD)V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD) - private void injectNoRotateSet(PlayerPositionLookS2CPacket packet, CallbackInfo ci, PlayerEntity playerEntity, Vec3d vec3d, boolean bl, boolean bl2, boolean bl3, double d, double e, double f, double g, double h, double i) { - float j = packet.getYaw(); - float k = packet.getPitch(); + @Inject(method = "onPlayerPositionLook", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;setPosition(Lnet/minecraft/entity/player/PlayerPosition;Ljava/util/Set;Lnet/minecraft/entity/Entity;Z)Z", shift = At.Shift.AFTER)) + private void injectNoRotateSet(PlayerPositionLookS2CPacket packet, CallbackInfo ci, @Local PlayerEntity playerEntity) { + float j = packet.change().yaw(); + float k = packet.change().pitch(); if (!ModuleNoRotateSet.INSTANCE.getRunning() || MinecraftClient.getInstance().currentScreen instanceof DownloadingTerrainScreen) { return; } // Confirm teleport - this.connection.send(new TeleportConfirmC2SPacket(packet.getTeleportId())); + this.connection.send(new TeleportConfirmC2SPacket(packet.teleportId())); // Silently accept yaw and pitch values requested by the server. - this.connection.send(new PlayerMoveC2SPacket.Full(playerEntity.getX(), playerEntity.getY(), playerEntity.getZ(), j, k, false)); + this.connection.send(new PlayerMoveC2SPacket.Full(playerEntity.getX(), playerEntity.getY(), playerEntity.getZ(), j, k, false, playerEntity.horizontalCollision)); Choice activeChoice = ModuleNoRotateSet.INSTANCE.getMode().getActiveChoice(); if (activeChoice.equals(ModuleNoRotateSet.ResetRotation.INSTANCE)) { // Changes your server side rotation and then resets it with provided settings diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinPlayerListEntry.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinPlayerListEntry.java index 025a6b03662..45782c0945c 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinPlayerListEntry.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/network/MixinPlayerListEntry.java @@ -53,10 +53,11 @@ private void injectCapeCosmetic(CallbackInfoReturnable callbackInf return; } - fetchCapeTexture(); + liquid_bounce$fetchCapeTexture(); } - private void fetchCapeTexture() { + @Unique + private void liquid_bounce$fetchCapeTexture() { if (capeTextureLoading) return; diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/registry/MixinRegistries.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/registry/MixinRegistries.java index d17ba2d3949..a72d0304c68 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/registry/MixinRegistries.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/registry/MixinRegistries.java @@ -33,4 +33,5 @@ public class MixinRegistries { private static void injectInitializeTabs(CallbackInfo ci) { ClientItemGroups.INSTANCE.setup(); } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinBackgroundRenderer.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinBackgroundRenderer.java index a3943639ad6..91864f3b2c9 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinBackgroundRenderer.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinBackgroundRenderer.java @@ -19,22 +19,19 @@ package net.ccbluex.liquidbounce.injection.mixins.minecraft.render; -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.mojang.blaze3d.systems.RenderSystem; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import com.llamalad7.mixinextras.sugar.Local; import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind; import net.ccbluex.liquidbounce.features.module.modules.render.ModuleCustomAmbience; import net.minecraft.block.enums.CameraSubmersionType; import net.minecraft.client.render.BackgroundRenderer; -import net.minecraft.client.render.BackgroundRenderer.FogType; import net.minecraft.client.render.Camera; +import net.minecraft.client.render.Fog; import net.minecraft.entity.effect.StatusEffects; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArgs; import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.invoke.arg.Args; import java.util.List; import java.util.stream.Stream; @@ -42,6 +39,9 @@ @Mixin(BackgroundRenderer.class) public abstract class MixinBackgroundRenderer { + @Shadow + private static boolean fogEnabled; + @Redirect(method = "getFogModifier", at = @At(value = "INVOKE", target = "Ljava/util/List;stream()Ljava/util/stream/Stream;")) private static Stream injectAntiBlind(List list) { return list.stream().filter(modifier -> { @@ -58,50 +58,33 @@ private static Stream injectAntiBlin }); } - @Inject(method = "applyFog", at = @At(value = "INVOKE", shift = At.Shift.AFTER, ordinal = 0, target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderFogEnd(F)V", remap = false)) - private static void injectLiquidsFog(Camera camera, FogType fogType, float viewDistance, boolean thickFog, float tickDelta, CallbackInfo info) { + @ModifyReturnValue(method = "applyFog", at = @At("RETURN")) + private static Fog injectFog(Fog original, @Local(argsOnly = true) Camera camera, @Local(argsOnly = true, ordinal = 0) float viewDistance) { var antiBlind = ModuleAntiBlind.INSTANCE; - var customAmbienceFog = ModuleCustomAmbience.Fog.INSTANCE; - if (!antiBlind.getRunning() || customAmbienceFog.getRunning()) { - return; + var customAmbienceFog = ModuleCustomAmbience.FogConfigurable.INSTANCE; + if (!antiBlind.getRunning() || customAmbienceFog.getRunning() || !fogEnabled) { + return ModuleCustomAmbience.FogConfigurable.INSTANCE.modifyFog(camera, viewDistance, original); } CameraSubmersionType type = camera.getSubmersionType(); if (antiBlind.getPowderSnowFog() && type == CameraSubmersionType.POWDER_SNOW) { - RenderSystem.setShaderFogStart(-8.0F); - RenderSystem.setShaderFogEnd(viewDistance * 0.5F); - return; + return new Fog(-8f, viewDistance * 0.5f, original.shape(), original.red(), original.green(), original.blue(), original.alpha()); } if (antiBlind.getLiquidsFog()) { // Renders fog same as spectator. switch (type) { case LAVA -> { - RenderSystem.setShaderFogStart(-8.0F); - RenderSystem.setShaderFogEnd(viewDistance * 0.5F); + return new Fog(-8f, viewDistance * 0.5f, original.shape(), original.red(), original.green(), original.blue(), original.alpha()); } case WATER -> { - RenderSystem.setShaderFogStart(-8.0F); - RenderSystem.setShaderFogEnd(viewDistance); + return new Fog(-8f, viewDistance, original.shape(), original.red(), original.green(), original.blue(), original.alpha()); } } } - } - - @Inject(method = "applyFog", at = @At("RETURN")) - private static void injectFog(Camera camera, FogType fogType, float viewDistance, boolean thickFog, float tickDelta, CallbackInfo ci) { - ModuleCustomAmbience.Fog.INSTANCE.modifyFog(camera, viewDistance); - } - - @Inject(method = "applyFogColor", at = @At("RETURN")) - private static void injectFog(CallbackInfo ci) { - ModuleCustomAmbience.Fog.INSTANCE.modifyFogColor(); - } - @ModifyArgs(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;clearColor(FFFF)V")) - private static void injectFog(Args args) { - ModuleCustomAmbience.Fog.INSTANCE.modifySetColorArgs(args); + return original; } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinChunkOcclusionDataBuilder.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinChunkOcclusionDataBuilder.java index 1c55d75412f..4b0fa74218b 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinChunkOcclusionDataBuilder.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinChunkOcclusionDataBuilder.java @@ -30,7 +30,7 @@ public class MixinChunkOcclusionDataBuilder { @Inject(method = "markClosed", at = @At("HEAD"), cancellable = true) private void onMarkClosed(BlockPos pos, CallbackInfo cir) { - if(ModuleXRay.INSTANCE.getRunning()) { + if (ModuleXRay.INSTANCE.getRunning()) { cir.cancel(); } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinEntityRenderDispatcher.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinEntityRenderDispatcher.java index a7bd6ca1323..290866d8c41 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinEntityRenderDispatcher.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinEntityRenderDispatcher.java @@ -42,7 +42,7 @@ private static void getEntity(MatrixStack matrices, VertexConsumer vertices, Ent MixinEntityRenderDispatcher.entity = entity; } - @ModifyArg(method = "renderHitbox", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;drawBox(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/util/math/Box;FFFF)V", ordinal = 0), index = 2, require = 1, allow = 1) + @ModifyArg(method = "renderHitbox", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/VertexRendering;drawBox(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/util/math/Box;FFFF)V", ordinal = 0), index = 2, require = 1, allow = 1) private static Box updateBoundingBox(Box box) { var moduleHitBox = ModuleHitbox.INSTANCE; if (moduleHitBox.getRunning() && CombatExtensionsKt.shouldBeAttacked(entity, CombatExtensionsKt.getCombatTargetsConfigurable())) { diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinEntityRenderer.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinEntityRenderer.java index 6eaf5142709..4b82a6cf14a 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinEntityRenderer.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinEntityRenderer.java @@ -16,18 +16,19 @@ * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . */ - package net.ccbluex.liquidbounce.injection.mixins.minecraft.render; import net.ccbluex.liquidbounce.features.module.modules.render.ModuleCombineMobs; import net.ccbluex.liquidbounce.features.module.modules.render.ModuleMobOwners; import net.ccbluex.liquidbounce.features.module.modules.render.nametags.ModuleNametags; +import net.ccbluex.liquidbounce.interfaces.EntityRenderStateAddition; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.render.Frustum; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRenderer; +import net.minecraft.client.render.entity.state.EntityRenderState; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; import net.minecraft.text.OrderedText; @@ -43,7 +44,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(EntityRenderer.class) -public abstract class MixinEntityRenderer { +public abstract class MixinEntityRenderer { @Shadow @Final @@ -60,8 +61,8 @@ private void shouldRender(T entity, Frustum frustum, double x, double y, double } @Inject(method = "render", at = @At("HEAD")) - private void renderMobOwners(T entity, float yaw, float tickDelta, MatrixStack matrices, - VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + private void renderMobOwners(S state, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + var entity = ((EntityRenderStateAddition) state).liquid_bounce$getEntity(); var ownerName = ModuleMobOwners.INSTANCE.getOwnerInfoText(entity); if (ownerName != null) { @@ -98,11 +99,17 @@ private void renderLabel(Entity entity, OrderedText text, MatrixStack matrices, } @Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true) - private void disableDuplicateNametagsAndInjectMobOwners(T entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, float tickDelta, CallbackInfo ci) { + private void disableDuplicateNametagsAndInjectMobOwners(S state, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { // Don't render nametags + var entity = ((EntityRenderStateAddition) state).liquid_bounce$getEntity(); if (ModuleNametags.INSTANCE.getRunning() && ModuleNametags.shouldRenderNametag(entity)) { ci.cancel(); } } + @Inject(method = "updateRenderState", at = @At("HEAD")) + private void hookInjectEntityIntoState(T entity, S state, float tickDelta, CallbackInfo ci) { + ((EntityRenderStateAddition) state).liquid_bounce$setEntity(entity); + } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinGameRenderer.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinGameRenderer.java index 052c4095ff8..946198212c5 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinGameRenderer.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinGameRenderer.java @@ -21,8 +21,6 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.llamalad7.mixinextras.sugar.Local; -import com.mojang.blaze3d.systems.RenderSystem; -import net.ccbluex.liquidbounce.LiquidBounce; import net.ccbluex.liquidbounce.event.EventManager; import net.ccbluex.liquidbounce.event.events.GameRenderEvent; import net.ccbluex.liquidbounce.event.events.PerspectiveEvent; @@ -33,15 +31,15 @@ import net.ccbluex.liquidbounce.features.module.modules.render.*; import net.ccbluex.liquidbounce.features.module.modules.world.ModuleLiquidPlace; import net.ccbluex.liquidbounce.interfaces.LightmapTextureManagerAddition; -import net.ccbluex.liquidbounce.interfaces.PostEffectPassTextureAddition; -import net.ccbluex.liquidbounce.render.engine.UIRenderer; +import net.ccbluex.liquidbounce.render.engine.UiRenderer; import net.ccbluex.liquidbounce.render.shader.shaders.OutlineEffectShader; import net.ccbluex.liquidbounce.utils.aiming.RaytracingExtensionsKt; import net.ccbluex.liquidbounce.utils.aiming.Rotation; import net.ccbluex.liquidbounce.utils.aiming.RotationManager; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gl.PostEffectProcessor; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.ChatScreen; +import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.option.Perspective; import net.minecraft.client.render.Camera; import net.minecraft.client.render.GameRenderer; @@ -49,10 +47,7 @@ import net.minecraft.client.render.RenderTickCounter; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RotationAxis; @@ -62,7 +57,6 @@ import org.spongepowered.asm.mixin.Final; 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; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -77,16 +71,6 @@ public abstract class MixinGameRenderer { @Shadow public abstract MinecraftClient getClient(); - @Shadow - @Final - private ResourceManager resourceManager; - /** - * UI Blur Post Effect Processor - * - * @author superblaubeere27 - */ - @Unique - private PostEffectProcessor blurPostEffectProcessor; @Shadow @Final private Camera camera; @@ -139,7 +123,7 @@ private Vec3d hookRotationVector(Vec3d original, Entity camera, double blockInte * Hook world render event */ @Inject(method = "renderWorld", at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/GameRenderer;renderHand:Z", opcode = Opcodes.GETFIELD, ordinal = 0)) - public void hookWorldRender(RenderTickCounter tickCounter, CallbackInfo ci, @Local(ordinal = 1) Matrix4f matrix4f2) { + public void hookWorldRender(RenderTickCounter tickCounter, CallbackInfo ci, @Local(ordinal = 2) Matrix4f matrix4f2) { // TODO: Improve this var newMatStack = new MatrixStack(); @@ -160,7 +144,7 @@ public void prepareItemCharms(Camera camera, float tickDelta, Matrix4f matrix4f, public void drawItemCharms(Camera camera, float tickDelta, Matrix4f matrix4f, CallbackInfo ci) { if (ModuleItemChams.INSTANCE.getActive()) { ModuleItemChams.INSTANCE.setActive(false); - OutlineEffectShader.INSTANCE.apply(); + OutlineEffectShader.INSTANCE.apply(true); } } @@ -192,14 +176,14 @@ private void injectBobView(MatrixStack matrixStack, float f, CallbackInfo callba return; } - if (!(client.getCameraEntity() instanceof PlayerEntity playerEntity)) { + if (!(client.getCameraEntity() instanceof AbstractClientPlayerEntity playerEntity)) { return; } float additionalBobbing = ModuleDankBobbing.INSTANCE.getMotion(); - float g = playerEntity.horizontalSpeed - playerEntity.prevHorizontalSpeed; - float h = -(playerEntity.horizontalSpeed + g * f); + float g = playerEntity.distanceMoved - playerEntity.lastDistanceMoved; + float h = -(playerEntity.distanceMoved + g * f); float i = MathHelper.lerp(f, playerEntity.prevStrideDistance, playerEntity.strideDistance); matrixStack.translate((MathHelper.sin(h * MathHelper.PI) * i * 0.5F), -Math.abs(MathHelper.cos(h * MathHelper.PI) * i), 0.0D); matrixStack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(MathHelper.sin(h * MathHelper.PI) * i * (3.0F + additionalBobbing))); @@ -210,59 +194,19 @@ private void injectBobView(MatrixStack matrixStack, float f, CallbackInfo callba @Inject(method = "onResized", at = @At("HEAD")) private void injectResizeUIBlurShader(int width, int height, CallbackInfo ci) { - if (this.blurPostEffectProcessor != null) { - this.blurPostEffectProcessor.setupDimensions(width, height); - } - - UIRenderer.INSTANCE.setupDimensions(width, height); - } - - @Inject(method = "loadPrograms", at = @At("TAIL")) - private void hookUIBlurLoad(final CallbackInfo ci) { - if (this.blurPostEffectProcessor == null) { - try { - var identifier = Identifier.of("liquidbounce", "shaders/post/ui_blur.json"); - - this.blurPostEffectProcessor = new PostEffectProcessor(this.client.getTextureManager(), this.resourceManager, - this.client.getFramebuffer(), identifier); - this.blurPostEffectProcessor.setupDimensions(this.client.getWindow().getFramebufferWidth(), - this.client.getWindow().getFramebufferHeight()); - } catch (final Exception e) { - LiquidBounce.INSTANCE.getLogger().error("Failed to load UI blur shader", e); - } - } - } - - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;drawEntityOutlinesFramebuffer()V", shift = At.Shift.AFTER)) - private void injectUIBlurRender(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci) { - if (!ModuleHud.INSTANCE.isBlurable() || this.blurPostEffectProcessor == null) { - return; - } - - RenderSystem.disableBlend(); - RenderSystem.disableDepthTest(); - RenderSystem.resetTextureMatrix(); - - var overlayFramebuffer = UIRenderer.INSTANCE.getOverlayFramebuffer(); - var overlayTexture = overlayFramebuffer.getColorAttachment(); - - overlayFramebuffer.beginRead(); - - RenderSystem.setShaderTexture(0, overlayTexture); - ((PostEffectPassTextureAddition) this.blurPostEffectProcessor.passes.get(0)).liquid_bounce$setTextureSampler("Overlay", overlayTexture); - this.blurPostEffectProcessor.passes.get(0).getProgram().getUniformByName("Radius").set(UIRenderer.INSTANCE.getBlurRadius()); - - this.blurPostEffectProcessor.render(tickCounter.getTickDelta(false)); + UiRenderer.INSTANCE.setupDimensions(width, height); } @Inject(method = "render", at = @At(value = "RETURN")) private void hookRenderEventStop(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci) { - UIRenderer.INSTANCE.endUIOverlayDrawing(); + UiRenderer.INSTANCE.endUIOverlayDrawing(); } - @Inject(method = "renderBlur", at = @At("HEAD")) + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/client/gui/DrawContext;IIF)V", shift = At.Shift.BEFORE)) private void injectRenderBlur(CallbackInfo ci) { - UIRenderer.INSTANCE.endUIOverlayDrawing(); + if (!(client.currentScreen instanceof ChatScreen)) { + UiRenderer.INSTANCE.endUIOverlayDrawing(); + } } @Inject(method = "showFloatingItem", at = @At("HEAD"), cancellable = true) @@ -294,14 +238,6 @@ private int hookGetFov(int original) { return result; } - @Inject(method = "renderNausea", at = @At("HEAD"), cancellable = true) - private void hookNauseaOverlay(DrawContext context, float distortionStrength, CallbackInfo ci) { - var antiBlind = ModuleAntiBlind.INSTANCE; - if (antiBlind.getRunning() && antiBlind.getAntiNausea()) { - ci.cancel(); - } - } - @ModifyExpressionValue(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;lerp(FFF)F")) private float hookNausea(float original) { var antiBlind = ModuleAntiBlind.INSTANCE; @@ -333,11 +269,11 @@ private Perspective hookPerspectiveEventOnHand(Perspective original) { } @ModifyReturnValue(method = "getFov", at = @At("RETURN")) - private double injectShit(double original) { + private float injectShit(float original) { var screen = ModuleDroneControl.INSTANCE.getScreen(); if (screen != null) { - return Math.min(120.0, original / screen.getZoomFactor()); + return Math.min(120f, original / screen.getZoomFactor()); } return original; diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinInGameOverlayRenderer.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinInGameOverlayRenderer.java index 982501dac64..0161a856f78 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinInGameOverlayRenderer.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinInGameOverlayRenderer.java @@ -22,6 +22,7 @@ import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind; import net.minecraft.client.gui.hud.InGameOverlayRenderer; import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.texture.Sprite; import net.minecraft.client.util.math.MatrixStack; import org.spongepowered.asm.mixin.Mixin; @@ -42,7 +43,7 @@ private static VertexConsumer injectFireOpacity(VertexConsumer vertexConsumer, f } @Inject(method = "renderInWallOverlay", at = @At("HEAD"), cancellable = true) - private static void hookWallOverlay(Sprite sprite, MatrixStack matrices, CallbackInfo ci) { + private static void hookWallOverlay(Sprite sprite, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo ci) { var antiBlind = ModuleAntiBlind.INSTANCE; if (antiBlind.getRunning() && antiBlind.getWallOverlay()) { ci.cancel(); diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinInactivityFpsLimiter.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinInactivityFpsLimiter.java new file mode 100644 index 00000000000..4c14448c7a9 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinInactivityFpsLimiter.java @@ -0,0 +1,41 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2024 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 . + */ +package net.ccbluex.liquidbounce.injection.mixins.minecraft.render; + +import net.minecraft.client.option.InactivityFpsLimiter; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(InactivityFpsLimiter.class) +public abstract class MixinInactivityFpsLimiter { + + @Shadow + private int maxFps; + + /** + * Removes frame rate limit + */ + @ModifyConstant(method = "update", constant = @Constant(intValue = 60)) + private int getFramerateLimit(int original) { + return maxFps; + } + +} diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinItemRender.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinItemRender.java index 1134865e5d4..e94b9f6d7b2 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinItemRender.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinItemRender.java @@ -21,24 +21,24 @@ import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleSwordBlock; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.ItemRenderer; -import net.minecraft.client.render.model.json.ModelTransformationMode; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.item.ModelTransformationMode; import net.minecraft.world.World; 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 static net.minecraft.client.render.model.json.ModelTransformationMode.THIRD_PERSON_LEFT_HAND; -import static net.minecraft.client.render.model.json.ModelTransformationMode.THIRD_PERSON_RIGHT_HAND; +import static net.minecraft.item.ModelTransformationMode.THIRD_PERSON_LEFT_HAND; +import static net.minecraft.item.ModelTransformationMode.THIRD_PERSON_RIGHT_HAND; @Mixin(ItemRenderer.class) public class MixinItemRender { - @Inject(method = "renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;III)V", at = @At("HEAD"), cancellable = true) + @Inject(method = "renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;III)V", at = @At("HEAD"), cancellable = true) private void hookRenderItem(LivingEntity entity, ItemStack item, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, World world, int light, int overlay, int seed, CallbackInfo ci) { if (renderMode == (leftHanded ? THIRD_PERSON_LEFT_HAND : THIRD_PERSON_RIGHT_HAND) && entity instanceof PlayerEntity player && ModuleSwordBlock.INSTANCE.shouldHideOffhand(player, item.getItem())) { ci.cancel(); diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinLightmapTextureManager.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinLightmapTextureManager.java index 59a64a2350c..c52d6dc370c 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinLightmapTextureManager.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinLightmapTextureManager.java @@ -19,15 +19,15 @@ package net.ccbluex.liquidbounce.injection.mixins.minecraft.render; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.mojang.blaze3d.systems.RenderSystem; import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind; import net.ccbluex.liquidbounce.features.module.modules.render.ModuleCustomAmbience; import net.ccbluex.liquidbounce.features.module.modules.render.ModuleFullBright; import net.ccbluex.liquidbounce.features.module.modules.render.ModuleXRay; import net.ccbluex.liquidbounce.interfaces.LightmapTextureManagerAddition; +import net.minecraft.client.gl.SimpleFramebuffer; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.render.LightmapTextureManager; -import net.minecraft.client.texture.NativeImage; -import net.minecraft.client.texture.NativeImageBackedTexture; import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.registry.entry.RegistryEntry; @@ -37,32 +37,18 @@ import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(LightmapTextureManager.class) public abstract class MixinLightmapTextureManager implements LightmapTextureManagerAddition { - @Shadow - @Final - private NativeImage image; - - @Shadow @Final - private NativeImageBackedTexture texture; - @Shadow - private boolean dirty; - - @Unique - private final int[] liquid_bounce$originalLightColor = new int[256]; - - @Unique - private short liquid_bounce$currentIndex = 0; + private SimpleFramebuffer lightmapFramebuffer; @Unique - private boolean liquid_bounce$dirty = false; + private boolean liquid_bounce$customLightMap = false; @ModifyExpressionValue(method = "update(F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/SimpleOption;getValue()Ljava/lang/Object;", ordinal = 1)) private Object injectXRayFullBright(Object original) { @@ -82,54 +68,45 @@ private Object injectXRayFullBright(Object original) { return (double) Float.MAX_VALUE; } - @Inject(method = "update(F)V", at = @At(value = "HEAD")) + @Inject(method = "update(F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;pop()V")) private void hookBlendTextureColors(float delta, CallbackInfo ci) { - if (!dirty && ModuleCustomAmbience.CustomLightColor.INSTANCE.getRunning()) { - liquid_bounce$dirty = true; - liquid_bounce$currentIndex = 0; - for (int y = 0; y < 16; y++) { - for (int x = 0; x < 16; x++) { - image.setColor(x, y, ModuleCustomAmbience.CustomLightColor.INSTANCE.blendWithLightColor(liquid_bounce$originalLightColor[liquid_bounce$currentIndex])); - liquid_bounce$currentIndex++; - } - } - texture.upload(); + var lightColor = ModuleCustomAmbience.CustomLightColor.INSTANCE; + if (lightColor.getRunning()) { + lightColor.update(); } } - @Inject(method = "update(F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/GameOptions;getDarknessEffectScale()Lnet/minecraft/client/option/SimpleOption;")) + @Inject(method = "update(F)V", at = @At(value = "HEAD")) private void hookResetIndex(float delta, CallbackInfo ci) { - if (ModuleCustomAmbience.CustomLightColor.INSTANCE.getRunning()) { - liquid_bounce$dirty = true; - liquid_bounce$currentIndex = 0; + var customLightColor = ModuleCustomAmbience.CustomLightColor.INSTANCE; + if (customLightColor.getRunning()) { + liquid_bounce$customLightMap = true; + if (RenderSystem.getShaderTexture(2) == lightmapFramebuffer.getColorAttachment()) { + RenderSystem.setShaderTexture(2, customLightColor.getFramebuffer().getColorAttachment()); + } } } - @ModifyArg(method = "update(F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/NativeImage;setColor(III)V"), index = 2) - private int cacheAndModifyTextureColor(int color) { - if (liquid_bounce$dirty) { - liquid_bounce$originalLightColor[liquid_bounce$currentIndex] = color; - liquid_bounce$currentIndex++; - return ModuleCustomAmbience.CustomLightColor.INSTANCE.blendWithLightColor(color); + @Inject(method = "enable", at = @At("HEAD"), cancellable = true) + private void hookSpoof(CallbackInfo ci) { + if (liquid_bounce$customLightMap) { + RenderSystem.setShaderTexture(2, ModuleCustomAmbience.CustomLightColor.INSTANCE.getFramebuffer().getColorAttachment()); + ci.cancel(); } - - return color; } @Unique @Override public void liquid_bounce$restoreLightMap() { - if (liquid_bounce$dirty) { - liquid_bounce$dirty = false; - liquid_bounce$currentIndex = 0; - for (int y = 0; y < 16; y++) { - for (int x = 0; x < 16; x++) { - image.setColor(x, y, liquid_bounce$originalLightColor[liquid_bounce$currentIndex]); - liquid_bounce$currentIndex++; - } - } - texture.upload(); + if (RenderSystem.getShaderTexture(2) != 0) { + RenderSystem.setShaderTexture(2, lightmapFramebuffer.getColorAttachment()); } + liquid_bounce$customLightMap = false; + } + + @Inject(method = "close", at = @At("HEAD")) + private void hookClose(CallbackInfo ci) { + ModuleCustomAmbience.CustomLightColor.INSTANCE.close(); } // Turns off blinking when the darkness effect is active. diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinLivingEntityRenderer.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinLivingEntityRenderer.java index 2841e9147b5..c04dec9fc85 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinLivingEntityRenderer.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinLivingEntityRenderer.java @@ -21,16 +21,20 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import com.llamalad7.mixinextras.sugar.Local; import it.unimi.dsi.fastutil.floats.FloatFloatPair; import net.ccbluex.liquidbounce.features.cosmetic.CosmeticCategory; import net.ccbluex.liquidbounce.features.cosmetic.CosmeticService; import net.ccbluex.liquidbounce.features.module.modules.render.ModuleESP; import net.ccbluex.liquidbounce.features.module.modules.render.ModuleRotations; import net.ccbluex.liquidbounce.features.module.modules.render.ModuleTrueSight; +import net.ccbluex.liquidbounce.interfaces.EntityRenderStateAddition; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.render.VertexConsumerProvider; 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.math.MathHelper; @@ -44,18 +48,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(LivingEntityRenderer.class) -public class MixinLivingEntityRenderer { +public class MixinLivingEntityRenderer> { @Unique private final ThreadLocal<@Nullable FloatFloatPair> rotationPitch = ThreadLocal.withInitial(Suppliers.nul()); - @Inject(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) - private void injectRender(T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { + @Inject(method = "render(Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) + private void injectRender(S livingEntityRenderState, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { final var rotationPitch = ModuleRotations.INSTANCE.getRotationPitch(); this.rotationPitch.remove(); - if (livingEntity != MinecraftClient.getInstance().player || !ModuleRotations.INSTANCE.shouldDisplayRotations() || !ModuleRotations.INSTANCE.getBodyParts().getHead()) { + if (((EntityRenderStateAddition) livingEntityRenderState).liquid_bounce$getEntity() != MinecraftClient.getInstance().player || !ModuleRotations.INSTANCE.shouldDisplayRotations() || !ModuleRotations.INSTANCE.getBodyParts().getHead()) { return; } @@ -65,23 +69,23 @@ private void injectRender(T livingEntity, float f, float g, MatrixStack matrixSt /** * Head rotation pitch injection hook */ - @Redirect(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;lerp(FFF)F", ordinal = 0)) - private float injectRotationPitch(float g, float f, float s) { + @Redirect(method = "updateRenderState(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getLerpedPitch(F)F")) + private float injectRotationPitch(LivingEntity instance, float v) { final var rot = this.rotationPitch.get(); if (rot != null) { - return MathHelper.lerp(g, rot.keyFloat(), rot.valueFloat()); + return MathHelper.lerp(v, rot.keyFloat(), rot.valueFloat()); } else { - return MathHelper.lerp(g, f, s); + return instance.getLerpedPitch(v); } } - @ModifyExpressionValue(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isInvisibleTo(Lnet/minecraft/entity/player/PlayerEntity;)Z")) - private boolean injectTrueSight(boolean original, T livingEntity) { + @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)) { - return false; + ModuleESP.INSTANCE.getRunning() && ModuleESP.INSTANCE.requiresTrueSight(((LivingEntity) ((EntityRenderStateAddition) livingEntityRenderState).liquid_bounce$getEntity()))) { + return true; } return original; diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinPlayerEntityRenderer.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinPlayerEntityRenderer.java index abd17ad1d73..3198dbf692b 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinPlayerEntityRenderer.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinPlayerEntityRenderer.java @@ -20,9 +20,10 @@ import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleSwordBlock; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.render.entity.PlayerEntityRenderer; import net.minecraft.client.render.entity.model.BipedEntityModel; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -32,12 +33,10 @@ @Mixin(PlayerEntityRenderer.class) public class MixinPlayerEntityRenderer { - @Inject(method = "getArmPose", at = @At("HEAD"), cancellable = true) - private static void injectArmPose(AbstractClientPlayerEntity player, Hand hand, CallbackInfoReturnable cir) { - if (hand == Hand.OFF_HAND && player == MinecraftClient.getInstance().player) { - if (ModuleSwordBlock.INSTANCE.shouldHideOffhand()) { - cir.setReturnValue(BipedEntityModel.ArmPose.EMPTY); - } + @Inject(method = "getArmPose(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Hand;)Lnet/minecraft/client/render/entity/model/BipedEntityModel$ArmPose;", at = @At("HEAD"), cancellable = true) + private static void injectArmPose(PlayerEntity player, ItemStack stack, Hand hand, CallbackInfoReturnable cir) { + if (hand == Hand.OFF_HAND && player == MinecraftClient.getInstance().player && ModuleSwordBlock.INSTANCE.shouldHideOffhand()) { + cir.setReturnValue(BipedEntityModel.ArmPose.EMPTY); } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinPostEffectPass.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinPostEffectPass.java deleted file mode 100644 index 0b2f8893c5b..00000000000 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinPostEffectPass.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.ccbluex.liquidbounce.injection.mixins.minecraft.render; - -import net.ccbluex.liquidbounce.interfaces.PostEffectPassTextureAddition; -import net.minecraft.client.gl.JsonEffectShaderProgram; -import net.minecraft.client.gl.PostEffectPass; -import org.spongepowered.asm.mixin.Final; -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; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.HashMap; -import java.util.Map; - -@Mixin(PostEffectPass.class) -public class MixinPostEffectPass implements PostEffectPassTextureAddition { - @Shadow - @Final - private JsonEffectShaderProgram program; - @Unique - private final Map textureSamplerMap = new HashMap<>(); - - @Override - public void liquid_bounce$setTextureSampler(String name, int textureId) { - this.textureSamplerMap.put(name, textureId); - } - - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/Framebuffer;endWrite()V", ordinal = 0)) - private void injectTextureSamplerMap(float time, CallbackInfo ci) { - for (Map.Entry stringIntegerEntry : this.textureSamplerMap.entrySet()) { - this.program.bindSampler(stringIntegerEntry.getKey(), stringIntegerEntry::getValue); - } - } - -} diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinSignText.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinSignText.java index 1689ebbacf9..670ab247770 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinSignText.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinSignText.java @@ -20,12 +20,16 @@ package net.ccbluex.liquidbounce.injection.mixins.minecraft.render; import net.ccbluex.liquidbounce.features.module.modules.render.ModuleNoSignRender; +import net.ccbluex.liquidbounce.utils.client.SignTranslationFixKt; import net.minecraft.block.entity.SignText; import net.minecraft.text.OrderedText; import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; 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; import java.util.Arrays; @@ -34,6 +38,10 @@ @Mixin(SignText.class) public class MixinSignText { + @Shadow + @Final + private Text[] messages; + @Inject(method = "getOrderedMessages", at = @At("HEAD"), cancellable = true) private void injectNoSignRender(boolean filtered, Function messageOrderer, CallbackInfoReturnable cir) { if (ModuleNoSignRender.INSTANCE.getRunning()) { @@ -43,4 +51,23 @@ private void injectNoSignRender(boolean filtered, Function me } } + /** + * Fixes a vulnerability where the server can find out about the installed mods via translated text. + *

+ * This is not the same fix as by https://modrinth.com/mod/moddetectionpreventer/ even if it fixes the same issue. + * In order to prevent further issues, we completely disallow creating a sign text with unknown translatable. + */ + @Inject(method = "([Lnet/minecraft/text/Text;[Lnet/minecraft/text/Text;Lnet/minecraft/util/DyeColor;Z)V", at = @At("RETURN")) + private void injectSignVulnerabilityFix(CallbackInfo ci) { + for (int i = 0; i < this.messages.length; i++) { + var msg = this.messages[i]; + + if (msg == null) { + continue; + } + + this.messages[i] = SignTranslationFixKt.filterNonVanillaText(msg); + } + } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinTextRenderer.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinTextRenderer.java index 66609a75450..8338ede2f5f 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinTextRenderer.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinTextRenderer.java @@ -32,12 +32,12 @@ @Mixin(TextRenderer.class) public abstract class MixinTextRenderer { - @ModifyArg(method = "drawInternal(Ljava/lang/String;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;IIZ)I", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;drawLayer(Ljava/lang/String;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)F"), index = 0) + @ModifyArg(method = "drawInternal(Ljava/lang/String;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;IIZ)I", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;drawLayer(Ljava/lang/String;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;IIZ)F"), index = 0) private String injectNameProtectA(String text) { return ModuleNameProtect.INSTANCE.replace(text); } - @Redirect(method = "drawLayer(Lnet/minecraft/text/OrderedText;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)F", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/OrderedText;accept(Lnet/minecraft/text/CharacterVisitor;)Z")) + @Redirect(method = "drawLayer(Lnet/minecraft/text/OrderedText;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;IIZ)F", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/OrderedText;accept(Lnet/minecraft/text/CharacterVisitor;)Z")) private boolean injectNameProtectB(OrderedText orderedText, CharacterVisitor visitor) { if (ModuleNameProtect.INSTANCE.getRunning()) { final OrderedText wrapped = new ModuleNameProtect.NameProtectOrderedText(orderedText); diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinWeatherRendering.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinWeatherRendering.java new file mode 100644 index 00000000000..9e171d394cb --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinWeatherRendering.java @@ -0,0 +1,73 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ +package net.ccbluex.liquidbounce.injection.mixins.minecraft.render; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import net.ccbluex.liquidbounce.features.module.modules.render.ModuleCustomAmbience; +import net.minecraft.client.render.WeatherRendering; +import net.minecraft.world.biome.Biome; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@Mixin(WeatherRendering.class) +public abstract class MixinWeatherRendering { + + @ModifyExpressionValue(method = "addParticlesAndSound", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;getRainGradient(F)F")) + private float ambientPrecipitation2(float original) { + var moduleCustomAmbience = ModuleCustomAmbience.INSTANCE; + if (moduleCustomAmbience.getRunning() && moduleCustomAmbience.getWeather().get() == ModuleCustomAmbience.WeatherType.SNOWY) { + return 0f; + } + + return original; + } + + @ModifyVariable(method = "renderPrecipitation(Lnet/minecraft/world/World;Lnet/minecraft/client/render/VertexConsumerProvider;IFLnet/minecraft/util/math/Vec3d;)V", at = @At(value = "STORE"), ordinal = 1) + private int modifyPrecipitationLayers(int original) { + var precipitation = ModuleCustomAmbience.Precipitation.INSTANCE; + if (precipitation.getRunning()) { + return precipitation.getLayers(); + } + + return original; + } + + @ModifyExpressionValue(method = "renderPrecipitation(Lnet/minecraft/world/World;Lnet/minecraft/client/render/VertexConsumerProvider;IFLnet/minecraft/util/math/Vec3d;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getRainGradient(F)F")) + private float modifyPrecipitationGradient(float original) { + var precipitation = ModuleCustomAmbience.Precipitation.INSTANCE; + if (precipitation.getRunning() && original != 0f) { + return precipitation.getGradient(); + } + + return original; + } + + @ModifyReturnValue(method = "getPrecipitationAt", at = @At(value = "RETURN", ordinal = 1)) + private Biome.Precipitation modifyBiomePrecipitation(Biome.Precipitation original) { + var moduleOverrideWeather = ModuleCustomAmbience.INSTANCE; + if (moduleOverrideWeather.getRunning() && moduleOverrideWeather.getWeather().get() == ModuleCustomAmbience.WeatherType.SNOWY) { + return Biome.Precipitation.SNOW; + } + + return original; + } + +} diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinWorldRenderer.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinWorldRenderer.java index e9bb38b76a3..d7e58762386 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinWorldRenderer.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/MixinWorldRenderer.java @@ -19,7 +19,7 @@ package net.ccbluex.liquidbounce.injection.mixins.minecraft.render; -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.sugar.Local; import net.ccbluex.liquidbounce.common.OutlineFlag; import net.ccbluex.liquidbounce.event.EventManager; import net.ccbluex.liquidbounce.event.events.DrawOutlinesEvent; @@ -32,11 +32,13 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gl.Framebuffer; import net.minecraft.client.render.*; +import net.minecraft.client.util.Handle; +import net.minecraft.client.util.ObjectAllocator; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.TntEntity; -import net.minecraft.world.biome.Biome; +import net.minecraft.util.profiler.Profiler; import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Final; @@ -52,48 +54,48 @@ @Mixin(WorldRenderer.class) public abstract class MixinWorldRenderer { - @Shadow - @Nullable - public Framebuffer entityOutlinesFramebuffer; - - @Shadow - protected abstract void renderEntity(Entity entity, double cameraX, double cameraY, double cameraZ, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers); - @Shadow public abstract @Nullable Framebuffer getEntityOutlinesFramebuffer(); @Shadow protected abstract boolean canDrawEntityOutlines(); + @Shadow + protected abstract void renderTargetBlockOutline(Camera camera, VertexConsumerProvider.Immediate vertexConsumers, MatrixStack matrices, boolean translucent); + @Shadow @Final private MinecraftClient client; + @Shadow + @Final + public DefaultFramebufferSet framebufferSet; + + @Shadow + protected abstract void renderEntity(Entity entity, double cameraX, double cameraY, double cameraZ, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers); + + @Shadow + @Nullable + public Framebuffer entityOutlineFramebuffer; @Inject(method = "loadEntityOutlinePostProcessor", at = @At("RETURN")) private void onLoadEntityOutlineShader(CallbackInfo info) { - try { - OutlineShader.INSTANCE.load(); - } catch (Throwable e) { - ClientUtilsKt.getLogger().error("Failed to load outline shader", e); - } + // load the shader class to compile the shaders + //noinspection unused + var instance = OutlineShader.INSTANCE; } - @Inject(method = "render", at = @At("HEAD")) - private void onRender(RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) { + @Inject(method = "render", at = @At("HEAD")) + private void onRender(ObjectAllocator allocator, RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, Matrix4f positionMatrix, Matrix4f projectionMatrix, CallbackInfo ci) { try { - if (!OutlineShader.INSTANCE.isReady()) { - return; - } - OutlineShader outlineShader = OutlineShader.INSTANCE; - outlineShader.begin(2.0F); - outlineShader.getFramebuffer().beginWrite(false); + OutlineShader.INSTANCE.update(); + outlineShader.getHandle().get().beginWrite(false); var event = new DrawOutlinesEvent(new MatrixStack(), camera, tickCounter.getTickDelta(false), DrawOutlinesEvent.OutlineType.INBUILT_OUTLINE); EventManager.INSTANCE.callEvent(event); if (event.getDirtyFlag()) { - outlineShader.setDirty(); + outlineShader.setDirty(true); } client.getFramebuffer().beginWrite(false); @@ -105,14 +107,13 @@ private void onRender(RenderTickCounter tickCounter, boolean renderBlockOutline, @Inject(method = "renderEntity", at = @At("HEAD")) private void injectOutlineESP(Entity entity, double cameraX, double cameraY, double cameraZ, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo info) { // Prevent stack overflow - if (RenderingFlags.isCurrentlyRenderingEntityOutline().get() || !OutlineShader.INSTANCE.isReady()) { + if (RenderingFlags.isCurrentlyRenderingEntityOutline().get()) { return; } Color4b color; - if (ModuleESP.OutlineMode.INSTANCE.getRunning() && entity instanceof LivingEntity - && CombatExtensionsKt.shouldBeShown(entity)) { + if (ModuleESP.OutlineMode.INSTANCE.getRunning() && entity instanceof LivingEntity && CombatExtensionsKt.shouldBeShown(entity)) { color = ModuleESP.INSTANCE.getColor((LivingEntity) entity); } else if (ModuleItemESP.OutlineMode.INSTANCE.getRunning() && ModuleItemESP.INSTANCE.shouldRender(entity)) { color = ModuleItemESP.INSTANCE.getColor(); @@ -120,39 +121,39 @@ private void injectOutlineESP(Entity entity, double cameraX, double cameraY, dou return; } - OutlineShader outlineShader = OutlineShader.INSTANCE; - Framebuffer originalBuffer = this.entityOutlinesFramebuffer; + var outlineShader = OutlineShader.INSTANCE; + var originalBuffer = framebufferSet.entityOutlineFramebuffer; + var originalBuffer2 = entityOutlineFramebuffer; - this.entityOutlinesFramebuffer = outlineShader.getFramebuffer(); + framebufferSet.entityOutlineFramebuffer = outlineShader.getHandle(); + entityOutlineFramebuffer = outlineShader.getHandle().get(); outlineShader.setColor(color); - outlineShader.setDirty(); + outlineShader.setDirty(true); RenderingFlags.isCurrentlyRenderingEntityOutline().set(true); try { - renderEntity(entity, cameraX, cameraY, cameraZ, tickDelta, matrices, - outlineShader.getVertexConsumerProvider()); + renderEntity(entity, cameraX, cameraY, cameraZ, tickDelta, matrices, outlineShader.getVertexConsumerProvider()); } finally { RenderingFlags.isCurrentlyRenderingEntityOutline().set(false); } - this.entityOutlinesFramebuffer = originalBuffer; + entityOutlineFramebuffer = originalBuffer2; + framebufferSet.entityOutlineFramebuffer = originalBuffer; } - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/OutlineVertexConsumerProvider;draw()V")) - private void onDrawOutlines(RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) { - if (!ModuleESP.OutlineMode.INSTANCE.getRunning()) { - return; + @Inject(method = "method_62214", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/OutlineVertexConsumerProvider;draw()V")) + private void onDrawOutlines(Fog fog, RenderTickCounter renderTickCounter, Camera camera, Profiler profiler, Matrix4f matrix4f, Matrix4f matrix4f2, Handle handle, Handle handle2, Handle handle3, Handle handle4, boolean bl, Frustum frustum, Handle handle5, CallbackInfo ci) { + if (OutlineShader.INSTANCE.getDirty()) { + OutlineShader.INSTANCE.draw(); } - - OutlineShader.INSTANCE.end(tickCounter.getTickDelta(false)); } - @Inject(method = "drawEntityOutlinesFramebuffer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/Framebuffer;draw(IIZ)V")) + @Inject(method = "drawEntityOutlinesFramebuffer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/Framebuffer;drawInternal(II)V")) private void onDrawEntityOutlinesFramebuffer(CallbackInfo info) { - if (OutlineShader.INSTANCE.isReady() && OutlineShader.INSTANCE.isDirty()) { - OutlineShader.INSTANCE.drawFramebuffer(); + if (OutlineShader.INSTANCE.getDirty()) { + OutlineShader.INSTANCE.apply(false); } } @@ -179,12 +180,7 @@ private void injectChamsForEntityPost(Entity entity, double cameraX, double came } } - @Inject(method = "onResized", at = @At("HEAD")) - private void onResized(int w, int h, CallbackInfo info) { - OutlineShader.INSTANCE.onResized(w, h); - } - - @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isSleeping()Z")) + @Redirect(method = "getEntitiesToRender", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isSleeping()Z")) private boolean hookFreeCamRenderPlayerFromAllPerspectives(LivingEntity instance) { return ModuleFreeCam.INSTANCE.renderPlayerFromAllPerspectives(instance); } @@ -194,7 +190,7 @@ private boolean hookFreeCamRenderPlayerFromAllPerspectives(LivingEntity instance * * @author 1zuna */ - @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;hasOutline(Lnet/minecraft/entity/Entity;)Z")) + @Redirect(method = "renderEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;hasOutline(Lnet/minecraft/entity/Entity;)Z")) private boolean injectHasOutline(MinecraftClient instance, Entity entity) { if (ModuleItemESP.GlowMode.INSTANCE.getRunning() && ModuleItemESP.INSTANCE.shouldRender(entity)) { return true; @@ -213,12 +209,31 @@ private boolean injectHasOutline(MinecraftClient instance, Entity entity) { return instance.hasOutline(entity); } + @Redirect(method = "getEntitiesToRender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;hasOutline(Lnet/minecraft/entity/Entity;)Z")) + private boolean injectHasOutline2(MinecraftClient instance, Entity entity) { + if (ModuleItemESP.GlowMode.INSTANCE.getRunning() && ModuleItemESP.INSTANCE.shouldRender(entity)) { + return true; + } + if (ModuleESP.GlowMode.INSTANCE.getRunning() && CombatExtensionsKt.shouldBeShown(entity)) { + return true; + } + if (ModuleTNTTimer.INSTANCE.getRunning() && ModuleTNTTimer.INSTANCE.getEsp() && entity instanceof TntEntity) { + return true; + } + + if (ModuleStorageESP.Glow.INSTANCE.getRunning() && ModuleStorageESP.categorize(entity) != null) { + return true; + } + + return instance.hasOutline(entity); + } + /** * Inject ESP color as glow color * * @author 1zuna */ - @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getTeamColorValue()I")) + @Redirect(method = "renderEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getTeamColorValue()I")) private int injectTeamColor(Entity instance) { if (ModuleItemESP.GlowMode.INSTANCE.getRunning() && ModuleItemESP.INSTANCE.shouldRender(instance)) { return ModuleItemESP.INSTANCE.getColor().toARGB(); @@ -243,15 +258,16 @@ private int injectTeamColor(Entity instance) { return instance.getTeamColorValue(); } - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/OutlineVertexConsumerProvider;draw()V", shift = At.Shift.BEFORE)) - private void onRenderOutline(RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) { + @Inject(method = "method_62214", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/OutlineVertexConsumerProvider;draw()V", shift = At.Shift.BEFORE)) + private void onRenderOutline(Fog fog, RenderTickCounter renderTickCounter, Camera camera, Profiler profiler, Matrix4f matrix4f, Matrix4f matrix4f2, Handle handle, Handle handle2, Handle handle3, Handle handle4, boolean bl, Frustum frustum, Handle handle5, CallbackInfo ci) { if (!this.canDrawEntityOutlines()) { return; } + //noinspection DataFlowIssue this.getEntityOutlinesFramebuffer().beginWrite(false); - var event = new DrawOutlinesEvent(new MatrixStack(), camera, tickCounter.getTickDelta(false), DrawOutlinesEvent.OutlineType.MINECRAFT_GLOW); + var event = new DrawOutlinesEvent(new MatrixStack(), camera, renderTickCounter.getTickDelta(false), DrawOutlinesEvent.OutlineType.MINECRAFT_GLOW); EventManager.INSTANCE.callEvent(event); @@ -260,20 +276,12 @@ private void onRenderOutline(RenderTickCounter tickCounter, boolean renderBlockO MinecraftClient.getInstance().getFramebuffer().beginWrite(false); } - @ModifyVariable(method = "render", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/BufferBuilderStorage;getOutlineVertexConsumers()Lnet/minecraft/client/render/OutlineVertexConsumerProvider;", - ordinal = 1), - ordinal = 3, - name = "bl3", - require = 1 - ) - private boolean hookOutlineFlag(boolean bl3) { - if (OutlineFlag.drawOutline) { + @Inject(method = "method_62214", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/BufferBuilderStorage;getOutlineVertexConsumers()Lnet/minecraft/client/render/OutlineVertexConsumerProvider;", shift = At.Shift.AFTER)) + private void hookOutlineFlag(Fog fog, RenderTickCounter renderTickCounter, Camera camera, Profiler profiler, Matrix4f matrix4f, Matrix4f matrix4f2, Handle handle, Handle handle2, Handle handle3, Handle handle4, boolean bl, Frustum frustum, Handle handle5, CallbackInfo ci, @Local(ordinal = 0) VertexConsumerProvider.Immediate immediate, @Local(ordinal = 0) MatrixStack matrixStack) { + if (OutlineFlag.drawOutline && !bl) { OutlineFlag.drawOutline = false; - return true; + renderTargetBlockOutline(camera, immediate, matrixStack, false); } - - return bl3; } @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;setupTerrain(Lnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/Frustum;ZZ)V"), index = 3) @@ -281,89 +289,19 @@ private boolean renderSetupTerrainModifyArg(boolean spectator) { return ModuleFreeCam.INSTANCE.getRunning() || spectator; } - @ModifyExpressionValue(method = "renderWeather", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getPrecipitation(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/world/biome/Biome$Precipitation;")) - private Biome.Precipitation modifyBiomePrecipitation(Biome.Precipitation original) { - var moduleOverrideWeather = ModuleCustomAmbience.INSTANCE; - if (moduleOverrideWeather.getRunning() && moduleOverrideWeather.getWeather().get() == ModuleCustomAmbience.WeatherType.SNOWY) { - return Biome.Precipitation.SNOW; - } - - return original; - } - - @ModifyExpressionValue(method = "renderWeather", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;getRainGradient(F)F")) - private float modifyPrecipitationGradient(float original) { - var precipitation = ModuleCustomAmbience.Precipitation.INSTANCE; - if (precipitation.getRunning() && original != 0f) { - return precipitation.getGradient(); - } - return original; - } - - @ModifyVariable(method = "renderWeather", at = @At(value = "STORE"), ordinal = 3) - private int modifyPrecipitationLayers(int original) { - var precipitation = ModuleCustomAmbience.Precipitation.INSTANCE; - if (precipitation.getRunning()) { - return precipitation.getLayers(); - } - - return original; - } - - @ModifyExpressionValue(method = "renderWeather", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;isFancyGraphicsOrBetter()Z")) - private boolean modifyPrecipitationLayersSet(boolean original) { - var precipitation = ModuleCustomAmbience.Precipitation.INSTANCE; - if (precipitation.getRunning()) { - return false; - } - - return original; - } - - @ModifyExpressionValue(method = "tickRainSplashing", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;getRainGradient(F)F")) - private float removeRainSplashing(float original) { - var moduleOverrideWeather = ModuleCustomAmbience.INSTANCE; - if (moduleOverrideWeather.getRunning() && moduleOverrideWeather.getWeather().get() == ModuleCustomAmbience.WeatherType.SNOWY) { - return 0f; - } - - return original; - } - - @ModifyArgs( - method = "drawBlockOutline", + @ModifyArgs(method = "drawBlockOutline", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/render/WorldRenderer;drawCuboidShapeOutline(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/util/shape/VoxelShape;DDDFFFF)V" + target = "Lnet/minecraft/client/render/VertexRendering;drawOutline(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/util/shape/VoxelShape;DDDI)V" ) ) private void modifyBlockOutlineArgs(Args args) { - // args: MatrixStack matrices, - // VertexConsumer vertexConsumer, - // VoxelShape shape, - // double offsetX, - // double offsetY, - // double offsetZ, - // float red, - // float green, - // float blue, - // float alpha - if (!ModuleBlockOutline.INSTANCE.getRunning()) { return; } - var color = ModuleBlockOutline.INSTANCE.getOutlineColor(); - var red = color.getR() / 255f; - var green = color.getG() / 255f; - var blue = color.getB() / 255f; - var alpha = color.getA() / 255f; - - args.set(6, red); - args.set(7, green); - args.set(8, blue); - args.set(9, alpha); + args.set(6, ModuleBlockOutline.INSTANCE.getOutlineColor().toARGB()); } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinOtherClientPlayerEntity.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/MixinEntityRenderState.java similarity index 50% rename from src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinOtherClientPlayerEntity.java rename to src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/MixinEntityRenderState.java index d64ca848256..0f2cfc8e669 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinOtherClientPlayerEntity.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/MixinEntityRenderState.java @@ -16,26 +16,32 @@ * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . */ -package net.ccbluex.liquidbounce.injection.mixins.minecraft.entity; +package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.entity; -import com.mojang.authlib.GameProfile; -import net.ccbluex.liquidbounce.interfaces.OtherClientPlayerEntityAddition; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.network.OtherClientPlayerEntity; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.damage.DamageSource; +import net.ccbluex.liquidbounce.interfaces.EntityRenderStateAddition; +import net.minecraft.client.render.entity.state.EntityRenderState; +import net.minecraft.entity.Entity; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; -@Mixin(OtherClientPlayerEntity.class) -public abstract class MixinOtherClientPlayerEntity extends AbstractClientPlayerEntity implements OtherClientPlayerEntityAddition { +@Mixin(EntityRenderState.class) +public abstract class MixinEntityRenderState implements EntityRenderStateAddition { - public MixinOtherClientPlayerEntity(ClientWorld world, GameProfile profile) { - super(world, profile); + @Unique + private Entity liquid_bounce$entity; + + @Unique + @Override + @SuppressWarnings("unused") + public void liquid_bounce$setEntity(Entity entity) { + this.liquid_bounce$entity = entity; } + @Unique @Override - public boolean liquid_bounce$actuallyDamage(DamageSource source, float amount) { - return super.damage(source, amount); + @SuppressWarnings("unused") + public Entity liquid_bounce$getEntity() { + return liquid_bounce$entity; } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/feature/MixinDeadmau5FeatureRenderer.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/feature/MixinDeadmau5FeatureRenderer.java index 90f219b7654..e2d3e002f15 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/feature/MixinDeadmau5FeatureRenderer.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/render/entity/feature/MixinDeadmau5FeatureRenderer.java @@ -1,40 +1,40 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + * + */ package net.ccbluex.liquidbounce.injection.mixins.minecraft.render.entity.feature; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -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.cosmetic.CosmeticCategory; import net.ccbluex.liquidbounce.features.cosmetic.CosmeticService; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.render.VertexConsumerProvider; +import net.ccbluex.liquidbounce.interfaces.EntityRenderStateAddition; import net.minecraft.client.render.entity.feature.Deadmau5FeatureRenderer; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.render.entity.state.PlayerEntityRenderState; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @Mixin(Deadmau5FeatureRenderer.class) public class MixinDeadmau5FeatureRenderer { - @ModifyExpressionValue( - method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/network/AbstractClientPlayerEntity;FFFFFF)V", - at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z") - ) - private boolean onRender( - boolean original, - MatrixStack matrixStack, - VertexConsumerProvider vertexConsumerProvider, - int i, - AbstractClientPlayerEntity abstractClientPlayerEntity, - float f, - float g, - float h, - float j, - float k, - float l - ) { - return original || CosmeticService.INSTANCE.hasCosmetic(abstractClientPlayerEntity.getUuid(), - CosmeticCategory.DEADMAU5_EARS); + @ModifyExpressionValue(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/PlayerEntityRenderState;FF)V", at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z", remap = false)) + private boolean onRender(boolean original, @Local(argsOnly = true) PlayerEntityRenderState playerEntityRenderState) { + return original || CosmeticService.INSTANCE.hasCosmetic(((EntityRenderStateAddition) playerEntityRenderState).liquid_bounce$getEntity().getUuid(), CosmeticCategory.DEADMAU5_EARS); } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/text/MixinTextColor.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/text/MixinTextColor.java index 268efa2aa9f..172d29a29ba 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/text/MixinTextColor.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/text/MixinTextColor.java @@ -14,6 +14,7 @@ */ @Mixin(TextColor.class) public class MixinTextColor implements ClientTextColorAdditions { + @Shadow @Final private @Nullable String name; @@ -58,4 +59,5 @@ private void equals(Object o, CallbackInfoReturnable cir) { public int hashCode() { return Objects.hashCode(this.name, this.rgb, this.bypassesNameProtect); } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/text/MixinTranslatableTextContent.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/text/MixinTranslatableTextContent.java index 01ccbd6c506..dfe649b099d 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/text/MixinTranslatableTextContent.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/text/MixinTranslatableTextContent.java @@ -11,8 +11,7 @@ @Mixin(TranslatableTextContent.class) public class MixinTranslatableTextContent { - @ModifyExpressionValue(method = "updateTranslations", at = @At(value = "INVOKE", - target = "Lnet/minecraft/util/Language;getInstance()Lnet/minecraft/util/Language;")) + @ModifyExpressionValue(method = "updateTranslations", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Language;getInstance()Lnet/minecraft/util/Language;")) private Language hookClientTranslations(Language original) { if ((Object) this instanceof LanguageText) { return LanguageManager.INSTANCE.getLanguage(); diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/sodium/MixinSodiumBlockOcclusionCache.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/sodium/MixinSodiumBlockOcclusionCache.java index 69369b37672..42863eb0ef9 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/sodium/MixinSodiumBlockOcclusionCache.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/sodium/MixinSodiumBlockOcclusionCache.java @@ -16,7 +16,6 @@ * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . */ - package net.ccbluex.liquidbounce.injection.mixins.sodium; import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockOcclusionCache; @@ -45,4 +44,5 @@ private void injectXRay(BlockState selfState, BlockView view, BlockPos pos, Dire cir.setReturnValue(module.shouldRender(selfState, pos)); cir.cancel(); } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/sodium/MixinSodiumLightDataAccessMixin.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/sodium/MixinSodiumLightDataAccessMixin.java index 580f25cf50b..5d66adb8634 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/sodium/MixinSodiumLightDataAccessMixin.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/sodium/MixinSodiumLightDataAccessMixin.java @@ -16,7 +16,6 @@ * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . */ - package net.ccbluex.liquidbounce.injection.mixins.sodium; import net.caffeinemc.mods.sodium.client.model.light.data.LightDataAccess; diff --git a/src/main/java/net/ccbluex/liquidbounce/interfaces/OtherClientPlayerEntityAddition.java b/src/main/java/net/ccbluex/liquidbounce/interfaces/ArmorItemAdditions.java similarity index 66% rename from src/main/java/net/ccbluex/liquidbounce/interfaces/OtherClientPlayerEntityAddition.java rename to src/main/java/net/ccbluex/liquidbounce/interfaces/ArmorItemAdditions.java index f86dd83fd49..54e446ca2f8 100644 --- a/src/main/java/net/ccbluex/liquidbounce/interfaces/OtherClientPlayerEntityAddition.java +++ b/src/main/java/net/ccbluex/liquidbounce/interfaces/ArmorItemAdditions.java @@ -18,19 +18,18 @@ */ package net.ccbluex.liquidbounce.interfaces; -import net.ccbluex.liquidbounce.features.command.commands.ingame.fakeplayer.FakePlayer; -import net.minecraft.entity.damage.DamageSource; +import net.minecraft.item.equipment.ArmorMaterial; +import net.minecraft.item.equipment.EquipmentType; /** - * Additions to {@link net.minecraft.client.network.OtherClientPlayerEntity}. + * Additions to {@link net.minecraft.item.ArmorItem} */ -public interface OtherClientPlayerEntityAddition { +public interface ArmorItemAdditions { - /** - * Allows the entity to receive damage. - * Used in {@link FakePlayer}. - */ @SuppressWarnings("unused") - boolean liquid_bounce$actuallyDamage(DamageSource source, float amount); + ArmorMaterial liquid_bounce$getMaterial(); + + @SuppressWarnings("unused") + EquipmentType liquid_bounce$getType(); } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/DitheringShader.kt b/src/main/java/net/ccbluex/liquidbounce/interfaces/EntityRenderStateAddition.java similarity index 66% rename from src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/DitheringShader.kt rename to src/main/java/net/ccbluex/liquidbounce/interfaces/EntityRenderStateAddition.java index 0fae5f589ae..8d6a2195858 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/DitheringShader.kt +++ b/src/main/java/net/ccbluex/liquidbounce/interfaces/EntityRenderStateAddition.java @@ -16,16 +16,17 @@ * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . */ -package net.ccbluex.liquidbounce.render.shader.shaders +package net.ccbluex.liquidbounce.interfaces; -import net.ccbluex.liquidbounce.render.engine.MinecraftFramebufferShader +import net.minecraft.entity.Entity; -object DitheringShader : MinecraftFramebufferShader("dithering_shader") { +/** + * Addition to {@link net.minecraft.client.render.entity.state.EntityRenderState} + */ +public interface EntityRenderStateAddition { + + void liquid_bounce$setEntity(Entity entity); - fun begin(ditherAmount: Float) { - this.setUniform1f("ditherAmount", ditherAmount) -// this.vertexConsumerProvider!!.setColor(255, 255, 255, 255) - this.beginInternal() - } + Entity liquid_bounce$getEntity(); } diff --git a/src/main/java/net/ccbluex/liquidbounce/interfaces/LightmapTextureManagerAddition.java b/src/main/java/net/ccbluex/liquidbounce/interfaces/LightmapTextureManagerAddition.java index 657a5c491c8..189e85dd079 100644 --- a/src/main/java/net/ccbluex/liquidbounce/interfaces/LightmapTextureManagerAddition.java +++ b/src/main/java/net/ccbluex/liquidbounce/interfaces/LightmapTextureManagerAddition.java @@ -19,7 +19,7 @@ package net.ccbluex.liquidbounce.interfaces; /** - * Additions to {@link net.minecraft.client.gui.hud.ChatHudLine}. + * Additions to {@link net.minecraft.client.render.LightmapTextureManager}. */ public interface LightmapTextureManagerAddition { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/BlurUIShader.kt b/src/main/java/net/ccbluex/liquidbounce/interfaces/MiningToolItemAddition.java similarity index 58% rename from src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/BlurUIShader.kt rename to src/main/java/net/ccbluex/liquidbounce/interfaces/MiningToolItemAddition.java index 058a3b29953..60ca3ae9747 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/BlurUIShader.kt +++ b/src/main/java/net/ccbluex/liquidbounce/interfaces/MiningToolItemAddition.java @@ -16,22 +16,16 @@ * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . */ -package net.ccbluex.liquidbounce.render.shader.shaders +package net.ccbluex.liquidbounce.interfaces; -import com.mojang.blaze3d.systems.RenderSystem -import net.ccbluex.liquidbounce.render.engine.Color4b -import net.ccbluex.liquidbounce.render.engine.MinecraftFramebufferShader +import net.minecraft.item.ToolMaterial; -object BlurUIShader : MinecraftFramebufferShader("blur_ui") { - - fun begin(shaderTexture: Int) { - this.beginInternal() - - RenderSystem.setShaderTexture(1, shaderTexture) - } +/** + * Addition to {@link net.minecraft.item.MiningToolItem} + */ +public interface MiningToolItemAddition { - fun setColor(color: Color4b) { - this.vertexConsumerProvider?.setColor(color.r, color.g, color.b, color.a) - } + @SuppressWarnings("unused") + ToolMaterial liquid_bounce$getMaterial(); } diff --git a/src/main/java/net/ccbluex/liquidbounce/interfaces/PostEffectPassTextureAddition.java b/src/main/java/net/ccbluex/liquidbounce/interfaces/PostEffectPassTextureAddition.java deleted file mode 100644 index 6dda052c069..00000000000 --- a/src/main/java/net/ccbluex/liquidbounce/interfaces/PostEffectPassTextureAddition.java +++ /dev/null @@ -1,5 +0,0 @@ -package net.ccbluex.liquidbounce.interfaces; - -public interface PostEffectPassTextureAddition { - void liquid_bounce$setTextureSampler(String name, int textureId); -} diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/client/vfp/VfpCompatibility.java b/src/main/java/net/ccbluex/liquidbounce/utils/client/vfp/VfpCompatibility.java index 521f010d6c7..ea73f25cedd 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/client/vfp/VfpCompatibility.java +++ b/src/main/java/net/ccbluex/liquidbounce/utils/client/vfp/VfpCompatibility.java @@ -25,7 +25,6 @@ import com.viaversion.viaversion.api.protocol.version.VersionType; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import de.florianmichael.viafabricplus.screen.base.ProtocolSelectionScreen; -import de.florianmichael.viafabricplus.settings.impl.VisualSettings; import net.ccbluex.liquidbounce.LiquidBounce; import net.ccbluex.liquidbounce.utils.client.ClientProtocolVersion; import net.minecraft.client.MinecraftClient; @@ -41,17 +40,6 @@ public enum VfpCompatibility { INSTANCE; - public void unsafeDisableConflictingVfpOptions() { - try { - VisualSettings visualSettings = VisualSettings.global(); - - // 1 == off, 0 == on - visualSettings.enableSwordBlocking.setValue(1); - } catch (Throwable throwable) { - LiquidBounce.INSTANCE.getLogger().error("Failed to disable conflicting options", throwable); - } - } - public ClientProtocolVersion unsafeGetProtocolVersion() { try { ProtocolVersion version = ProtocolTranslator.getTargetVersion(); diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/LiquidBounce.kt b/src/main/kotlin/net/ccbluex/liquidbounce/LiquidBounce.kt index 0ef28386cb4..f0392e1a89b 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/LiquidBounce.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/LiquidBounce.kt @@ -57,7 +57,6 @@ import net.ccbluex.liquidbounce.utils.aiming.RotationManager import net.ccbluex.liquidbounce.utils.block.ChunkScanner import net.ccbluex.liquidbounce.utils.client.ErrorHandler import net.ccbluex.liquidbounce.utils.client.InteractionTracker -import net.ccbluex.liquidbounce.utils.client.disableConflictingVfpOptions import net.ccbluex.liquidbounce.utils.client.mc import net.ccbluex.liquidbounce.utils.combat.CombatManager import net.ccbluex.liquidbounce.utils.combat.combatTargetsConfigurable @@ -290,13 +289,6 @@ object LiquidBounce : EventListener { }.onFailure { logger.error("Failed to load settings list from API", it) } - - // Disable conflicting options - runCatching { - disableConflictingVfpOptions() - }.onSuccess { - logger.info("Disabled conflicting options.") - } } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/event/Event.kt b/src/main/kotlin/net/ccbluex/liquidbounce/event/Event.kt index 8f5f8f100e2..9241cbfa80a 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/event/Event.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/event/Event.kt @@ -50,7 +50,7 @@ open class CancellableEvent : Event() { } /** - * State of event. Might be PRE or POST. + * MixinEntityRenderState of event. Might be PRE or POST. */ enum class EventState(val stateName: String) { PRE("PRE"), POST("POST") diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt b/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt index 052cf10d6c2..5271694d080 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/event/events/GameEvents.kt @@ -53,7 +53,7 @@ class KeyEvent(val key: InputUtil.Key, val action: Int) : Event() class InputHandleEvent : Event() @Nameable("movementInput") -class MovementInputEvent(var directionalInput: DirectionalInput, var jumping: Boolean, var sneaking: Boolean) : Event() +class MovementInputEvent(var directionalInput: DirectionalInput, var jump: Boolean, var sneak: Boolean) : Event() @Nameable("mouseRotation") class MouseRotationEvent(var cursorDeltaX: Double, var cursorDeltaY: Double) : CancellableEvent() diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/event/events/PlayerEvents.kt b/src/main/kotlin/net/ccbluex/liquidbounce/event/events/PlayerEvents.kt index 7d41da9d76e..17638edb2c3 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/event/events/PlayerEvents.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/event/events/PlayerEvents.kt @@ -23,8 +23,8 @@ package net.ccbluex.liquidbounce.event.events import net.ccbluex.liquidbounce.event.CancellableEvent import net.ccbluex.liquidbounce.event.Event import net.ccbluex.liquidbounce.event.EventState -import net.ccbluex.liquidbounce.utils.client.Nameable import net.ccbluex.liquidbounce.integration.interop.protocol.event.WebSocketEvent +import net.ccbluex.liquidbounce.utils.client.Nameable import net.minecraft.entity.MovementType import net.minecraft.entity.player.PlayerEntity import net.minecraft.fluid.Fluid @@ -77,7 +77,7 @@ class PlayerAfterJumpEvent : Event() class PlayerUseMultiplier(var forward: Float, var sideways: Float) : Event() @Nameable("playerSneakMultiplier") -class PlayerSneakMultiplier(var multiplier: Float) : Event() +class PlayerSneakMultiplier(var multiplier: Double) : Event() @Nameable("playerInteractedItem") class PlayerInteractedItem(val player: PlayerEntity, val hand: Hand, val actionResult: ActionResult) : Event() diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/command/builder/Parameters.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/command/builder/Parameters.kt index eb688d08cae..5328823a160 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/command/builder/Parameters.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/command/builder/Parameters.kt @@ -57,7 +57,7 @@ fun enchantmentParameter(name: String = "enchantment"): ParameterBuilder .begin(name) .verifiedBy(ParameterBuilder.STRING_VALIDATOR) .autocompletedWith { _ -> - world.registryManager.get(RegistryKeys.ENCHANTMENT).indexedEntries.map { + world.registryManager.getOrThrow(RegistryKeys.ENCHANTMENT).indexedEntries.map { it.idAsString } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/client/CommandItems.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/client/CommandItems.kt index 4a55bd51c34..88733bdd6ac 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/client/CommandItems.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/client/CommandItems.kt @@ -61,7 +61,7 @@ object CommandItems : CommandFactory { val identifier = Identifier.tryParse(name) val displayName = identifier.toString() - val block = Registries.BLOCK.getOrEmpty(identifier).orElseThrow { + val block = Registries.BLOCK.getOptionalValue(identifier).orElseThrow { throw CommandException(command.result("blockNotExists", displayName)) } @@ -86,7 +86,7 @@ object CommandItems : CommandFactory { val identifier = Identifier.tryParse(name) val displayName = identifier.toString() - val block = Registries.BLOCK.getOrEmpty(identifier).orElseThrow { + val block = Registries.BLOCK.getOptionalValue(identifier).orElseThrow { throw CommandException(command.result("blockNotExists", displayName)) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/ingame/creative/CommandItemEnchant.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/ingame/creative/CommandItemEnchant.kt index d1fb3af938c..594e8a91da2 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/ingame/creative/CommandItemEnchant.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/ingame/creative/CommandItemEnchant.kt @@ -194,7 +194,7 @@ object CommandItemEnchant : CommandFactory, MinecraftShortcuts { private fun enchantmentByName(enchantmentName: String, command: Command): RegistryEntry { val identifier = Identifier.tryParse(enchantmentName) - val registry = world.registryManager.get(RegistryKeys.ENCHANTMENT) + val registry = world.registryManager.getOrThrow(RegistryKeys.ENCHANTMENT) val enchantment = registry.getEntry(identifier).orElseThrow { throw CommandException(command.resultWithTree("enchantmentNotExists", enchantmentName)) } @@ -216,7 +216,7 @@ object CommandItemEnchant : CommandFactory, MinecraftShortcuts { } private fun enchantAll(item: ItemStack, onlyAcceptable: Boolean, level: Int?) { - world.registryManager.get(RegistryKeys.ENCHANTMENT).indexedEntries.forEach { enchantment -> + world.registryManager.getOrThrow(RegistryKeys.ENCHANTMENT).indexedEntries.forEach { enchantment -> if(!enchantment.value().isAcceptableItem(item) && onlyAcceptable) { return@forEach } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/ingame/fakeplayer/CommandFakePlayer.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/ingame/fakeplayer/CommandFakePlayer.kt index 972eb2e9089..7a5f9c3d413 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/ingame/fakeplayer/CommandFakePlayer.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/ingame/fakeplayer/CommandFakePlayer.kt @@ -20,6 +20,7 @@ package net.ccbluex.liquidbounce.features.command.commands.ingame.fakeplayer import com.mojang.authlib.GameProfile import net.ccbluex.liquidbounce.event.EventListener +import net.ccbluex.liquidbounce.event.events.AttackEntityEvent import net.ccbluex.liquidbounce.event.events.GameTickEvent import net.ccbluex.liquidbounce.event.events.NotificationEvent import net.ccbluex.liquidbounce.event.events.PacketEvent @@ -31,11 +32,13 @@ import net.ccbluex.liquidbounce.features.command.builder.CommandBuilder import net.ccbluex.liquidbounce.features.command.builder.ParameterBuilder import net.ccbluex.liquidbounce.lang.translation import net.ccbluex.liquidbounce.utils.client.* +import net.ccbluex.liquidbounce.utils.entity.getDamageFromExplosion +import net.ccbluex.liquidbounce.utils.entity.getEffectiveDamage import net.minecraft.entity.Entity +import net.minecraft.entity.LivingEntity +import net.minecraft.entity.attribute.EntityAttributes import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket import net.minecraft.network.packet.s2c.play.ExplosionS2CPacket -import net.minecraft.world.explosion.Explosion -import net.minecraft.world.explosion.ExplosionBehavior import java.math.BigDecimal import java.math.RoundingMode import java.util.* @@ -55,8 +58,6 @@ object CommandFakePlayer : CommandFactory, EventListener { private var recording = false private val snapshots = ArrayList() - private val explosionBehavior: ExplosionBehavior = ExplosionBehavior() - // the entity ids of fake players shouldn't conflict with real entity ids, so they are negative private var fakePlayerId = -1 @@ -293,29 +294,14 @@ object CommandFakePlayer : CommandFactory, EventListener { * so an ExplosionS2CPacket handler is required. */ if (packet is ExplosionS2CPacket) { - val explosion = Explosion( - world, - null, - packet.x, - packet.y, - packet.z, - packet.radius, - packet.affectedBlocks, - packet.destructionType, - packet.particle, - packet.emitterParticle, - packet.soundEvent - ) - fakePlayers.forEach { fakePlayer -> - if (!explosionBehavior.shouldDamage(explosion, fakePlayer)) { // might not be necessary - return@handler - } - - fakePlayer.damage( - Explosion.createDamageSource(world, null), - explosionBehavior.calculateDamage(explosion, fakePlayer) + val damage = fakePlayer.getDamageFromExplosion( + pos = packet.center // will only work for crystals ) + + val absorption = fakePlayer.absorptionAmount + fakePlayer.health -= damage - absorption + fakePlayer.absorptionAmount -= damage.coerceAtMost(absorption) } } @@ -324,14 +310,48 @@ object CommandFakePlayer : CommandFactory, EventListener { */ if ( packet is PlayerInteractEntityC2SPacket && - fakePlayers.any { fakePlayers -> - packet.entityId == fakePlayers.id + fakePlayers.any { fakePlayer -> + packet.entityId == fakePlayer.id } ) { it.cancelEvent() } } + @Suppress("unused") + val attackHandler = handler { + if (fakePlayers.isEmpty()) { + return@handler + } + + val contains = fakePlayers.none { player -> + player.id == it.entity.id + } + + if (!contains) { + return@handler + } + + val fakePlayer = it.entity as LivingEntity + + val genericAttackDamage = if (player.isUsingRiptide) { + player.riptideAttackDamage + } else { + player.getAttributeValue(EntityAttributes.ATTACK_DAMAGE).toFloat() + } + val damageSource = player.damageSources.playerAttack(player) + var enchantAttackDamage = player.getDamageAgainst(fakePlayer, genericAttackDamage, + damageSource) - genericAttackDamage + + val attackCooldown = player.getAttackCooldownProgress(0.5f) + enchantAttackDamage *= attackCooldown + val damage = fakePlayer.getEffectiveDamage(damageSource, enchantAttackDamage, false) + + val absorption = fakePlayer.absorptionAmount + fakePlayer.health -= damage - absorption + fakePlayer.absorptionAmount -= damage.coerceAtMost(absorption) + } + /** * Recordings are made in the tick event handler. */ diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/ingame/fakeplayer/FakePlayer.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/ingame/fakeplayer/FakePlayer.kt index 9f5d4fc139a..193ac194386 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/ingame/fakeplayer/FakePlayer.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/ingame/fakeplayer/FakePlayer.kt @@ -19,10 +19,16 @@ package net.ccbluex.liquidbounce.features.command.commands.ingame.fakeplayer import com.mojang.authlib.GameProfile -import net.ccbluex.liquidbounce.interfaces.OtherClientPlayerEntityAddition +import net.ccbluex.liquidbounce.event.EventManager.callEvent +import net.ccbluex.liquidbounce.event.events.PacketEvent +import net.ccbluex.liquidbounce.event.events.TransferOrigin +import net.minecraft.client.MinecraftClient import net.minecraft.client.network.OtherClientPlayerEntity import net.minecraft.client.world.ClientWorld -import net.minecraft.entity.damage.DamageSource +import net.minecraft.entity.LivingEntity +import net.minecraft.entity.effect.StatusEffectInstance +import net.minecraft.entity.effect.StatusEffects +import net.minecraft.network.packet.s2c.play.EntityStatusS2CPacket /** * This class represents a Fake Player implementing @@ -64,12 +70,21 @@ open class FakePlayer( this.limbAnimator.pos = snapshot.limbPos } - /** - * Applies the actual damage. - */ - override fun damage(source: DamageSource?, amount: Float): Boolean { - @Suppress("CAST_NEVER_SUCCEEDS") // it does succeed with the mixin into OtherClientPlayerEntity - return (this as OtherClientPlayerEntityAddition).`liquid_bounce$actuallyDamage`(source, amount) + override fun setHealth(health: Float) { + super.setHealth(health) + if (getHealth() <= 0f) { + addStatusEffect(StatusEffectInstance(StatusEffects.REGENERATION, 900, 1)) + addStatusEffect(StatusEffectInstance(StatusEffects.ABSORPTION, 100, 1)) + addStatusEffect(StatusEffectInstance(StatusEffects.FIRE_RESISTANCE, 800, 0)) + setHealth(1.0f) + + val packet = EntityStatusS2CPacket(LivingEntity::class.java.cast(this), 35.toByte()) + val event = PacketEvent(TransferOrigin.RECEIVE, packet, true) + callEvent(event) + if (!event.isCancelled) { + packet.apply(MinecraftClient.getInstance().networkHandler) + } + } } /** @@ -81,6 +96,10 @@ open class FakePlayer( } super.tick() + + if (age % 10 == 0 && health < 20f) { + health = (health + 0.5f).coerceAtMost(20f) + } } /** diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/module/CommandXRay.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/module/CommandXRay.kt index b4bb3432da5..ae6dab8bcaa 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/module/CommandXRay.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/command/commands/module/CommandXRay.kt @@ -59,7 +59,7 @@ object CommandXRay : CommandFactory { val identifier = Identifier.tryParse(name) val displayName = identifier.toString() - val block = Registries.BLOCK.getOrEmpty(identifier).orElseThrow { + val block = Registries.BLOCK.getOptionalValue(identifier).orElseThrow { throw CommandException(command.result("blockNotExists", displayName)) } @@ -87,7 +87,7 @@ object CommandXRay : CommandFactory { val identifier = Identifier.tryParse(name) val displayName = identifier.toString() - val block = Registries.BLOCK.getOrEmpty(identifier).orElseThrow { + val block = Registries.BLOCK.getOptionalValue(identifier).orElseThrow { throw CommandException(command.result("blockNotExists", displayName)) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/container/NbtContainer.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/container/NbtContainer.kt index c18727c2592..fd16a8d4854 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/container/NbtContainer.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/container/NbtContainer.kt @@ -86,7 +86,7 @@ fun SimpleInventory.inventoryAsCompound(title: Text): List { val itemList = NbtList() stacks.forEachIndexed { index, itemStack -> - val itemCompound = itemStack.encode(DynamicRegistryManager.EMPTY) as NbtCompound + val itemCompound = itemStack.toNbt(DynamicRegistryManager.EMPTY) as NbtCompound itemCompound.putByte("Slot", index.toByte()) itemList.add(itemCompound) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/cosmetic/CapeCosmeticsManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/cosmetic/CapeCosmeticsManager.kt index 3568f6928aa..b188dd01d4a 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/cosmetic/CapeCosmeticsManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/cosmetic/CapeCosmeticsManager.kt @@ -20,6 +20,9 @@ package net.ccbluex.liquidbounce.features.cosmetic import com.mojang.authlib.GameProfile import net.ccbluex.liquidbounce.LiquidBounce +import net.ccbluex.liquidbounce.event.EventListener +import net.ccbluex.liquidbounce.event.events.DisconnectEvent +import net.ccbluex.liquidbounce.event.handler import net.ccbluex.liquidbounce.utils.client.mc import net.minecraft.client.texture.NativeImage import net.minecraft.client.texture.NativeImageBackedTexture @@ -31,7 +34,7 @@ import java.net.URI /** * A cape cosmetic manager */ -object CapeCosmeticsManager { +object CapeCosmeticsManager : EventListener { /** * I would prefer to use CLIENT_API but due to Cloudflare causing issues with SSL and their browser integrity check, @@ -87,15 +90,16 @@ object CapeCosmeticsManager { LiquidBounce.logger.info("Successfully loaded cape for ${player.name}") + val id = Identifier.of("liquidbounce", "cape-$name") + // Register cape texture - val capeTexture = mc.textureManager.registerDynamicTexture("liquidbounce-$name", - nativeImageBackedTexture) + mc.textureManager.registerTexture(id, nativeImageBackedTexture) // Cache cape texture - cachedCapes[name] = capeTexture + cachedCapes[name] = id // Return cape texture - response.response(capeTexture) + response.response(id) } } } @@ -136,4 +140,10 @@ object CapeCosmeticsManager { return name to String.format(CAPE_NAME_DL_BASE_URL, name) } + @Suppress("unused") + private val disconnectHandler = handler { + cachedCapes.values.forEach { mc.textureManager.destroyTexture(it) } + cachedCapes.clear() + } + } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/cosmetic/CosmeticService.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/cosmetic/CosmeticService.kt index b82461bf379..9af7928f6b3 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/cosmetic/CosmeticService.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/cosmetic/CosmeticService.kt @@ -25,6 +25,7 @@ import net.ccbluex.liquidbounce.api.oauth.OAuthClient import net.ccbluex.liquidbounce.config.gson.util.decode import net.ccbluex.liquidbounce.config.types.Configurable import net.ccbluex.liquidbounce.event.EventListener +import net.ccbluex.liquidbounce.event.events.DisconnectEvent import net.ccbluex.liquidbounce.event.events.SessionEvent import net.ccbluex.liquidbounce.event.handler import net.ccbluex.liquidbounce.utils.client.Chronometer @@ -76,7 +77,7 @@ object CosmeticService : EventListener, Configurable("Cosmetics") { if (task == null) { // Check if the required time in milliseconds has passed of the REFRESH_DELAY if (lastUpdate.hasElapsed(REFRESH_DELAY) || force) { - task = Util.getDownloadWorkerExecutor().submit { + task = Util.getDownloadWorkerExecutor().service.submit { runCatching { carriers = decode>(HttpClient.get(CARRIERS_URL)) task = null @@ -204,5 +205,10 @@ object CosmeticService : EventListener, Configurable("Cosmetics") { transferTemporaryOwnership(uuid) } + @Suppress("unused") + private val disconnectHandler = handler { + carriersCosmetics.clear() + } + } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleBacktrack.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleBacktrack.kt index a011c8a556b..bc9f275d6d0 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleBacktrack.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleBacktrack.kt @@ -145,7 +145,9 @@ object ModuleBacktrack : ClientModule("Backtrack", Category.COMBAT) { val pos = if (packet is EntityS2CPacket) { position?.withDelta(packet.deltaX.toLong(), packet.deltaY.toLong(), packet.deltaZ.toLong()) } else { - (packet as EntityPositionS2CPacket).let { vec -> Vec3d(vec.x, vec.y, vec.z) } + (packet as EntityPositionS2CPacket).let { p -> + Vec3d(p.change.position.x, p.change.position.y, p.change.position.z) + } } position?.setPos(pos) @@ -217,8 +219,7 @@ object ModuleBacktrack : ClientModule("Backtrack", Category.COMBAT) { 0.0, 0.0, 0.0, - entity.yaw, - 1.0f, + 1f, event.matrixStack, mc.bufferBuilders.entityVertexConsumers, reducedLight diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleFakeLag.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleFakeLag.kt index 2737676a8bf..0afda862884 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleFakeLag.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleFakeLag.kt @@ -42,6 +42,7 @@ import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket import net.minecraft.network.packet.s2c.play.ExplosionS2CPacket import net.minecraft.network.packet.s2c.play.HealthUpdateS2CPacket import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket +import kotlin.jvm.optionals.getOrNull /** * FakeLag module @@ -159,9 +160,11 @@ object ModuleFakeLag : ClientModule("FakeLag", Category.COMBAT) { // Flush on explosion is ExplosionS2CPacket -> { - if (packet.playerVelocityX != 0f || packet.playerVelocityY != 0f || packet.playerVelocityZ != 0f) { - chronometer.reset() - return@handler + packet.playerKnockback.getOrNull()?.let { knockback -> + if (knockback.x != 0.0 || knockback.y != 0.0 || knockback.z != 0.0) { + chronometer.reset() + return@handler + } } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/aimbot/DroneControlScreen.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/aimbot/DroneControlScreen.kt index 1783f6b521d..04284c95946 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/aimbot/DroneControlScreen.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/aimbot/DroneControlScreen.kt @@ -21,9 +21,8 @@ import net.minecraft.util.math.Vec2f import net.minecraft.util.math.Vec3d import org.joml.Vector2d import org.lwjgl.glfw.GLFW -import java.lang.Math.pow import kotlin.math.hypot -import kotlin.math.log +import kotlin.math.pow private const val DRAG_BUTTON = 0 @@ -45,8 +44,8 @@ class DroneControlScreen : Screen("BowAimbot Control Panel".asText()) { private var zoomSteps = 0.0 - fun getZoomFactor(): Double { - return pow(ZOOM_STEP_BASE, zoomSteps) + fun getZoomFactor(): Float { + return ZOOM_STEP_BASE.pow(zoomSteps).toFloat() } override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/criticals/modes/CriticalsJump.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/criticals/modes/CriticalsJump.kt index ddb09e94625..8008ad30c1d 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/criticals/modes/CriticalsJump.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/criticals/modes/CriticalsJump.kt @@ -89,7 +89,7 @@ object CriticalsJump : Choice("Jump") { // Change the jump motion only if the jump is a normal jump (small jumps, i.e. honey blocks // are not affected) and currently. if (enemies.isNotEmpty() && player.isOnGround) { - event.jumping = true + event.jump = true adjustNextJump = true } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/crystalaura/CrystalAuraDamageOptions.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/crystalaura/CrystalAuraDamageOptions.kt index 8c1c53fcdcd..05464e567dc 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/crystalaura/CrystalAuraDamageOptions.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/crystalaura/CrystalAuraDamageOptions.kt @@ -185,8 +185,8 @@ object CrystalAuraDamageOptions : Configurable("Damage") { ): DamageProvider { return NormalDamageProvider(entity.getDamageFromExplosion( crystal, - maxBlastResistance = maxBlastResistance, - include = include + include = include, + maxBlastResistance = maxBlastResistance )) } }; diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/crystalaura/PredictFeature.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/crystalaura/PredictFeature.kt index 402bb30ea4c..2ed3bce761d 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/crystalaura/PredictFeature.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/crystalaura/PredictFeature.kt @@ -95,16 +95,16 @@ abstract class PredictFeature(name: String) : ToggleableConfigurable(ModuleCryst if (!enabled) { return NormalDamageProvider(player.getDamageFromExplosion( crystal, - maxBlastResistance = maxBlastResistance, - include = include + include = include, + maxBlastResistance = maxBlastResistance )) } val simulated = getSnapshotPos(player, ticks) val predictedDamage = player.getDamageFromExplosion( crystal, - maxBlastResistance = maxBlastResistance, include = include, + maxBlastResistance = maxBlastResistance, entityBoundingBox = Box( simulated.x, simulated.y, @@ -120,7 +120,7 @@ abstract class PredictFeature(name: String) : ToggleableConfigurable(ModuleCryst return NormalDamageProvider(predictedDamage) } - val damage = player.getDamageFromExplosion(crystal, maxBlastResistance = maxBlastResistance, include = include) + val damage = player.getDamageFromExplosion(crystal, include = include, maxBlastResistance = maxBlastResistance) calcMode as Both return calcMode.logicalOperator.getDamageProvider(damage, predictedDamage) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/crystalaura/SubmoduleIdPredict.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/crystalaura/SubmoduleIdPredict.kt index 2d179e3fa16..5c62ab7b804 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/crystalaura/SubmoduleIdPredict.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/crystalaura/SubmoduleIdPredict.kt @@ -76,7 +76,8 @@ object SubmoduleIdPredict : ToggleableConfigurable(ModuleCrystalAura, "IDPredict player.z, rotation.yaw, rotation.pitch, - player.isOnGround + player.isOnGround, + player.horizontalCollision )) } @@ -91,7 +92,8 @@ object SubmoduleIdPredict : ToggleableConfigurable(ModuleCrystalAura, "IDPredict player.z, oldRotation!!.yaw, oldRotation!!.pitch, - player.isOnGround + player.isOnGround, + player.horizontalCollision )) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/ModuleKillAura.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/ModuleKillAura.kt index d4712b78642..5239b6d6625 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/ModuleKillAura.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/ModuleKillAura.kt @@ -510,14 +510,16 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) { } if (rotations.rotationTimingMode == RotationTimingMode.ON_TICK && rotation != null) { - network.sendPacket(Full(player.x, player.y, player.z, rotation.yaw, rotation.pitch, player.isOnGround)) + network.sendPacket(Full(player.x, player.y, player.z, rotation.yaw, rotation.pitch, player.isOnGround, + player.horizontalCollision)) } attack() if (rotations.rotationTimingMode == RotationTimingMode.ON_TICK && rotation != null) { network.sendPacket( - Full(player.x, player.y, player.z, player.withFixedYaw(rotation), player.pitch, player.isOnGround) + Full(player.x, player.y, player.z, player.withFixedYaw(rotation), player.pitch, player.isOnGround, + player.horizontalCollision) ) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/features/KillAuraAutoBlock.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/features/KillAuraAutoBlock.kt index 933636c8906..b6fc792e11d 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/features/KillAuraAutoBlock.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/features/KillAuraAutoBlock.kt @@ -37,9 +37,10 @@ import net.ccbluex.liquidbounce.utils.combat.shouldBeAttacked import net.ccbluex.liquidbounce.utils.entity.isBlockAction import net.ccbluex.liquidbounce.utils.entity.rotation import net.minecraft.item.ItemStack +import net.minecraft.item.consume.UseAction import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket +import net.minecraft.util.ActionResult import net.minecraft.util.Hand -import net.minecraft.util.UseAction import net.minecraft.util.hit.HitResult import java.security.SecureRandom @@ -141,7 +142,8 @@ object KillAuraAutoBlock : ToggleableConfigurable(ModuleKillAura, "AutoBlocking" // Interact with the item in the block hand val actionResult = interaction.interactItem(player, blockHand) if (actionResult.isAccepted) { - if (actionResult.shouldSwingHand()) { + if (actionResult is ActionResult.Success && + actionResult.swingSource == ActionResult.SwingSource.CLIENT) { player.swingHand(blockHand) } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/features/KillAuraFightBot.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/features/KillAuraFightBot.kt index 42321ab9b53..ccd921d32c7 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/features/KillAuraFightBot.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/killaura/features/KillAuraFightBot.kt @@ -82,7 +82,7 @@ object KillAuraFightBot : ToggleableConfigurable(ModuleKillAura, "FightBot", fal // Jump if we are stuck if (player.horizontalCollision) { - ev.jumping = true + ev.jump = true } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/tpaura/modes/AStarMode.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/tpaura/modes/AStarMode.kt index 458f792028f..23d265b4c7f 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/tpaura/modes/AStarMode.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/tpaura/modes/AStarMode.kt @@ -26,7 +26,7 @@ import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.PositionAndOnGr import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket import net.minecraft.util.math.Box import net.minecraft.util.math.Vec3i -import java.util.TreeSet +import java.util.* import kotlin.math.roundToInt private class Node(val position: Vec3i, var parent: Node? = null) { @@ -124,7 +124,8 @@ object AStarMode : TpAuraChoice("AStar") { packet.z = position.z packet.changePosition = true } else if (packet is PlayerPositionLookS2CPacket) { - chat(markAsError("Server setback detected - teleport failed at ${packet.x} ${packet.y} ${packet.z}!")) + val change = packet.change.position + chat(markAsError("Server setback detected - teleport failed at ${change.x} ${change.y} ${change.z}!")) stuckChronometer.reset() pathCache = null desyncPlayerPosition = null @@ -147,7 +148,7 @@ object AStarMode : TpAuraChoice("AStar") { for (position in chunk) { network.sendPacket( PositionAndOnGround( - position.x + 0.5, position.y.toDouble(), position.z + 0.5, false + position.x + 0.5, position.y.toDouble(), position.z + 0.5, false, false ) ) desyncPlayerPosition = position.toVec3d() @@ -155,7 +156,7 @@ object AStarMode : TpAuraChoice("AStar") { continue } else { // If the path is clear, we can teleport to the last position of the chunk. - network.sendPacket(PositionAndOnGround(end.x, end.y, end.z, false)) + network.sendPacket(PositionAndOnGround(end.x, end.y, end.z, false, false)) desyncPlayerPosition = end } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/velocity/mode/VelocityExemptGrim117.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/velocity/mode/VelocityExemptGrim117.kt index 54579a68c90..11d38f04f59 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/velocity/mode/VelocityExemptGrim117.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/velocity/mode/VelocityExemptGrim117.kt @@ -69,7 +69,8 @@ internal object VelocityExemptGrim117 : Choice("ExemptGrim117") { it.cancelEvent() waitTicks(1) repeat(if (alternativeBypass) 4 else 1) { - network.sendPacket(Full(player.x, player.y, player.z, player.yaw, player.pitch, player.isOnGround)) + network.sendPacket(Full(player.x, player.y, player.z, player.yaw, player.pitch, player.isOnGround, + player.horizontalCollision)) } network.sendPacket( PlayerActionC2SPacket( diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/velocity/mode/VelocityJumpReset.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/velocity/mode/VelocityJumpReset.kt index 39e87311a22..64f94f2e15d 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/velocity/mode/VelocityJumpReset.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/velocity/mode/VelocityJumpReset.kt @@ -57,7 +57,7 @@ internal object VelocityJumpReset : Choice("JumpReset") { return@handler } - it.jumping = true + it.jump = true limitUntilJump = 0 } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/velocity/mode/VelocityModify.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/velocity/mode/VelocityModify.kt index 39b8a2d0714..7d43bbe20b0 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/velocity/mode/VelocityModify.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/velocity/mode/VelocityModify.kt @@ -91,11 +91,13 @@ internal object VelocityModify : Choice("Modify") { // note: explosion packets are being used by hypixel to trick poorly made cheats. // Modify packet according to the specified values - packet.playerVelocityX *= horizontal - packet.playerVelocityY *= vertical - packet.playerVelocityZ *= horizontal + packet.playerKnockback.ifPresent { knockback -> + knockback.x *= horizontal + knockback.y *= vertical + knockback.z *= horizontal - NoFallBlink.waitUntilGround = true + NoFallBlink.waitUntilGround = true + } } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/ModuleDamage.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/ModuleDamage.kt index bef61f7ff4b..b61ea791f6c 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/ModuleDamage.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/ModuleDamage.kt @@ -54,10 +54,27 @@ object ModuleDamage : ClientModule("Damage", Category.EXPLOIT, disableActivation val (x, y, z) = player.exactPosition repeat(65 * damage) { - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(x, y + 0.049, z, false)) - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(x, y, z, false)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround( + x, + y + 0.049, + z, + false, + player.horizontalCollision)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround( + x, + y, + z, + false, + player.horizontalCollision + )) } - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(x, y, z, true)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround( + x, + y, + z, + true, + player.horizontalCollision + )) } ), AAC( @@ -76,10 +93,14 @@ object ModuleDamage : ClientModule("Damage", Category.EXPLOIT, disableActivation Verus( "Verus", { - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false)) - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y + 3.25, player.z, false)) - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false)) - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, true)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false, + player.horizontalCollision)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y + 3.25, player.z, false, + player.horizontalCollision)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false, + player.horizontalCollision)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, true, + player.horizontalCollision)) } ) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/ModuleKick.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/ModuleKick.kt index cbad4d3278b..c97e03f0695 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/ModuleKick.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/ModuleKick.kt @@ -63,7 +63,8 @@ object ModuleKick : ClientModule("Kick", Category.EXPLOIT, disableActivation = t Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, - !player.isOnGround + !player.isOnGround, + !player.horizontalCollision ) ) }), diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/disabler/disablers/DisablerAdvancedAntiCheat1910.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/disabler/disablers/DisablerAdvancedAntiCheat1910.kt index 4d347cc4d3f..488bec0cd36 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/disabler/disablers/DisablerAdvancedAntiCheat1910.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/disabler/disablers/DisablerAdvancedAntiCheat1910.kt @@ -24,6 +24,7 @@ import net.ccbluex.liquidbounce.event.handler import net.ccbluex.liquidbounce.features.module.modules.exploit.disabler.ModuleDisabler import net.minecraft.network.packet.c2s.play.PlayerInputC2SPacket import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket +import net.minecraft.util.PlayerInput /** * AAC 1.9.10 disabler @@ -33,9 +34,19 @@ internal object DisablerAdvancedAntiCheat1910 : ToggleableConfigurable(ModuleDis @Suppress("unused") private val packetHandler = handler { event -> if (event.packet is PlayerMoveC2SPacket) { + val input = player.input.playerInput + network.sendPacket( PlayerInputC2SPacket( - player.sidewaysSpeed, player.forwardSpeed, true, player.input.sneaking + PlayerInput( + input.forward, + input.backward, + input.left, + input.right, + true, + input.sneak, + input.sprint + ) ) ) event.packet.y += 7.0E-9 diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/disabler/disablers/DisablerHypixel.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/disabler/disablers/DisablerHypixel.kt index ade8102ba35..9efe40f1c1f 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/disabler/disablers/DisablerHypixel.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/disabler/disablers/DisablerHypixel.kt @@ -69,7 +69,7 @@ internal object DisablerHypixel : ToggleableConfigurable(ModuleDisabler, "Hypixe @Suppress("unused") private val movementInputHandler = handler { event -> if (jump) { - event.jumping = true + event.jump = true } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/disabler/disablers/DisablerVerusExperimental.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/disabler/disablers/DisablerVerusExperimental.kt index 7407668dd67..5ec267f0908 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/disabler/disablers/DisablerVerusExperimental.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/disabler/disablers/DisablerVerusExperimental.kt @@ -109,7 +109,8 @@ internal object DisablerVerusExperimental : ToggleableConfigurable(ModuleDisable player.z, player.yaw, player.pitch, - true + true, + player.horizontalCollision ) ) @@ -120,7 +121,8 @@ internal object DisablerVerusExperimental : ToggleableConfigurable(ModuleDisable player.lastZ, player.lastYaw, player.lastPitch, - false + false, + player.horizontalCollision ) ) @@ -131,7 +133,8 @@ internal object DisablerVerusExperimental : ToggleableConfigurable(ModuleDisable player.z, player.yaw, player.pitch, - player.isOnGround + player.isOnGround, + player.horizontalCollision ) ) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/servercrasher/exploits/NegativeInfinityExploit.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/servercrasher/exploits/NegativeInfinityExploit.kt index db2d8a11fab..74238d86c63 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/servercrasher/exploits/NegativeInfinityExploit.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/servercrasher/exploits/NegativeInfinityExploit.kt @@ -36,7 +36,7 @@ object NegativeInfinityExploit : Choice("NegativeInfinity") { override fun enable() { network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(Double.NEGATIVE_INFINITY, - Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, true)) + Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, true, false)) ModuleServerCrasher.enabled = false } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/fun/ModuleHandDerp.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/fun/ModuleHandDerp.kt index 945c2af18c1..de36ac80ae7 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/fun/ModuleHandDerp.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/fun/ModuleHandDerp.kt @@ -68,7 +68,8 @@ object ModuleHandDerp : ClientModule("HandDerp", Category.FUN) { calculatePlayerPartValue(), currentHand, mc.shouldFilterText(), - mc.options.allowServerListing.value + mc.options.allowServerListing.value, + mc.options.particles.value ) ) ) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/fun/ModuleSkinDerp.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/fun/ModuleSkinDerp.kt index 38d3560a184..aa829f9dc13 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/fun/ModuleSkinDerp.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/fun/ModuleSkinDerp.kt @@ -50,11 +50,11 @@ object ModuleSkinDerp : ClientModule("SkinDerp", Category.FUN) { override fun disable() { // Disable all current model parts for (modelPart in PlayerModelPart.entries) { - mc.options.togglePlayerModelPart(modelPart, false) + mc.options.setPlayerModelPart(modelPart, false) } // Enable all old model parts for (modelPart in prevModelParts) { - mc.options.togglePlayerModelPart(modelPart, true) + mc.options.setPlayerModelPart(modelPart, true) } } @@ -72,9 +72,9 @@ object ModuleSkinDerp : ClientModule("SkinDerp", Category.FUN) { for ((part, isEnabled) in partsMap) { if (isEnabled) { if (sync) - mc.options.togglePlayerModelPart(part, !mc.options.isPlayerModelPartEnabled(part)) + mc.options.setPlayerModelPart(part, !mc.options.isPlayerModelPartEnabled(part)) else - mc.options.togglePlayerModelPart(part, Random.nextBoolean()) + mc.options.setPlayerModelPart(part, Random.nextBoolean()) } } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/fun/ModuleTwerk.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/fun/ModuleTwerk.kt index f5f649e9f75..dcc00ee778c 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/fun/ModuleTwerk.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/fun/ModuleTwerk.kt @@ -40,7 +40,7 @@ object ModuleTwerk : ClientModule("Twerk", Category.FUN) { */ val movementInputHandler = handler(priority = 10) { val sneaking = player.age % (delay * 2) < delay - it.sneaking = sneaking + it.sneak = sneaking } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleAutoPearl.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleAutoPearl.kt index 319b9885185..91c8a0cd74d 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleAutoPearl.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleAutoPearl.kt @@ -1,3 +1,21 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ package net.ccbluex.liquidbounce.features.module.modules.misc import com.oracle.truffle.runtime.collection.ArrayQueue @@ -27,6 +45,7 @@ import net.ccbluex.liquidbounce.utils.kotlin.Priority import net.minecraft.entity.Entity import net.minecraft.entity.EntityDimensions import net.minecraft.entity.EntityType +import net.minecraft.entity.SpawnReason import net.minecraft.entity.projectile.thrown.EnderPearlEntity import net.minecraft.item.Items import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket @@ -47,11 +66,6 @@ object ModuleAutoPearl : ClientModule("AutoPearl", Category.MISC, aliases = arra private val mode by enumChoice("Mode", Modes.TRIGGER) - init { - tree(Rotate) - tree(Limits) - } - private object Limits : ToggleableConfigurable(this, "Limits", true) { val angle by int("Angle", 180, 0..180, suffix = "°") val activationDistance by float("MinDistance", 8.0f, 0.0f..10.0f, suffix = "m") @@ -62,6 +76,10 @@ object ModuleAutoPearl : ClientModule("AutoPearl", Category.MISC, aliases = arra val rotations = tree(RotationsConfigurable(this)) } + init { + treeAll(Rotate, Limits) + } + private val combatPauseTime by int("CombatPauseTime", 0, 0..40, "ticks") private val slotResetDelay by intRange("SlotResetDelay", 0..0, 0..40, "ticks") @@ -74,25 +92,19 @@ object ModuleAutoPearl : ClientModule("AutoPearl", Category.MISC, aliases = arra @Suppress("unused") private val pearlSpawnHandler = handler { event -> - if (event.packet !is EntitySpawnS2CPacket) { - return@handler - } - - if (event.packet.entityType != EntityType.ENDER_PEARL) { + if (event.packet !is EntitySpawnS2CPacket || event.packet.entityType != EntityType.ENDER_PEARL) { return@handler } - if (enderPearlSlot == null) { - return@handler - } + enderPearlSlot ?: return@handler val data = event.packet - val entity = data.entityType.create(world) as EnderPearlEntity + val entity = data.entityType.create(world, SpawnReason.SPAWN_ITEM_USE) as EnderPearlEntity entity.onSpawnPacket(data) proceedPearl( pearl = entity, - // entity.velocity & entity.pos doesnt work, dont use it + // entity.velocity & entity.pos doesn't work, don't use it velocity = with(data) { Vec3d(velocityX, velocityY, velocityZ) }, pearlPos = with(data) { Vec3d(x, y, z) } ) @@ -224,11 +236,11 @@ object ModuleAutoPearl : ClientModule("AutoPearl", Category.MISC, aliases = arra override fun disable() { queue.clear() - super.disable() } private enum class Modes(override val choiceName: String) : NamedChoice { TRIGGER("Trigger"), TARGET("Target") } + } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleFlagCheck.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleFlagCheck.kt index 1bd7091a141..d50fa0ec471 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleFlagCheck.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleFlagCheck.kt @@ -124,7 +124,9 @@ object ModuleFlagCheck : ClientModule("FlagCheck", Category.MISC, aliases = arra flagCount++ alert(AlertReason.LAGBACK) Render.reset() - Render.wireframePlayer.setPosRot(packet.x, packet.y, packet.z, packet.yaw, packet.pitch) + val change = packet.change + val position = change.position + Render.wireframePlayer.setPosRot(position.x, position.y, position.z, change.yaw, change.pitch) } is DisconnectS2CPacket -> { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleElytraRecast.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleElytraRecast.kt index 82a4ed7c0db..1bef99cc705 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleElytraRecast.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleElytraRecast.kt @@ -16,15 +16,12 @@ * You should have received a copy of the GNU General Public License * along with LiquidBounce. If not, see . */ - package net.ccbluex.liquidbounce.features.module.modules.movement import net.ccbluex.liquidbounce.features.module.Category import net.ccbluex.liquidbounce.features.module.ClientModule - import net.minecraft.entity.EquipmentSlot import net.minecraft.entity.effect.StatusEffects -import net.minecraft.item.ElytraItem import net.minecraft.item.Items import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket @@ -47,7 +44,7 @@ object ModuleElytraRecast : ClientModule("ElytraRecast", Category.MOVEMENT) { return !player.abilities.flying && !player.hasVehicle() && !player.isClimbing && !player.isTouchingWater && !player.hasStatusEffect(StatusEffects.LEVITATION) && - itemStack.isOf(Items.ELYTRA) && ElytraItem.isUsable(itemStack) && mc.options.jumpKey.isPressed + itemStack.isOf(Items.ELYTRA) && !itemStack.willBreakNextUse() && mc.options.jumpKey.isPressed } /** @@ -57,7 +54,7 @@ object ModuleElytraRecast : ClientModule("ElytraRecast", Category.MOVEMENT) { */ fun recastElytra(): Boolean { if (shouldRecast) { - player.startFallFlying() + player.startGliding() network.sendPacket(ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.START_FALL_FLYING)) return true } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleParkour.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleParkour.kt index cf5437740a1..45e781d4096 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleParkour.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleParkour.kt @@ -42,7 +42,7 @@ object ModuleParkour : ClientModule("Parkour", Category.MOVEMENT) { val movementInput = event.movementEvent if (shouldJump) { - movementInput.jumping = true + movementInput.jump = true } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleSafeWalk.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleSafeWalk.kt index 020e12547eb..6c61ee75988 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleSafeWalk.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleSafeWalk.kt @@ -60,7 +60,7 @@ object ModuleSafeWalk : ClientModule("SafeWalk", Category.MOVEMENT) { val simulatedPlayer = SimulatedPlayer.fromClientPlayer( SimulatedPlayer.SimulatedPlayerInput( event.directionalInput, - event.jumping, + event.jump, player.isSprinting, true ) @@ -68,7 +68,7 @@ object ModuleSafeWalk : ClientModule("SafeWalk", Category.MOVEMENT) { simulatedPlayer.tick() if (simulatedPlayer.clipLedged) { - event.sneaking = true + event.sneak = true } } } @@ -93,7 +93,7 @@ object ModuleSafeWalk : ClientModule("SafeWalk", Category.MOVEMENT) { val simulatedPlayer = SimulatedPlayer.fromClientPlayer( SimulatedPlayer.SimulatedPlayerInput( event.directionalInput, - event.jumping, + event.jump, player.isSprinting, true ) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleSneak.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleSneak.kt index 3c4b402cade..9e93b902369 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleSneak.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleSneak.kt @@ -51,7 +51,7 @@ object ModuleSneak : ClientModule("Sneak", Category.MOVEMENT) { } // Temporarily override sneaking - it.sneaking = true + it.sneak = true } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleTargetStrafe.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleTargetStrafe.kt index 15b1efa1245..961269da875 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleTargetStrafe.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleTargetStrafe.kt @@ -150,10 +150,10 @@ object ModuleTargetStrafe : ClientModule("TargetStrafe", Category.MOVEMENT) { } // Determine the direction to strafe - if (!(player.input.pressingLeft && player.input.pressingRight) && controlDirection) { + if (!(player.input.playerInput.left && player.input.playerInput.right) && controlDirection) { when { - player.input.pressingLeft -> direction = -1 - player.input.pressingRight -> direction = 1 + player.input.playerInput.left -> direction = -1 + player.input.playerInput.right -> direction = 1 } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleTeleport.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleTeleport.kt index 59312e60eec..128073a741c 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleTeleport.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleTeleport.kt @@ -92,11 +92,12 @@ object ModuleTeleport : ClientModule("Teleport", Category.EXPLOIT, aliases = arr } sendPacketSilently(MovePacketType.FULL.generatePacket().apply { - this.x = it.packet.x - this.y = it.packet.y - this.z = it.packet.z - this.yaw = it.packet.yaw - this.pitch = it.packet.pitch + val change = it.packet.change + this.x = change.position.x + this.y = change.position.y + this.z = change.position.z + this.yaw = change.yaw + this.pitch = change.pitch this.onGround = false }) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleVehicleControl.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleVehicleControl.kt index 308f5acd22c..8b627de9580 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleVehicleControl.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleVehicleControl.kt @@ -119,9 +119,9 @@ object ModuleVehicleControl : ClientModule("VehicleControl", Category.MOVEMENT, val isVehicleSafe = player.controllingVehicle?.let { it.isOnGround || it.isTouchingWater } == true // Do not quit vehicle if not safe to do so - event.sneaking = event.sneaking && isVehicleSafe + event.sneak = event.sneak && isVehicleSafe - if (event.sneaking) { + if (event.sneak) { Rehook.vehicleId = -1 } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/autododge/ModuleAutoDodge.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/autododge/ModuleAutoDodge.kt index 005d2b518de..172cfb416ec 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/autododge/ModuleAutoDodge.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/autododge/ModuleAutoDodge.kt @@ -82,7 +82,7 @@ object ModuleAutoDodge : ClientModule("AutoDodge", Category.COMBAT) { if (dodgePlan.shouldJump && AllowRotationChange.allowJump && player.isOnGround) { EventScheduler.schedule(ModuleScaffold) { - it.jumping = true + it.jump = true } } @@ -96,7 +96,8 @@ object ModuleAutoDodge : ClientModule("AutoDodge", Category.COMBAT) { if (it !is ArrowEntity) { return@mapNotNull null } - if (it.inGround) { + + if (it.isInGround()) { return@mapNotNull null } @@ -191,11 +192,11 @@ object ModuleAutoDodge : ClientModule("AutoDodge", Category.COMBAT) { return null } - fun getInflictedHit(pos: Vec3d): ModuleAutoDodge.HitInfo? { - val arrows = ModuleAutoDodge.findFlyingArrows(net.ccbluex.liquidbounce.utils.client.world) + fun getInflictedHit(pos: Vec3d): HitInfo? { + val arrows = findFlyingArrows(net.ccbluex.liquidbounce.utils.client.world) val playerSimulation = RigidPlayerSimulation(pos) - return ModuleAutoDodge.getInflictedHits(playerSimulation, arrows, maxTicks = 40) + return getInflictedHits(playerSimulation, arrows, maxTicks = 40) } data class HitInfo( diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/elytrafly/modes/ElytraStatic.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/elytrafly/modes/ElytraStatic.kt index c998f8d851d..cfe25e0c388 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/elytrafly/modes/ElytraStatic.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/elytrafly/modes/ElytraStatic.kt @@ -25,6 +25,7 @@ import net.ccbluex.liquidbounce.features.module.modules.movement.elytrafly.Modul import net.ccbluex.liquidbounce.features.module.modules.movement.elytrafly.ModuleElytraFly.instant import net.ccbluex.liquidbounce.features.module.modules.movement.elytrafly.ModuleElytraFly.instantStop import net.ccbluex.liquidbounce.utils.entity.moving +import net.ccbluex.liquidbounce.utils.entity.set import net.ccbluex.liquidbounce.utils.entity.strafe import net.minecraft.entity.EquipmentSlot import net.minecraft.item.Items @@ -52,7 +53,7 @@ internal object ElytraStatic : Choice("Static") { } if (mc.options.sneakKey.isPressed && instantStop) { - player.stopFallFlying() + player.stopGliding() return@tickHandler } fun isAnyMovementKeyPressed(): Boolean { @@ -62,7 +63,7 @@ internal object ElytraStatic : Choice("Static") { } // If player is flying - if (player.isFallFlying && isAnyMovementKeyPressed()) { + if (player.isGliding && isAnyMovementKeyPressed()) { if (ModuleElytraFly.Speed.enabled) { if (player.moving) { player.strafe(speed = ModuleElytraFly.Speed.horizontal.toDouble()) @@ -74,11 +75,12 @@ internal object ElytraStatic : Choice("Static") { } } // If the player has an elytra and wants to fly instead - } else if (chestSlot.item == Items.ELYTRA && player.input.jumping) { + } else if (chestSlot.item == Items.ELYTRA && player.input.playerInput.jump) { if (instant) { // Jump must be off due to abnormal speed boosts - player.input.jumping = true - player.input.jumping = false + player.input.set( + jump = false + ) } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/elytrafly/modes/ElytraVanilla.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/elytrafly/modes/ElytraVanilla.kt index c9e04efa769..1956d7cee66 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/elytrafly/modes/ElytraVanilla.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/elytrafly/modes/ElytraVanilla.kt @@ -25,6 +25,7 @@ import net.ccbluex.liquidbounce.features.module.modules.movement.elytrafly.Modul import net.ccbluex.liquidbounce.features.module.modules.movement.elytrafly.ModuleElytraFly.instant import net.ccbluex.liquidbounce.features.module.modules.movement.elytrafly.ModuleElytraFly.instantStop import net.ccbluex.liquidbounce.utils.entity.moving +import net.ccbluex.liquidbounce.utils.entity.set import net.ccbluex.liquidbounce.utils.entity.strafe import net.minecraft.entity.EquipmentSlot import net.minecraft.item.Items @@ -55,12 +56,12 @@ internal object ElytraVanilla : Choice("Vanilla") { } if (mc.options.sneakKey.isPressed && instantStop) { - player.stopFallFlying() + player.stopGliding() return@tickHandler } // If player is flying - if (player.isFallFlying) { + if (player.isGliding) { if (ModuleElytraFly.Speed.enabled) { if (player.moving) { player.strafe(speed = ModuleElytraFly.Speed.horizontal.toDouble()) @@ -72,11 +73,12 @@ internal object ElytraVanilla : Choice("Vanilla") { } } // If the player has an elytra and wants to fly instead - } else if (chestSlot.item == Items.ELYTRA && player.input.jumping) { + } else if (chestSlot.item == Items.ELYTRA && player.input.playerInput.jump) { if (instant) { // Jump must be off due to abnormal speed boosts - player.input.jumping = true - player.input.jumping = false + player.input.set( + jump = false + ) } } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/FlyGeneric.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/FlyGeneric.kt index 5a318927037..9eb38898bec 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/FlyGeneric.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/FlyGeneric.kt @@ -40,6 +40,7 @@ import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket import net.minecraft.network.packet.s2c.play.ExplosionS2CPacket import net.minecraft.util.shape.VoxelShapes +import kotlin.jvm.optionals.getOrNull internal object FlyVanilla : Choice("Vanilla") { @@ -75,8 +76,8 @@ internal object FlyVanilla : Choice("Vanilla") { player.strafe(speed = hSpeed.toDouble()) player.velocity.y = when { - player.input.jumping -> vSpeed.toDouble() - player.input.sneaking -> (-vSpeed).toDouble() + player.input.playerInput.jump -> vSpeed.toDouble() + player.input.playerInput.sneak -> (-vSpeed).toDouble() else -> glide.toDouble() } @@ -227,12 +228,14 @@ internal object FlyExplosion : Choice("Explosion") { waitTicks(1) strafeSince = startStrafe } else if (packet is ExplosionS2CPacket) { // Check if explosion affects velocity - packet.playerVelocityX = 0f - packet.playerVelocityY *= vertical - packet.playerVelocityZ = 0f + packet.playerKnockback.getOrNull()?.let { knockback -> + knockback.x = 0.0 + knockback.y *= vertical + knockback.z = 0.0 - waitTicks(1) - strafeSince = startStrafe + waitTicks(1) + strafeSince = startStrafe + } } } @@ -244,7 +247,7 @@ internal object FlyJetpack : Choice("Jetpack") { get() = ModuleFly.modes val repeatable = tickHandler { - if (player.input.jumping) { + if (player.input.playerInput.jump) { player.velocity.x *= 1.1 player.velocity.y += 0.15 player.velocity.z *= 1.1 diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/sentinel/FlySentinel10thMar.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/sentinel/FlySentinel10thMar.kt index bcfb003cddf..92de8e93286 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/sentinel/FlySentinel10thMar.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/sentinel/FlySentinel10thMar.kt @@ -60,7 +60,7 @@ internal object FlySentinel10thMar : Choice("Sentinel10thMar") { } val moveHandler = handler { - it.jumping = false + it.jump = false } val packetHandler = handler { event -> diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/sentinel/FlySentinel20thApr.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/sentinel/FlySentinel20thApr.kt index ca03510e82e..2809704254a 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/sentinel/FlySentinel20thApr.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/sentinel/FlySentinel20thApr.kt @@ -118,8 +118,8 @@ internal object FlySentinel20thApr : Choice("Sentinel20thApr") { } event.movement.y = when { - player.input.jumping -> verticalSpeed.toDouble() - player.input.sneaking -> (-verticalSpeed).toDouble() + player.input.playerInput.jump -> verticalSpeed.toDouble() + player.input.playerInput.sneak -> (-verticalSpeed).toDouble() else -> 0.0 } @@ -130,13 +130,14 @@ internal object FlySentinel20thApr : Choice("Sentinel20thApr") { private fun boost() { hasBeenHurt = false - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false, + player.horizontalCollision)) network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y + 3.25, player.z, - false)) - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false)) - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, true)) + false, player.horizontalCollision)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false, + player.horizontalCollision)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, true, + player.horizontalCollision)) } - - } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/sentinel/FlySentinel27thJan.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/sentinel/FlySentinel27thJan.kt index 5b05edc5f5d..07d33a5bba7 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/sentinel/FlySentinel27thJan.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/sentinel/FlySentinel27thJan.kt @@ -56,7 +56,7 @@ internal object FlySentinel27thJan : Choice("Sentinel27thJan") { player.velocity.y = when { player.isSneaking -> -0.4 - player.input.jumping -> 0.42 + player.input.playerInput.jump -> 0.42 else -> 0.2 } player.strafe(speed = horizontalSpeed.random()) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/specific/FlyNcpClip.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/specific/FlyNcpClip.kt index bd53a4d8cc3..1e5a0c782e0 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/specific/FlyNcpClip.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/specific/FlyNcpClip.kt @@ -92,13 +92,13 @@ object FlyNcpClip : Choice("NcpClip") { network.sendPacket( PlayerMoveC2SPacket.PositionAndOnGround( player.x, player.y + clipping, player.z, - false + false, player.horizontalCollision ) ) network.sendPacket( PlayerMoveC2SPacket.PositionAndOnGround( player.x, player.y, player.z, - false + false, player.horizontalCollision ) ) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/verus/FlyVerusB3869Flat.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/verus/FlyVerusB3869Flat.kt index 93cd6f24ab5..d41ab564afa 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/verus/FlyVerusB3869Flat.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/verus/FlyVerusB3869Flat.kt @@ -87,7 +87,7 @@ internal object FlyVerusB3869Flat : Choice("VerusB3896Flat") { network.sendPacket( PlayerMoveC2SPacket.PositionAndOnGround( player.x, player.y - 0.5, player.z, - false + false, player.horizontalCollision ) ) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/verus/FlyVerusB3896Damage.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/verus/FlyVerusB3896Damage.kt index 003f6032867..8ca075f3d42 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/verus/FlyVerusB3896Damage.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/verus/FlyVerusB3896Damage.kt @@ -49,10 +49,14 @@ internal object FlyVerusB3896Damage : Choice("VerusB3896Damage") { private var gotDamage = false override fun enable() { - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false)) - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y + 3.25, player.z, false)) - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false)) - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, true)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false, + player.horizontalCollision)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y + 3.25, player.z, false, + player.horizontalCollision)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false, + player.horizontalCollision)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, true, + player.horizontalCollision)) } @Suppress("unused") diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/vulcan/FlyVulcan286.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/vulcan/FlyVulcan286.kt index 48e2b655a7b..ee91f033491 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/vulcan/FlyVulcan286.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/vulcan/FlyVulcan286.kt @@ -64,7 +64,7 @@ internal object FlyVulcan286 : Choice("Vulcan286-113") { network.sendPacket( PlayerMoveC2SPacket.Full( player.x, player.y - 0.1, player.z, - player.yaw, player.pitch, player.isOnGround + player.yaw, player.pitch, player.isOnGround, player.horizontalCollision ) ) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/vulcan/FlyVulcan286MC18.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/vulcan/FlyVulcan286MC18.kt index fa7cc4c49a0..bb01090d568 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/vulcan/FlyVulcan286MC18.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/vulcan/FlyVulcan286MC18.kt @@ -90,7 +90,7 @@ internal object FlyVulcan286MC18 : Choice("Vulcan286-18") { if (packet is PlayerPositionLookS2CPacket) { flags++ if (autoDisable) { - val pos = Vec3d(packet.x, packet.y, packet.z) + val pos = packet.change.position if (flags == 2) { flagPos = pos } else if (flags > 2 && flagPos != pos) { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/vulcan/FlyVulcan286Teleport.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/vulcan/FlyVulcan286Teleport.kt index 6ec91013081..d519c7a943f 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/vulcan/FlyVulcan286Teleport.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/fly/modes/vulcan/FlyVulcan286Teleport.kt @@ -80,7 +80,13 @@ internal object FlyVulcan286Teleport : Choice("Vulcan286-Teleport-18") { waitUntil { player.hurtTime > 0 } // Flag to disable some checks... - network.sendPacket(PositionAndOnGround(player.x, player.y - 0.1, player.z, player.isOnGround)) + network.sendPacket(PositionAndOnGround( + player.x, + player.y - 0.1, + player.z, + player.isOnGround, + player.horizontalCollision + )) waitUntil { flagged } @@ -92,7 +98,13 @@ internal object FlyVulcan286Teleport : Choice("Vulcan286-Teleport-18") { // Used 9 because stable... // Otherwise, last teleport would flag since player also moves a bit player.setPosition(player.x + vector.x * 9, player.y, player.z + vector.z * 9) - network.sendPacket(PositionAndOnGround(player.x, player.y, player.z, player.isOnGround)) + network.sendPacket(PositionAndOnGround( + player.x, + player.y, + player.z, + player.isOnGround, + player.horizontalCollision + )) } ModuleFly.enabled = false diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/liquidwalk/modes/LiquidWalkNoCheatPlus.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/liquidwalk/modes/LiquidWalkNoCheatPlus.kt index 3dd2a008ed8..8877333a899 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/liquidwalk/modes/LiquidWalkNoCheatPlus.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/liquidwalk/modes/LiquidWalkNoCheatPlus.kt @@ -52,7 +52,7 @@ internal object LiquidWalkNoCheatPlus : Choice("NoCheatPlus") { @Suppress("unused") val shapeHandler = handler { event -> - if (player.input.sneaking || player.fallDistance > 3.0f || player.isOnFire) { + if (player.input.playerInput.sneak || player.fallDistance > 3.0f || player.isOnFire) { return@handler } @@ -64,7 +64,7 @@ internal object LiquidWalkNoCheatPlus : Choice("NoCheatPlus") { } val repeatable = tickHandler { - if (player.box.isBlockAtPosition { it is FluidBlock } && !player.input.sneaking) { + if (player.box.isBlockAtPosition { it is FluidBlock } && !player.input.playerInput.sneak) { player.velocity.y = 0.08 } } @@ -73,7 +73,11 @@ internal object LiquidWalkNoCheatPlus : Choice("NoCheatPlus") { val packet = event.packet if (event.origin == TransferOrigin.SEND && packet is PlayerMoveC2SPacket) { - if (!player.input.sneaking && !player.isTouchingWater && standingOnWater() && !collidesWithAnythingElse()) { + if (!player.input.playerInput.sneak && + !player.isTouchingWater && + standingOnWater() && + !collidesWithAnythingElse() + ) { if (shiftDown) { packet.y -= 0.001 } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/liquidwalk/modes/LiquidWalkVanilla.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/liquidwalk/modes/LiquidWalkVanilla.kt index 138b12d7eea..04d74fef7b1 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/liquidwalk/modes/LiquidWalkVanilla.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/liquidwalk/modes/LiquidWalkVanilla.kt @@ -39,17 +39,17 @@ internal object LiquidWalkVanilla : Choice("Vanilla") { @Suppress("unused") val inputHandler = handler { event -> - if (event.sneaking || !player.box.isBlockAtPosition { it is FluidBlock }) { + if (event.sneak || !player.box.isBlockAtPosition { it is FluidBlock }) { return@handler } // Swims up - event.jumping = true + event.jump = true } @Suppress("unused") val shapeHandler = handler { event -> - if (player.input.sneaking || player.fallDistance > 3.0f || player.isOnFire) { + if (player.input.playerInput.sneak || player.fallDistance > 3.0f || player.isOnFire) { return@handler } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/liquidwalk/modes/LiquidWalkVerusB3901.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/liquidwalk/modes/LiquidWalkVerusB3901.kt index a2baf552c8f..16575236b76 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/liquidwalk/modes/LiquidWalkVerusB3901.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/liquidwalk/modes/LiquidWalkVerusB3901.kt @@ -50,7 +50,7 @@ internal object LiquidWalkVerusB3901 : Choice("VerusB3901") { @Suppress("unused") val shapeHandler = handler { event -> - if (player.input.sneaking || player.fallDistance > 3.0f || player.isOnFire) { + if (player.input.playerInput.sneak || player.fallDistance > 3.0f || player.isOnFire) { return@handler } @@ -63,7 +63,11 @@ internal object LiquidWalkVerusB3901 : Choice("VerusB3901") { val packet = event.packet if (event.origin == TransferOrigin.SEND && packet is PlayerMoveC2SPacket) { - if (!player.input.sneaking && !player.isTouchingWater && standingOnWater() && !collidesWithAnythingElse()) { + if (!player.input.playerInput.sneak && + !player.isTouchingWater && + standingOnWater() && + !collidesWithAnythingElse() + ) { packet.onGround = spoof spoof = !spoof } else { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/longjump/modes/VulcanLongJump.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/longjump/modes/VulcanLongJump.kt index 78062d6bc4e..e8528399720 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/longjump/modes/VulcanLongJump.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/longjump/modes/VulcanLongJump.kt @@ -107,6 +107,7 @@ internal object VulcanLongJump : Choice("Vulcan289") { player.pos.x, player.pos.y + position, player.pos.z, + false, false ) ) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/longjump/modes/nocheatplus/NoCheatPlusBow.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/longjump/modes/nocheatplus/NoCheatPlusBow.kt index 002b6f3370b..ed28d5014d0 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/longjump/modes/nocheatplus/NoCheatPlusBow.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/longjump/modes/nocheatplus/NoCheatPlusBow.kt @@ -116,7 +116,7 @@ internal object NoCheatPlusBow : Choice("NoCheatPlusBow") { } if (player.fallDistance >= fallDistance) { - it.jumping = true + it.jump = true player.fallDistance = 0f } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/ModuleNoSlow.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/ModuleNoSlow.kt index 83ce68e3130..c10a69811eb 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/ModuleNoSlow.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/ModuleNoSlow.kt @@ -24,6 +24,7 @@ import net.ccbluex.liquidbounce.features.module.Category import net.ccbluex.liquidbounce.features.module.ClientModule import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.blocking.NoSlowBlock import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.bow.NoSlowBow +import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.bundle.NoSlowBundle import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.consume.NoSlowConsume import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.fluid.NoSlowFluid import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.honey.NoSlowHoney @@ -31,8 +32,7 @@ import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.po import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.slime.NoSlowSlime import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.sneaking.NoSlowSneaking import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.soulsand.NoSlowSoulsand -import net.ccbluex.liquidbounce.utils.client.InteractionTracker -import net.minecraft.util.UseAction +import net.minecraft.item.consume.UseAction /** * NoSlow module @@ -45,6 +45,7 @@ object ModuleNoSlow : ClientModule("NoSlow", Category.MOVEMENT) { tree(NoSlowBlock) tree(NoSlowConsume) tree(NoSlowBow) + tree(NoSlowBundle) tree(NoSlowSneaking) tree(NoSlowSoulsand) tree(NoSlowSlime) @@ -56,28 +57,18 @@ object ModuleNoSlow : ClientModule("NoSlow", Category.MOVEMENT) { @Suppress("unused") val multiplierHandler = handler { event -> val action = player.activeItem.useAction ?: return@handler - val (forward, strafe) = multiplier(action) + val mul = multiplier(action) - event.forward = forward - event.sideways = strafe + event.forward = mul.firstFloat() + event.sideways = mul.secondFloat() } private fun multiplier(action: UseAction) = when (action) { - UseAction.NONE -> Pair(0.2f, 0.2f) - UseAction.EAT, UseAction.DRINK -> if (NoSlowConsume.enabled) Pair( - NoSlowConsume.forwardMultiplier, NoSlowConsume.sidewaysMultiplier - ) else Pair(0.2f, 0.2f) - - UseAction.BLOCK, UseAction.SPYGLASS, UseAction.TOOT_HORN, UseAction.BRUSH -> - if (NoSlowBlock.enabled && (!NoSlowBlock.onlySlowOnServerSide || !InteractionTracker.isBlocking)) Pair( - NoSlowBlock.forwardMultiplier, - NoSlowBlock.sidewaysMultiplier - ) - else Pair(0.2f, 0.2f) - - UseAction.BOW, UseAction.CROSSBOW, UseAction.SPEAR -> if (NoSlowBow.enabled) Pair( - NoSlowBow.forwardMultiplier, NoSlowBow.sidewaysMultiplier - ) else Pair(0.2f, 0.2f) - + UseAction.NONE -> NoSlowUseActionHandler.DEFAULT_USE_MUL + UseAction.EAT, UseAction.DRINK -> NoSlowConsume.getMultiplier() + UseAction.BLOCK, UseAction.SPYGLASS, UseAction.TOOT_HORN, UseAction.BRUSH -> NoSlowBlock.getMultiplier() + UseAction.BOW, UseAction.CROSSBOW, UseAction.SPEAR -> NoSlowBow.getMultiplier() + UseAction.BUNDLE -> NoSlowBundle.getMultiplier() } + } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/NoSlowUseActionHandler.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/NoSlowUseActionHandler.kt new file mode 100644 index 00000000000..460436aba8f --- /dev/null +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/NoSlowUseActionHandler.kt @@ -0,0 +1,42 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ +package net.ccbluex.liquidbounce.features.module.modules.movement.noslow + +import it.unimi.dsi.fastutil.floats.FloatFloatImmutablePair +import it.unimi.dsi.fastutil.floats.FloatFloatPair +import net.ccbluex.liquidbounce.config.types.ToggleableConfigurable + +abstract class NoSlowUseActionHandler(name: String) : ToggleableConfigurable(ModuleNoSlow, name, true) { + + private val forwardMultiplier by float("Forward", 1f, 0.2f..1f) + private val sidewaysMultiplier by float("Sideways", 1f, 0.2f..1f) + + companion object { + val DEFAULT_USE_MUL = FloatFloatImmutablePair(0.2f, 0.2f) + } + + open fun getMultiplier() : FloatFloatPair { + if (!this.enabled) { + return DEFAULT_USE_MUL + } + + return FloatFloatImmutablePair(forwardMultiplier, sidewaysMultiplier) + } + +} diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/blocking/NoSlowBlock.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/blocking/NoSlowBlock.kt index 9e8e8efe058..36776c5ffb1 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/blocking/NoSlowBlock.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/blocking/NoSlowBlock.kt @@ -18,24 +18,22 @@ */ package net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.blocking +import it.unimi.dsi.fastutil.floats.FloatFloatPair import net.ccbluex.liquidbounce.config.types.Choice import net.ccbluex.liquidbounce.config.types.NoneChoice -import net.ccbluex.liquidbounce.config.types.ToggleableConfigurable -import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.ModuleNoSlow +import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.NoSlowUseActionHandler import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.shared.NoSlowSharedGrim2360 import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.shared.NoSlowSharedGrim2364MC18 import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.shared.NoSlowSharedInvalidHand import net.ccbluex.liquidbounce.utils.client.InteractionTracker.isBlocking import net.ccbluex.liquidbounce.utils.client.inGame -import net.minecraft.util.UseAction +import net.minecraft.item.consume.UseAction -internal object NoSlowBlock : ToggleableConfigurable(ModuleNoSlow, "Blocking", true) { +internal object NoSlowBlock : NoSlowUseActionHandler("Blocking") { - val forwardMultiplier by float("Forward", 1f, 0.2f..1f) - val sidewaysMultiplier by float("Sideways", 1f, 0.2f..1f) - val onlySlowOnServerSide by boolean("OnlySlowOnServerSide", false) + private val onlySlowOnServerSide by boolean("OnlySlowOnServerSide", false) - val modes = choices(this, "Choice", { it.choices[0] }) { + val modes = choices(this, "Choice", 0) { arrayOf( NoneChoice(it), NoSlowBlockingReuse, @@ -49,6 +47,14 @@ internal object NoSlowBlock : ToggleableConfigurable(ModuleNoSlow, "Blocking", t ) } + override fun getMultiplier(): FloatFloatPair { + if (onlySlowOnServerSide && isBlocking) { + return DEFAULT_USE_MUL + } + + return super.getMultiplier() + } + override val running: Boolean get() { if (!super.running || !inGame) { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/bow/NoSlowBow.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/bow/NoSlowBow.kt index a3ff83769f6..cbe57bb3420 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/bow/NoSlowBow.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/bow/NoSlowBow.kt @@ -20,21 +20,17 @@ package net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.b import net.ccbluex.liquidbounce.config.types.Choice import net.ccbluex.liquidbounce.config.types.NoneChoice -import net.ccbluex.liquidbounce.config.types.ToggleableConfigurable -import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.ModuleNoSlow +import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.NoSlowUseActionHandler import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.shared.NoSlowNoBlockInteract import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.shared.NoSlowSharedGrim2360 import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.shared.NoSlowSharedGrim2364MC18 import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.shared.NoSlowSharedInvalidHand import net.ccbluex.liquidbounce.utils.client.inGame -import net.minecraft.util.UseAction +import net.minecraft.item.consume.UseAction -internal object NoSlowBow : ToggleableConfigurable(ModuleNoSlow, "Bow", true) { +internal object NoSlowBow : NoSlowUseActionHandler("Bow") { - val forwardMultiplier by float("Forward", 1f, 0.2f..1f) - val sidewaysMultiplier by float("Sideways", 1f, 0.2f..1f) - - val modes = choices(this, "Choice", { it.choices[0] }) { + val modes = choices(this, "Choice", 0) { arrayOf( NoneChoice(it), NoSlowSharedGrim2360(it), diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/bundle/NoSlowBundle.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/bundle/NoSlowBundle.kt new file mode 100644 index 00000000000..f48dc5dcd21 --- /dev/null +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/bundle/NoSlowBundle.kt @@ -0,0 +1,23 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ +package net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.bundle + +import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.NoSlowUseActionHandler + +object NoSlowBundle : NoSlowUseActionHandler("Bundle") diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/consume/NoSlowConsume.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/consume/NoSlowConsume.kt index dd42e7a2700..18b10b43f0c 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/consume/NoSlowConsume.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/consume/NoSlowConsume.kt @@ -20,20 +20,16 @@ package net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.c import net.ccbluex.liquidbounce.config.types.Choice import net.ccbluex.liquidbounce.config.types.NoneChoice -import net.ccbluex.liquidbounce.config.types.ToggleableConfigurable -import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.ModuleNoSlow +import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.NoSlowUseActionHandler import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.shared.NoSlowNoBlockInteract import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.shared.NoSlowSharedGrim2360 import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.shared.NoSlowSharedGrim2364MC18 import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.shared.NoSlowSharedInvalidHand import net.ccbluex.liquidbounce.utils.client.inGame import net.ccbluex.liquidbounce.utils.item.isConsumable -import net.minecraft.util.UseAction +import net.minecraft.item.consume.UseAction -object NoSlowConsume : ToggleableConfigurable(ModuleNoSlow, "Consume", true) { - - val forwardMultiplier by float("Forward", 1f, 0.2f..1f) - val sidewaysMultiplier by float("Sideways", 1f, 0.2f..1f) +object NoSlowConsume : NoSlowUseActionHandler("Consume") { @Suppress("unused") private val noBlockInteract = tree(NoSlowNoBlockInteract(this) { action -> @@ -41,7 +37,7 @@ object NoSlowConsume : ToggleableConfigurable(ModuleNoSlow, "Consume", true) { }) @Suppress("unused") - private val modes = choices(this, "Mode", { it.choices[0] }) { + private val modes = choices(this, "Mode", 0) { arrayOf( NoneChoice(it), NoSlowSharedGrim2360(it), diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/shared/NoSlowNoBlockInteract.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/shared/NoSlowNoBlockInteract.kt index 129875ac299..1588162fd9c 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/shared/NoSlowNoBlockInteract.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/shared/NoSlowNoBlockInteract.kt @@ -23,8 +23,8 @@ import net.ccbluex.liquidbounce.event.EventListener import net.ccbluex.liquidbounce.event.events.PacketEvent import net.ccbluex.liquidbounce.event.handler import net.ccbluex.liquidbounce.utils.block.getState +import net.minecraft.item.consume.UseAction import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket -import net.minecraft.util.UseAction /** * Cancels block interactions allowing to bypass certain anti-cheats diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/sneaking/NoSlowSneaking.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/sneaking/NoSlowSneaking.kt index d628b52d96a..6b8c2ae1e83 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/sneaking/NoSlowSneaking.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/noslow/modes/sneaking/NoSlowSneaking.kt @@ -42,7 +42,7 @@ internal object NoSlowSneaking : ToggleableConfigurable(ModuleNoSlow, "Sneaking" @Suppress("unused") val multiplierHandler = handler { event -> - event.multiplier = max(event.multiplier, minMultiplier) + event.multiplier = max(event.multiplier, minMultiplier.toDouble()) } override val running: Boolean diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/SpeedAntiCornerBump.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/SpeedAntiCornerBump.kt index 9df2197cb7e..3cc6a038c46 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/SpeedAntiCornerBump.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/SpeedAntiCornerBump.kt @@ -21,6 +21,7 @@ package net.ccbluex.liquidbounce.features.module.modules.movement.speed import net.ccbluex.liquidbounce.features.module.MinecraftShortcuts import net.ccbluex.liquidbounce.utils.block.getState import net.ccbluex.liquidbounce.utils.entity.SimulatedPlayer +import net.ccbluex.liquidbounce.utils.entity.set import net.ccbluex.liquidbounce.utils.movement.DirectionalInput import net.minecraft.block.BlockState import net.minecraft.entity.EntityPose @@ -38,7 +39,9 @@ object SpeedAntiCornerBump : MinecraftShortcuts { fun shouldDelayJump(): Boolean { val input = SimulatedPlayer.SimulatedPlayerInput.fromClientPlayer(DirectionalInput(player.input)) - input.jumping = true + input.set( + jump = true + ) val simulatedPlayer = SimulatedPlayer.fromClientPlayer(input) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/modes/SpeedGeneric.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/modes/SpeedGeneric.kt index 40cf37b3911..6d3691c8042 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/modes/SpeedGeneric.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/modes/SpeedGeneric.kt @@ -56,7 +56,7 @@ open class SpeedBHopBase(name: String, override val parent: ChoiceConfigurable<* return@handler } - event.jumping = true + event.jump = true } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/modes/blocksmc/SpeedBlocksMC.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/modes/blocksmc/SpeedBlocksMC.kt index f3fcd044fe3..d8073436465 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/modes/blocksmc/SpeedBlocksMC.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/modes/blocksmc/SpeedBlocksMC.kt @@ -150,7 +150,7 @@ class SpeedBlocksMC(override val parent: ChoiceConfigurable<*>) : Choice("Blocks @Suppress("unused") private val movementInputHandler = handler { event -> if (event.directionalInput.isMoving) { - event.jumping = true + event.jump = true } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/modes/sentinel/SpeedSentinelDamage.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/modes/sentinel/SpeedSentinelDamage.kt index 72c3251752e..f85811972df 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/modes/sentinel/SpeedSentinelDamage.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/modes/sentinel/SpeedSentinelDamage.kt @@ -114,7 +114,7 @@ class SpeedSentinelDamage(override val parent: ChoiceConfigurable<*>) : Choice(" @Suppress("unused") private val movementInputHandler = handler { event -> if (event.directionalInput.isMoving && hasBeenHurt) { - event.jumping = true + event.jump = true } } @@ -122,13 +122,13 @@ class SpeedSentinelDamage(override val parent: ChoiceConfigurable<*>) : Choice(" externalDamageAdjust = 0 hasBeenHurt = false enabledTime = System.currentTimeMillis() - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false, false)) network.sendPacket( PlayerMoveC2SPacket.PositionAndOnGround( player.x, player.y + 3.25, player.z, - false)) - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false)) - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, true)) + false, false)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, false, false)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, true, false)) } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/step/ModuleReverseStep.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/step/ModuleReverseStep.kt index a48fc145839..3615d429a97 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/step/ModuleReverseStep.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/step/ModuleReverseStep.kt @@ -111,7 +111,8 @@ object ModuleReverseStep : ClientModule("ReverseStep", Category.MOVEMENT) { if (simulateFalling) { simulationQueue += PlayerMoveC2SPacket.PositionAndOnGround( simulatePlayer.pos.x, - simulatePlayer.pos.y, simulatePlayer.pos.z, simulatePlayer.onGround + simulatePlayer.pos.y, simulatePlayer.pos.z, simulatePlayer.onGround, + simulatePlayer.horizontalCollision ) } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/step/ModuleStep.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/step/ModuleStep.kt index 7cb2549af8c..812198854ab 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/step/ModuleStep.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/step/ModuleStep.kt @@ -176,7 +176,7 @@ object ModuleStep : ClientModule("Step", Category.MOVEMENT) { @Suppress("unused") private val movementInputHandler = sequenceHandler { event -> if (player.canStep(1.0) && !stepping) { - event.jumping = true + event.jump = true stepCounter++ stepping = true @@ -223,7 +223,7 @@ object ModuleStep : ClientModule("Step", Category.MOVEMENT) { @Suppress("unused") private val movementInputHandler = sequenceHandler { event -> if (player.canStep(1.0) && !stepping) { - event.jumping = true + event.jump = true stepping = true Timer.requestTimerSpeed(baseTimer, Priority.IMPORTANT_FOR_USAGE_1, ModuleStep, 3) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAntiAFK.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAntiAFK.kt index 2fc6a07e740..f95a48b71ed 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAntiAFK.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAntiAFK.kt @@ -86,7 +86,7 @@ object ModuleAntiAFK : ClientModule("AntiAFK", Category.PLAYER) { when (Random.nextInt(0, 6)) { 0 -> { EventScheduler.schedule(ModuleScaffold) { - it.jumping = true + it.jump = true } } @@ -170,7 +170,7 @@ object ModuleAntiAFK : ClientModule("AntiAFK", Category.PLAYER) { if (jump && player.isOnGround) { EventScheduler.schedule(ModuleScaffold) { - it.jumping = true + it.jump = true } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAntiExploit.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAntiExploit.kt index 2a9824d4124..aef47ed54ce 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAntiExploit.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAntiExploit.kt @@ -32,7 +32,6 @@ import net.ccbluex.liquidbounce.utils.client.notification object ModuleAntiExploit : ClientModule("AntiExploit", Category.PLAYER) { val limitExplosionStrength by boolean("LimitExplosionStrength", true) - val limitExplosionRange by boolean("LimitExplosionRange", true) val cancelDemo by boolean("CancelDemo", true) val limitParticlesAmount by boolean("LimitParticlesAmount", true) val limitParticlesSpeed by boolean("LimitParticlesSpeed", true) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleEagle.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleEagle.kt index 68daea3143f..67ed1216c5e 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleEagle.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleEagle.kt @@ -47,11 +47,11 @@ object ModuleEagle : ClientModule("Eagle", Category.PLAYER, aliases = arrayOf("F val backwards by boolean("Backwards", false) fun shouldSneak(event: MovementInputEvent): Boolean = when { - !enabled || event.sneaking -> true + !enabled || event.sneak -> true holdingBlocks && !isValidBlock(player.mainHandStack) && !isValidBlock(player.offHandStack) -> false onGround && !player.isOnGround -> false player.pitch !in pitch -> false - sneak && !event.sneaking -> false + sneak && !event.sneak -> false left && !event.directionalInput.left -> false right && !event.directionalInput.right -> false forwards && !event.directionalInput.forwards -> false @@ -70,7 +70,7 @@ object ModuleEagle : ClientModule("Eagle", Category.PLAYER, aliases = arrayOf("F ) { event -> val shouldBeActive = !player.abilities.flying && Conditional.shouldSneak(event) - event.sneaking = shouldBeActive && player.isCloseToEdge(event.directionalInput, edgeDistance.toDouble()) + event.sneak = shouldBeActive && player.isCloseToEdge(event.directionalInput, edgeDistance.toDouble()) } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleSmartEat.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleSmartEat.kt index 16cffb5ac34..79b8722b76a 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleSmartEat.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleSmartEat.kt @@ -34,14 +34,14 @@ import net.ccbluex.liquidbounce.utils.item.foodComponent import net.ccbluex.liquidbounce.utils.item.getPotionEffects import net.ccbluex.liquidbounce.utils.sorting.ComparatorChain import net.minecraft.client.gui.DrawContext -import net.minecraft.client.option.KeyBinding +import net.minecraft.client.render.RenderLayer import net.minecraft.entity.effect.StatusEffects import net.minecraft.item.ItemStack import net.minecraft.item.Items -import net.minecraft.item.ToolItem +import net.minecraft.item.MiningToolItem +import net.minecraft.item.consume.UseAction import net.minecraft.util.ActionResult import net.minecraft.util.Identifier -import net.minecraft.util.UseAction import kotlin.math.absoluteValue /** @@ -119,7 +119,10 @@ object ModuleSmartEat : ClientModule("SmartEat", Category.PLAYER) { private object SilentOffhand : ToggleableConfigurable(this, "SilentOffhand", true) { private object RenderSlot : ToggleableConfigurable(this, "RenderSlot", true) { + private val offset by int("Offset", 40, 30..70) + + @Suppress("unused") val renderHandler = handler { renderEnvironmentForGUI { // MC-Rendering code for off-hand @@ -131,16 +134,19 @@ object ModuleSmartEat : ClientModule("SmartEat", Category.PLAYER) { val i: Int = scaledWidth / 2 val x = i - 91 - 26 - offset val y = scaledHeight - 16 - 3 - dc.drawItemInSlot(mc.textRenderer, currentFood.itemStack, x, y) + dc.drawStackOverlay(mc.textRenderer, currentFood.itemStack, x, y) dc.drawItem(currentFood.itemStack, x, y) dc.drawGuiTexture( + RenderLayer::getGuiTextured, HOTBAR_OFFHAND_LEFT_TEXTURE, i - 91 - 29 - offset, scaledHeight - 23, 29, 24 ) } } + } + @Suppress("unused") val InteractionHandler = handler { event -> if (!enabled) return@handler @@ -156,7 +162,7 @@ object ModuleSmartEat : ClientModule("SmartEat", Category.PLAYER) { } // Only use silent offhand if we have tools in hand. - if (player.mainHandStack.item !is ToolItem) { + if (player.mainHandStack.item !is MiningToolItem) { return@handler } @@ -167,6 +173,7 @@ object ModuleSmartEat : ClientModule("SmartEat", Category.PLAYER) { ) } + @Suppress("unused") val tickHandler = tickHandler { val useAction = player.activeItem.useAction @@ -217,11 +224,9 @@ object ModuleSmartEat : ClientModule("SmartEat", Category.PLAYER) { } - init { tree(SilentOffhand) tree(AutoEat) } - } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/invcleaner/ItemCategorization.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/invcleaner/ItemCategorization.kt index 465a8fcc013..ff43555e9e3 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/invcleaner/ItemCategorization.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/invcleaner/ItemCategorization.kt @@ -175,7 +175,7 @@ class ItemCategorization( is BowItem -> arrayOf(BowItemFacet(slot)) is CrossbowItem -> arrayOf(CrossbowItemFacet(slot)) is ArrowItem -> arrayOf(ArrowItemFacet(slot)) - is ToolItem -> arrayOf(ToolItemFacet(slot)) + is MiningToolItem -> arrayOf(MiningToolItemFacet(slot)) is FishingRodItem -> arrayOf(RodItemFacet(slot)) is ShieldItem -> arrayOf(ShieldItemFacet(slot)) is BlockItem -> { @@ -187,7 +187,7 @@ class ItemCategorization( arrayOf(ItemFacet(slot)) } } - is MilkBucketItem -> arrayOf(PrimitiveItemFacet(slot, ItemCategory(ItemType.BUCKET, 2))) + Items.MILK_BUCKET -> arrayOf(PrimitiveItemFacet(slot, ItemCategory(ItemType.BUCKET, 2))) is BucketItem -> { when (item.fluid) { is WaterFluid -> arrayOf(PrimitiveItemFacet(slot, ItemCategory(ItemType.BUCKET, 0))) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/invcleaner/items/ToolItemFacet.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/invcleaner/items/MiningToolItemFacet.kt similarity index 83% rename from src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/invcleaner/items/ToolItemFacet.kt rename to src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/invcleaner/items/MiningToolItemFacet.kt index 4376906cb38..83951b7a78e 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/invcleaner/items/ToolItemFacet.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/invcleaner/items/MiningToolItemFacet.kt @@ -20,12 +20,13 @@ package net.ccbluex.liquidbounce.features.module.modules.player.invcleaner.items import net.ccbluex.liquidbounce.features.module.modules.player.invcleaner.* import net.ccbluex.liquidbounce.utils.item.EnchantmentValueEstimator +import net.ccbluex.liquidbounce.utils.item.material import net.ccbluex.liquidbounce.utils.item.type import net.ccbluex.liquidbounce.utils.sorting.ComparatorChain import net.minecraft.enchantment.Enchantments -import net.minecraft.item.ToolItem +import net.minecraft.item.MiningToolItem -class ToolItemFacet(itemSlot: ItemSlot) : ItemFacet(itemSlot) { +class MiningToolItemFacet(itemSlot: ItemSlot) : ItemFacet(itemSlot) { companion object { val VALUE_ESTIMATOR = EnchantmentValueEstimator( @@ -34,8 +35,8 @@ class ToolItemFacet(itemSlot: ItemSlot) : ItemFacet(itemSlot) { EnchantmentValueEstimator.WeightedEnchantment(Enchantments.FORTUNE, 0.33f), ) private val COMPARATOR = - ComparatorChain( - compareBy { (it.itemStack.item as ToolItem).material.miningSpeedMultiplier }, + ComparatorChain( + compareBy { (it.itemStack.item as MiningToolItem).material().speed }, compareBy { VALUE_ESTIMATOR.estimateValue(it.itemStack) }, PREFER_BETTER_DURABILITY, PREFER_ITEMS_IN_HOTBAR, @@ -44,9 +45,9 @@ class ToolItemFacet(itemSlot: ItemSlot) : ItemFacet(itemSlot) { } override val category: ItemCategory - get() = ItemCategory(ItemType.TOOL, (this.itemStack.item as ToolItem).type) + get() = ItemCategory(ItemType.TOOL, (this.itemStack.item as MiningToolItem).type) override fun compareTo(other: ItemFacet): Int { - return COMPARATOR.compare(this, other as ToolItemFacet) + return COMPARATOR.compare(this, other as MiningToolItemFacet) } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/invcleaner/items/WeaponItemFacet.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/invcleaner/items/WeaponItemFacet.kt index 913ab5d0da8..898d790285e 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/invcleaner/items/WeaponItemFacet.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/invcleaner/items/WeaponItemFacet.kt @@ -25,9 +25,9 @@ import net.ccbluex.liquidbounce.utils.item.attackSpeed import net.ccbluex.liquidbounce.utils.item.getEnchantment import net.ccbluex.liquidbounce.utils.sorting.ComparatorChain import net.ccbluex.liquidbounce.utils.sorting.compareByCondition +import net.minecraft.component.DataComponentTypes import net.minecraft.enchantment.Enchantments import net.minecraft.item.SwordItem -import net.minecraft.item.ToolItem import kotlin.math.ceil import kotlin.math.pow @@ -58,7 +58,7 @@ open class WeaponItemFacet(itemSlot: ItemSlot) : ItemFacet(itemSlot) { compareBy { SECONDARY_VALUE_ESTIMATOR.estimateValue(it.itemStack) }, compareByCondition { it.itemStack.item is SwordItem }, PREFER_BETTER_DURABILITY, - compareBy { it.itemStack.item.enchantability }, + compareBy { it.itemStack.get(DataComponentTypes.ENCHANTABLE)?.value ?: 0 }, PREFER_ITEMS_IN_HOTBAR, STABILIZE_COMPARISON, ) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/ModuleNoFall.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/ModuleNoFall.kt index 71f3f0ce0ec..993e696724f 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/ModuleNoFall.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/ModuleNoFall.kt @@ -69,7 +69,7 @@ object ModuleNoFall : ClientModule("NoFall", Category.PLAYER) { } // With Elytra - we don't want to reduce fall damage. - if (!duringFallFlying && player.isFallFlying && player.isInPose(EntityPose.FALL_FLYING)) { + if (!duringFallFlying && player.isGliding && player.isInPose(EntityPose.GLIDING)) { return false } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallBlink.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallBlink.kt index 245c6303073..daa789947f2 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallBlink.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallBlink.kt @@ -88,7 +88,7 @@ internal object NoFallBlink : Choice("Blink") { val simulatedPlayer = SimulatedPlayer.fromClientPlayer( SimulatedPlayer.SimulatedPlayerInput( event.directionalInput, - event.jumping, + event.jump, player.isSprinting, true )) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallHoplite.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallHoplite.kt index 6d5f79533a0..3dec367323f 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallHoplite.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallHoplite.kt @@ -26,7 +26,7 @@ internal object NoFallHoplite : Choice("Hoplite") { // Goes up a tiny bit to stop fall damage on 1.17+ servers. // Abuses Grim 1.17 extra packets to not flag timer. network.sendPacket(PlayerMoveC2SPacket.Full(player.x, player.y + 1.0E-9, player.z, - player.yaw, player.pitch, player.isOnGround)) + player.yaw, player.pitch, player.isOnGround, player.horizontalCollision)) player.onLanding() } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallSpartan524Flag.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallSpartan524Flag.kt index a7ef2a28196..c3be71e3144 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallSpartan524Flag.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallSpartan524Flag.kt @@ -37,7 +37,7 @@ internal object NoFallSpartan524Flag : Choice("Spartan524Flag") { val repeatable = tickHandler { if (player.fallDistance > 2f) { - network.sendPacket(PlayerMoveC2SPacket.OnGroundOnly(true)) + network.sendPacket(PlayerMoveC2SPacket.OnGroundOnly(true, player.horizontalCollision)) waitTicks(1) } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallVulcanTP.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallVulcanTP.kt index 38b199bd632..7eda40b4d3e 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallVulcanTP.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/nofall/modes/NoFallVulcanTP.kt @@ -24,6 +24,7 @@ import net.ccbluex.liquidbounce.event.events.PacketEvent import net.ccbluex.liquidbounce.event.handler import net.ccbluex.liquidbounce.features.module.modules.player.nofall.ModuleNoFall import net.ccbluex.liquidbounce.utils.entity.isFallingToVoid +import net.ccbluex.liquidbounce.utils.entity.set import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket /** @@ -50,7 +51,9 @@ internal object NoFallVulcanTP : Choice("VulcanTP288") { // Extreme high fall velocity player.setVelocity(0.0, -99.887575, 0.0) - player.input.sneaking = true + player.input.set( + sneak = true + ) } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/offhand/Totem.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/offhand/Totem.kt index 5a5c16336f8..ae83cbf15ec 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/offhand/Totem.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/offhand/Totem.kt @@ -96,7 +96,7 @@ class Totem : ToggleableConfigurable(ModuleOffhand, "Totem", true) { return 0f } - if (ignoreElytra && player.isFallFlying && player.isInPose(EntityPose.FALL_FLYING)) { + if (ignoreElytra && player.isGliding && player.isInPose(EntityPose.GLIDING)) { return 0f } @@ -221,7 +221,7 @@ class Totem : ToggleableConfigurable(ModuleOffhand, "Totem", true) { } maxDamage = maxDamage.coerceAtLeast( - player.getDamageFromExplosion(pos.toVec3d(), null, 5f, 10f, 100f, exclude) + player.getDamageFromExplosion(pos.toVec3d(), 5f, 10f, 100f, exclude) ) if (maxDamage >= allowedDamage) { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleBreadcrumbs.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleBreadcrumbs.kt index 6e65f45880f..2e1872c1dfb 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleBreadcrumbs.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleBreadcrumbs.kt @@ -33,8 +33,12 @@ import net.ccbluex.liquidbounce.render.renderEnvironmentForWorld import net.ccbluex.liquidbounce.render.utils.rainbow import net.ccbluex.liquidbounce.utils.kotlin.component1 import net.ccbluex.liquidbounce.utils.kotlin.component2 -import net.minecraft.client.render.* +import net.minecraft.client.gl.ShaderProgramKeys +import net.minecraft.client.render.BufferBuilder +import net.minecraft.client.render.BufferRenderer +import net.minecraft.client.render.Camera import net.minecraft.client.render.VertexFormat.DrawMode +import net.minecraft.client.render.VertexFormats import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.Entity import org.joml.Matrix4f @@ -100,7 +104,7 @@ object ModuleBreadcrumbs : ClientModule("Breadcrumbs", Category.RENDER, aliases VertexFormats.POSITION_COLOR) val renderData = RenderData(matrix, buffer, colorF, lines) - RenderSystem.setShader { GameRenderer.getPositionColorProgram() } + RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR) trails.forEach { (entity, trail) -> trail.verifyAndRenderTrail(renderData, camera, entity, time) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleCustomAmbience.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleCustomAmbience.kt index 194c8876601..122633ec203 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleCustomAmbience.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleCustomAmbience.kt @@ -18,18 +18,23 @@ */ package net.ccbluex.liquidbounce.features.module.modules.render -import com.mojang.blaze3d.systems.RenderSystem +import com.mojang.blaze3d.platform.GlStateManager import net.ccbluex.liquidbounce.config.types.NamedChoice import net.ccbluex.liquidbounce.config.types.ToggleableConfigurable import net.ccbluex.liquidbounce.features.module.Category import net.ccbluex.liquidbounce.features.module.ClientModule import net.ccbluex.liquidbounce.injection.mixins.minecraft.render.MixinBackgroundRenderer import net.ccbluex.liquidbounce.render.engine.Color4b +import net.ccbluex.liquidbounce.render.shader.shaders.BlendShader +import net.ccbluex.liquidbounce.render.shader.shaders.BlendShaderData import net.minecraft.block.enums.CameraSubmersionType +import net.minecraft.client.gl.Framebuffer +import net.minecraft.client.gl.SimpleFramebuffer import net.minecraft.client.render.Camera +import net.minecraft.client.render.Fog import net.minecraft.client.render.FogShape import net.minecraft.util.math.MathHelper -import org.spongepowered.asm.mixin.injection.invoke.arg.Args +import org.lwjgl.opengl.GL13 /** * CustomAmbience module @@ -46,7 +51,7 @@ object ModuleCustomAmbience : ClientModule("CustomAmbience", Category.RENDER) { val layers by int("Layers", 3, 1..14) } - object Fog : ToggleableConfigurable(this, "Fog", true) { + object FogConfigurable : ToggleableConfigurable(this, "Fog", true) { private val color by color("Color", Color4b(47, 128, 255, 201)) private val backgroundColor by color("BackgroundColor", Color4b(47, 128, 255, 201)) @@ -57,42 +62,35 @@ object ModuleCustomAmbience : ClientModule("CustomAmbience", Category.RENDER) { /** * [MixinBackgroundRenderer] */ - fun modifyFog(camera: Camera, viewDistance: Float) { + fun modifyFog(camera: Camera, viewDistance: Float, fog: Fog): Fog { if (!this.running) { - return + return fog } - RenderSystem.setShaderFogStart(MathHelper.clamp(fogStart, -8f, viewDistance)) - RenderSystem.setShaderFogEnd(MathHelper.clamp(fogStart + density, 0f, viewDistance)) + val start = MathHelper.clamp(fogStart, -8f, viewDistance) + val end = MathHelper.clamp(fogStart + density, 0f, viewDistance) + var shape = fog.shape val type = camera.submersionType - if (type != CameraSubmersionType.NONE) { - return + if (type == CameraSubmersionType.NONE) { + shape = fogShape.fogShape } - RenderSystem.setShaderFogShape(fogShape.fogShape) + return Fog(start, end, shape, color.r / 255f, color.g / 255f, color.b / 255f, color.a / 255f) } - fun modifyFogColor() { - if (!this.running) { - return - } - - val color = color - RenderSystem.setShaderFogColor( - color.r / 255f, - color.g / 255f, - color.b / 255f, - color.a / 255f - ) - } - - fun modifySetColorArgs(args: Args) { + fun modifyClearColor(): Boolean { if (!this.running || backgroundColor.a == 0) { - return + return false } - args.setAll(backgroundColor.r / 255f, backgroundColor.g / 255f, backgroundColor.b / 255f, 0f) + GlStateManager._clearColor( + backgroundColor.r / 255f, + backgroundColor.g / 255f, + backgroundColor.b / 255f, + backgroundColor.a / 255f + ) + return true } @Suppress("unused") @@ -103,35 +101,39 @@ object ModuleCustomAmbience : ClientModule("CustomAmbience", Category.RENDER) { } - object CustomLightColor : ToggleableConfigurable(this, "CustomLightColor", true) { - - private val lightColor by color("LightColor", Color4b(70, 119, 255, 255)) + object CustomLightColor : + ToggleableConfigurable(this, "CustomLightColor", true), AutoCloseable { - fun blendWithLightColor(srcColor: Int): Int { - if (lightColor.a == 255) { - return lightColor.toABGR() - } else if (lightColor.a == 0) { - return srcColor - } + private val lightColor by color("LightColor", Color4b(70, 119, 255, 255)).onChanged { + update() + } - val srcB = (srcColor shr 16) and 0xFF - val srcG = (srcColor shr 8) and 0xFF - val srcR = srcColor and 0xFF + val framebuffer: Framebuffer = SimpleFramebuffer(16, 16, false) - val dstAlpha = lightColor.a / 255f + init { + framebuffer.setTexFilter(9729) + framebuffer.setClearColor(1f, 1f, 1f, 1f) + } - val outB = ((srcB * (1 - dstAlpha)) + (lightColor.b * dstAlpha)).toInt() - val outG = ((srcG * (1 - dstAlpha)) + (lightColor.g * dstAlpha)).toInt() - val outR = ((srcR * (1 - dstAlpha)) + (lightColor.r * dstAlpha)).toInt() + fun update() { + framebuffer.clear() + framebuffer.beginWrite(true) + GlStateManager._activeTexture(GL13.GL_TEXTURE0) + GlStateManager._bindTexture(mc.gameRenderer.lightmapTextureManager.lightmapFramebuffer.colorAttachment) + BlendShaderData.color = lightColor + BlendShader.blit() + framebuffer.endWrite() + } - return (255 shl 24) or (outB shl 16) or (outG shl 8) or outR + override fun close() { + framebuffer.delete() } } init { tree(Precipitation) - tree(Fog) + tree(FogConfigurable) tree(CustomLightColor) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt index 4dbc69005f6..76f3d507d50 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleFreeCam.kt @@ -92,8 +92,8 @@ object ModuleFreeCam : ClientModule("FreeCam", Category.RENDER, disableOnQuit = val inputHandler = handler { event -> val speed = this.speed.toDouble() val yAxisMovement = when { - event.jumping -> 1.0f - event.sneaking -> -1.0f + event.jump -> 1.0f + event.sneak -> -1.0f else -> 0.0f } val directionYaw = getMovementDirectionOfInput(player.yaw, event.directionalInput) @@ -104,8 +104,8 @@ object ModuleFreeCam : ClientModule("FreeCam", Category.RENDER, disableOnQuit = updatePosition(velocity) event.directionalInput = DirectionalInput.NONE - event.jumping = false - event.sneaking = false + event.jump = false + event.sneak = false } fun applyCameraPosition(entity: Entity, tickDelta: Float) { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleXRay.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleXRay.kt index bd936214b79..ab4ed1180d1 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleXRay.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleXRay.kt @@ -194,6 +194,14 @@ object ModuleXRay : ClientModule("XRay", Category.RENDER) { else -> true } + fun shouldRender(state: BlockState, otherState: BlockState, side: Direction) = when { + state.block !in blocks -> false + + exposedOnly -> !state.isSideInvisible(otherState, side) + + else -> true + } + /** * Resets the block list to the default values */ diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/ModuleSurround.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/ModuleSurround.kt index 4a7310efdff..e9c10cd982b 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/ModuleSurround.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/ModuleSurround.kt @@ -387,7 +387,8 @@ object ModuleSurround : ClientModule("Surround", Category.WORLD, disableOnQuit = if (rotationMode.send) { val rotation = placementTarget.rotation.normalize() network.connection!!.send( - PlayerMoveC2SPacket.LookAndOnGround(rotation.yaw, rotation.pitch, player.isOnGround), + PlayerMoveC2SPacket.LookAndOnGround(rotation.yaw, rotation.pitch, player.isOnGround, + player.horizontalCollision), null ) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/autofarm/AutoFarmAutoWalk.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/autofarm/AutoFarmAutoWalk.kt index 2976e3d4f86..3d11b50f052 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/autofarm/AutoFarmAutoWalk.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/autofarm/AutoFarmAutoWalk.kt @@ -133,12 +133,12 @@ object AutoFarmAutoWalk : ToggleableConfigurable(ModuleAutoFarm, "AutoWalk", fal // We want to swim up in water, so we don't drown and can move onwards if (player.isTouchingWater) { - event.jumping = true + event.jump = true } // Auto jump if (autoJump && player.horizontalCollision && walkTarget!!.y > player.y) { - event.jumping = true + event.jump = true } } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/fucker/IsSelfBed.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/fucker/IsSelfBed.kt index 183d26159c5..aeac9b6ce54 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/fucker/IsSelfBed.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/fucker/IsSelfBed.kt @@ -60,7 +60,8 @@ class IsSelfBedSpawnLocationChoice(parent: ChoiceConfigurable<*>) : IsSelfBedCho val packet = it.packet if (packet is PlayerPositionLookS2CPacket) { - val packetPos = Vec3d(packet.x, packet.y, packet.z) + val pos = packet.change.position + val packetPos = Vec3d(pos.x, pos.y, pos.z) val dist = player.pos.distanceTo(packetPos) if (dist > 16.0) { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/packetmine/ModulePacketMine.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/packetmine/ModulePacketMine.kt index 3d3170a1485..518c72e02ec 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/packetmine/ModulePacketMine.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/packetmine/ModulePacketMine.kt @@ -405,7 +405,7 @@ object ModulePacketMine : ClientModule("PacketMine", Category.WORLD) { val enchantmentLevel = stack.getEnchantment(Enchantments.EFFICIENCY) if (speed > 1f && enchantmentLevel != 0) { /** - * See: [EntityAttributes.PLAYER_MINING_EFFICIENCY] + * See: [EntityAttributes.MINING_EFFICIENCY] */ val enchantmentAddition = enchantmentLevel.sq() + 1f speed += enchantmentAddition.coerceIn(0f..1024f) @@ -427,9 +427,9 @@ object ModulePacketMine : ClientModule("PacketMine", Category.WORLD) { speed *= miningFatigueMultiplier } - speed *= player.getAttributeValue(EntityAttributes.PLAYER_BLOCK_BREAK_SPEED).toFloat() + speed *= player.getAttributeValue(EntityAttributes.BLOCK_BREAK_SPEED).toFloat() if (player.isSubmergedIn(FluidTags.WATER)) { - speed *= player.getAttributeInstance(EntityAttributes.PLAYER_SUBMERGED_MINING_SPEED)!!.value.toFloat() + speed *= player.getAttributeInstance(EntityAttributes.SUBMERGED_MINING_SPEED)!!.value.toFloat() } if (!player.isOnGround) { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/ModuleScaffold.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/ModuleScaffold.kt index 35c0f164ea8..7b0c849d203 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/ModuleScaffold.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/ModuleScaffold.kt @@ -155,7 +155,7 @@ object ModuleScaffold : ClientModule("Scaffold", Category.WORLD) { } val isTowering: Boolean - get() = towerMode.choices.indexOf(towerMode.activeChoice) != 0 && player.input.jumping + get() = towerMode.choices.indexOf(towerMode.activeChoice) != 0 && player.input.playerInput.jump // SafeWalk feature - uses the SafeWalk module as a base @Suppress("unused") @@ -357,11 +357,11 @@ object ModuleScaffold : ClientModule("Scaffold", Category.WORLD) { ) if (requiresJump) { - it.movementEvent.jumping = true + it.movementEvent.jump = true } if (requiresSneak > 0) { - it.movementEvent.sneaking = true + it.movementEvent.sneak = true forceSneak = requiresSneak } } @@ -394,7 +394,7 @@ object ModuleScaffold : ClientModule("Scaffold", Category.WORLD) { @Suppress("unused") private val movementInputHandler = handler(priority = EventPriorityConvention.SAFETY_FEATURE) { if (forceSneak > 0) { - it.sneaking = true + it.sneak = true forceSneak-- } } @@ -481,7 +481,8 @@ object ModuleScaffold : ClientModule("Scaffold", Category.WORLD) { player.x, player.y, player.z, currentRotation.yaw, currentRotation.pitch, - player.isOnGround + player.isOnGround, + player.horizontalCollision ) ) } @@ -512,7 +513,8 @@ object ModuleScaffold : ClientModule("Scaffold", Category.WORLD) { if (rotationTiming == ON_TICK && RotationManager.serverRotation != player.rotation) { network.sendPacket( Full( - player.x, player.y, player.z, player.withFixedYaw(currentRotation), player.pitch, player.isOnGround + player.x, player.y, player.z, player.withFixedYaw(currentRotation), player.pitch, player.isOnGround, + player.horizontalCollision ) ) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/ScaffoldBreezilyTechnique.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/ScaffoldBreezilyTechnique.kt index 3347fc7c12e..d4e51e662c7 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/ScaffoldBreezilyTechnique.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/ScaffoldBreezilyTechnique.kt @@ -33,7 +33,6 @@ import net.ccbluex.liquidbounce.utils.kotlin.random import net.ccbluex.liquidbounce.utils.math.geometry.Line import net.ccbluex.liquidbounce.utils.math.toBlockPos import net.ccbluex.liquidbounce.utils.movement.DirectionalInput -import net.minecraft.block.Blocks import net.minecraft.entity.EntityPose import net.minecraft.item.ItemStack import net.minecraft.util.math.Direction @@ -86,7 +85,7 @@ object ScaffoldBreezilyTechnique : ScaffoldTechnique("Breezily") { val ma = 1 - currentEdgeDistanceRandom var currentSideways = 0f - when (Direction.fromRotation(player.yaw.toDouble())) { + when (Direction.fromHorizontalDegrees(player.yaw.toDouble())) { Direction.SOUTH -> { if (modX > ma) currentSideways = 1f if (modX < currentEdgeDistanceRandom) currentSideways = -1f diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/ScaffoldGodBridgeTechnique.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/ScaffoldGodBridgeTechnique.kt index bb7e58d7882..4b2df0fa746 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/ScaffoldGodBridgeTechnique.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/ScaffoldGodBridgeTechnique.kt @@ -147,7 +147,8 @@ object ScaffoldGodBridgeTechnique : ScaffoldTechnique("GodBridge"), ScaffoldLedg isOnRightSide = floor(player.x + cos(movingYaw.toRadians()) * 0.5) != floor(player.x) || floor(player.z + sin(movingYaw.toRadians()) * 0.5) != floor(player.z) - val posInDirection = player.pos.offset(Direction.fromRotation(movingYaw.toDouble()), 0.6).toBlockPos() + val posInDirection = player.pos.offset(Direction.fromHorizontalDegrees(movingYaw.toDouble()), 0.6) + .toBlockPos() val isLeaningOffBlock = player.blockPos.down().getState()?.isAir == true val nextBlockIsAir = posInDirection.down().getState()?.isAir == true diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldDownFeature.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldDownFeature.kt index 520a53ba4fd..31dee627704 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldDownFeature.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldDownFeature.kt @@ -30,7 +30,7 @@ object ScaffoldDownFeature : ToggleableConfigurable(ScaffoldNormalTechnique, "Do val handleMoveInput = handler(priority = EventPriorityConvention.OBJECTION_AGAINST_EVERYTHING) { if (shouldFallOffBlock()) { - it.sneaking = false + it.sneak = false } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldEagleFeature.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldEagleFeature.kt index 989dab5f820..dd3444ccb66 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldEagleFeature.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldEagleFeature.kt @@ -40,7 +40,7 @@ object ScaffoldEagleFeature : ToggleableConfigurable(ScaffoldNormalTechnique, "E val stateUpdateHandler = handler(priority = EventPriorityConvention.SAFETY_FEATURE) { if (mode == EagleMode.INPUT && shouldEagle(it.directionalInput)) { - it.sneaking = true + it.sneak = true } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldStabilizeMovementFeature.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldStabilizeMovementFeature.kt index 674143e370d..838edac5854 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldStabilizeMovementFeature.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldStabilizeMovementFeature.kt @@ -37,7 +37,7 @@ object ScaffoldStabilizeMovementFeature : ToggleableConfigurable(ScaffoldNormalT @Suppress("unused") val moveEvent = handler(priority = EventPriorityConvention.MODEL_STATE) { event -> // Prevents the stabilization from giving the player a boost before jumping that cannot be corrected mid-air. - if (event.jumping && player.isOnGround) { + if (event.jump && player.isOnGround) { return@handler } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldTellyFeature.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldTellyFeature.kt index ba4eae3121a..cc65cefb2f4 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldTellyFeature.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/techniques/normal/ScaffoldTellyFeature.kt @@ -28,7 +28,6 @@ import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.ModuleSca import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.techniques.ScaffoldNormalTechnique import net.ccbluex.liquidbounce.utils.aiming.RotationManager import net.ccbluex.liquidbounce.utils.entity.moving -import net.ccbluex.liquidbounce.utils.entity.rotation /** * Telly feature @@ -75,8 +74,8 @@ object ScaffoldTellyFeature : ToggleableConfigurable(ScaffoldNormalTechnique, "T val isStraight = RotationManager.currentRotation == null || straightTicks == 0 when (resetMode) { - Mode.REVERSE -> event.jumping = true - Mode.RESET -> if (isStraight && ticksUntilJump >= jumpTicks) event.jumping = true + Mode.REVERSE -> event.jump = true + Mode.RESET -> if (isStraight && ticksUntilJump >= jumpTicks) event.jump = true } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/integration/VirtualScreenType.kt b/src/main/kotlin/net/ccbluex/liquidbounce/integration/VirtualScreenType.kt index c8a4460db1f..21a76c3c1e1 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/integration/VirtualScreenType.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/integration/VirtualScreenType.kt @@ -87,7 +87,7 @@ enum class VirtualScreenType( CREATE_WORLD( "create_world", recognizer = { it is CreateWorldScreen }, - open = { CreateWorldScreen.create(mc, IntegrationListener.parent) } + open = { CreateWorldScreen.show(mc, IntegrationListener.parent) } ), OPTIONS( diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/integration/browser/BrowserDrawer.kt b/src/main/kotlin/net/ccbluex/liquidbounce/integration/browser/BrowserDrawer.kt index 52995398f6a..c8a4523173c 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/integration/browser/BrowserDrawer.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/integration/browser/BrowserDrawer.kt @@ -24,19 +24,49 @@ import net.ccbluex.liquidbounce.event.EventListener import net.ccbluex.liquidbounce.event.events.* import net.ccbluex.liquidbounce.event.handler import net.ccbluex.liquidbounce.integration.browser.supports.IBrowser +import net.ccbluex.liquidbounce.render.engine.UiRenderer import net.ccbluex.liquidbounce.utils.client.mc import net.ccbluex.liquidbounce.utils.kotlin.EventPriorityConvention -import net.minecraft.client.render.BufferRenderer.drawWithGlobalProgram -import net.minecraft.client.render.GameRenderer -import net.minecraft.client.render.Tessellator +import net.minecraft.client.gui.DrawContext +import net.minecraft.client.render.RenderLayer +import net.minecraft.client.render.RenderPhase import net.minecraft.client.render.VertexFormat import net.minecraft.client.render.VertexFormats +import net.minecraft.util.Identifier +import net.minecraft.util.TriState +import net.minecraft.util.Util +import java.util.function.Function class BrowserDrawer(val browser: () -> IBrowser?) : EventListener { private val tabs get() = browser()?.getTabs() ?: emptyList() + + private val browserTextureLayer: Function = Util.memoize { texture: Identifier -> + RenderLayer.of( + "browser_textured", + VertexFormats.POSITION_TEXTURE_COLOR, + VertexFormat.DrawMode.QUADS, + 786432, + RenderLayer.MultiPhaseParameters.builder() + .texture(RenderPhase.Texture(texture, TriState.FALSE, false)) + .program(RenderPhase.POSITION_TEXTURE_COLOR_PROGRAM) + .transparency(browserTransparency) + .depthTest(RenderPhase.LEQUAL_DEPTH_TEST) + .target(UiRenderer.OUTLINE_TARGET) + .build(false) + ) + } + + private val browserTransparency: RenderPhase.Transparency = RenderPhase.Transparency("browser_transparency", { + RenderSystem.enableBlend() + RenderSystem.blendFunc(GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA) + }, { + RenderSystem.disableBlend() + RenderSystem.defaultBlendFunc() + }) + @Suppress("unused") val preRenderHandler = handler { browser()?.drawGlobally() @@ -54,7 +84,7 @@ class BrowserDrawer(val browser: () -> IBrowser?) : EventListener { } @Suppress("unused") - val onScreenRender = handler { + val onScreenRender = handler(priority = EventPriorityConvention.READ_FINAL_STATE) { for (tab in tabs) { if (tab.drawn) { continue @@ -66,7 +96,7 @@ class BrowserDrawer(val browser: () -> IBrowser?) : EventListener { val w = tab.position.width.toFloat() / scaleFactor val h = tab.position.height.toFloat() / scaleFactor - renderTexture(x, y, w, h, tab.getTexture()) + renderTexture(it.context, tab.getTexture(), x, y, w, h) tab.drawn = true } } @@ -103,36 +133,22 @@ class BrowserDrawer(val browser: () -> IBrowser?) : EventListener { val w = tab.position.width.toFloat() / scaleFactor val h = tab.position.height.toFloat() / scaleFactor - renderTexture(x, y, w, h, tab.getTexture()) + renderTexture(it.context, tab.getTexture(), x, y, w, h) tab.drawn = true } } - private fun renderTexture(x: Float, y: Float, width: Float, height: Float, texture: Int) { - RenderSystem.disableDepthTest() - RenderSystem.enableBlend() - RenderSystem.blendFunc(GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA) - RenderSystem.setShader { GameRenderer.getPositionTexColorProgram() } - RenderSystem.setShaderTexture(0, texture) - val tessellator = Tessellator.getInstance() - val buffer = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR) - buffer.vertex(x, y + height, 0.0f) - .texture(0.0f, 1.0f) - .color(255, 255, 255, 255) - buffer.vertex(x + width, y + height, 0.0f) - .texture(1.0f, 1.0f) - .color(255, 255, 255, 255) - buffer.vertex(x + width, y, 0.0f) - .texture(1.0f, 0.0f) - .color(255, 255, 255, 255) - buffer.vertex(x, y, 0.0f) - .texture(0.0f, 0.0f) - .color(255, 255, 255, 255) - drawWithGlobalProgram(buffer.end()) - RenderSystem.setShaderTexture(0, 0) - RenderSystem.enableDepthTest() - RenderSystem.defaultBlendFunc() - RenderSystem.enableBlend() + @Suppress("LongParameterList") + private fun renderTexture( + context: DrawContext, + texture: Identifier, + x: Float, + y: Float, + width: Float, + height: Float + ) { + context.drawTexture(browserTextureLayer, texture, x.toInt(), y.toInt(), 0f, 0f, width.toInt(), + height.toInt(), width.toInt(), height.toInt()) } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/integration/browser/supports/tab/ITab.kt b/src/main/kotlin/net/ccbluex/liquidbounce/integration/browser/supports/tab/ITab.kt index d13549b888b..67b5a6702e6 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/integration/browser/supports/tab/ITab.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/integration/browser/supports/tab/ITab.kt @@ -18,6 +18,8 @@ */ package net.ccbluex.liquidbounce.integration.browser.supports.tab +import net.minecraft.util.Identifier + interface ITab { var position: TabPosition @@ -32,7 +34,7 @@ interface ITab { fun loadUrl(url: String) fun getUrl(): String fun closeTab() - fun getTexture(): Int + fun getTexture(): Identifier fun resize(width: Int, height: Int) fun preferOnTop(): ITab { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/integration/browser/supports/tab/JcefTab.kt b/src/main/kotlin/net/ccbluex/liquidbounce/integration/browser/supports/tab/JcefTab.kt index b8dfdcf8301..5cdda91de60 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/integration/browser/supports/tab/JcefTab.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/integration/browser/supports/tab/JcefTab.kt @@ -18,9 +18,12 @@ */ package net.ccbluex.liquidbounce.integration.browser.supports.tab +import net.ccbluex.liquidbounce.features.module.MinecraftShortcuts +import net.ccbluex.liquidbounce.integration.browser.supports.JcefBrowser import net.ccbluex.liquidbounce.mcef.MCEF import net.ccbluex.liquidbounce.mcef.MCEFBrowser -import net.ccbluex.liquidbounce.integration.browser.supports.JcefBrowser +import net.minecraft.client.texture.AbstractTexture +import net.minecraft.util.Identifier @Suppress("TooManyFunctions") class JcefTab( @@ -29,7 +32,7 @@ class JcefTab( position: TabPosition, frameRate: Int = 60, override val takesInput: () -> Boolean -) : ITab, InputAware { +) : ITab, InputAware, MinecraftShortcuts { override var position: TabPosition = position set(value) { @@ -53,9 +56,17 @@ class JcefTab( zoomLevel = 1.0 } + private val texture = Identifier.of("liquidbounce", "browser/tab/${mcefBrowser.hashCode()}") + override var drawn = false override var preferOnTop = false + init { + mc.textureManager.registerTexture(texture, object : AbstractTexture() { + override fun getGlId() = mcefBrowser.renderer.textureID + }) + } + override fun forceReload() { mcefBrowser.reloadIgnoreCache() } @@ -81,9 +92,10 @@ class JcefTab( override fun closeTab() { mcefBrowser.close() jcefBrowser.removeTab(this) + mc.textureManager.destroyTexture(texture) } - override fun getTexture() = mcefBrowser.renderer.textureID + override fun getTexture(): Identifier = texture override fun resize(width: Int, height: Int) { if (!position.fullScreen) { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/integration/interop/protocol/rest/v1/game/RegistryFunctions.kt b/src/main/kotlin/net/ccbluex/liquidbounce/integration/interop/protocol/rest/v1/game/RegistryFunctions.kt index 6cda3709552..30cc98d9eab 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/integration/interop/protocol/rest/v1/game/RegistryFunctions.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/integration/interop/protocol/rest/v1/game/RegistryFunctions.kt @@ -58,7 +58,7 @@ val ACCEPTED_ITEM_TAGS ItemTags.WALLS, ItemTags.ANVIL, ItemTags.RAILS, - ItemTags.FLOWERS, + ItemTags.SMALL_FLOWERS, ItemTags.SAPLINGS, ItemTags.LEAVES, ItemTags.TRAPDOORS, @@ -82,7 +82,7 @@ val ACCEPTED_ITEM_TAGS ItemTags.COALS, ItemTags.ARROWS, ItemTags.COMPASSES, - ItemTags.TRIM_TEMPLATES, + ItemTags.TRIM_MATERIALS, ItemTags.SWORDS, ItemTags.AXES, ItemTags.HOES, @@ -144,7 +144,7 @@ fun constructMap(registry: DefaultedRegistry, tagKeys: Array>): val map = hashMapOf() for (acceptedTag in tagKeys) { - val get = registry.getEntryList(acceptedTag).getOrNull() ?: continue + val get = registry.getOptional(acceptedTag).getOrNull() ?: continue get.forEach { val itemId = registry.getId(it.value()) @@ -169,7 +169,7 @@ fun getRegistries(requestObject: RequestObject) = httpOk(JsonObject().apply { val world = mc.world ?: return httpForbidden("No world") Registries.BLOCK.forEach { - val pickStack = it.getPickStack(world, BlockPos.ORIGIN, it.defaultState) + val pickStack = it.getPickStack(world, BlockPos.ORIGIN, it.defaultState, false) val id = Registries.BLOCK.getId(it) when (val item = pickStack.item) { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/integration/interop/protocol/rest/v1/game/TextureFunctions.kt b/src/main/kotlin/net/ccbluex/liquidbounce/integration/interop/protocol/rest/v1/game/TextureFunctions.kt index 272c86dd915..784a17f3559 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/integration/interop/protocol/rest/v1/game/TextureFunctions.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/integration/interop/protocol/rest/v1/game/TextureFunctions.kt @@ -28,7 +28,7 @@ import net.ccbluex.netty.http.model.RequestObject import net.ccbluex.netty.http.util.httpBadRequest import net.ccbluex.netty.http.util.httpFileStream import net.ccbluex.netty.http.util.httpInternalServerError -import net.minecraft.client.texture.PlayerSkinTexture +import net.minecraft.client.texture.NativeImageBackedTexture import net.minecraft.client.util.DefaultSkinHelper import net.minecraft.registry.Registries import net.minecraft.registry.RegistryKey @@ -36,6 +36,8 @@ import net.minecraft.registry.RegistryKeys import net.minecraft.util.Identifier import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream +import java.nio.channels.Channels +import java.nio.channels.WritableByteChannel import java.util.* import javax.imageio.ImageIO import kotlin.jvm.optionals.getOrNull @@ -80,7 +82,6 @@ fun getItemTexture(requestObject: RequestObject) = run { } // GET /api/v1/client/skin -@Suppress("UNUSED_PARAMETER") fun getSkin(requestObject: RequestObject) = run { val uuid = requestObject.queryParams["uuid"]?.let { UUID.fromString(it) } ?: return@run httpBadRequest("Missing UUID parameter") @@ -88,11 +89,14 @@ fun getSkin(requestObject: RequestObject) = run { ?: DefaultSkinHelper.getSkinTextures(uuid) val texture = mc.textureManager.getTexture(skinTextures.texture) - if (texture is PlayerSkinTexture) { - val cacheFile = texture.cacheFile - ?: return@run httpInternalServerError("Texture is not cached yet") + if (texture is NativeImageBackedTexture) { + val outputStream = ByteArrayOutputStream() + val channel: WritableByteChannel = Channels.newChannel(outputStream) + texture.image?.write(channel) ?: return@run httpInternalServerError("Texture is not cached yet") + + channel.close() - cacheFile.inputStream().use { + ByteArrayInputStream(outputStream.toByteArray()).use { httpFileStream(it) } } else { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/ThemeManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/ThemeManager.kt index d3cb822ad42..f2c9b92e226 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/ThemeManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/ThemeManager.kt @@ -44,9 +44,11 @@ import net.ccbluex.liquidbounce.utils.io.resourceToString import net.ccbluex.liquidbounce.utils.render.refreshRate import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ChatScreen +import net.minecraft.client.render.RenderLayer import net.minecraft.client.texture.NativeImage import net.minecraft.client.texture.NativeImageBackedTexture import net.minecraft.util.Identifier +import java.io.Closeable import java.io.File object ThemeManager : Configurable("theme") { @@ -73,6 +75,10 @@ object ThemeManager : Configurable("theme") { return } + if (field != defaultTheme) { + activeTheme.close() + } + field = value // Update components @@ -154,7 +160,18 @@ object ThemeManager : Configurable("theme") { val image = activeTheme.loadedBackgroundImage ?: defaultTheme.loadedBackgroundImage if (image != null) { - context.drawTexture(image, 0, 0, 0f, 0f, width, height, width, height) + context.drawTexture( + RenderLayer::getGuiTextured, + image, + 0, + 0, + 0f, + 0f, + width, + height, + width, + height + ) return true } @@ -163,8 +180,6 @@ object ThemeManager : Configurable("theme") { fun chooseTheme(name: String) { activeTheme = Theme(name) - - } fun themes() = themesFolder.listFiles()?.filter { it.isDirectory }?.mapNotNull { it.name } ?: emptyList() @@ -173,7 +188,7 @@ object ThemeManager : Configurable("theme") { } -class Theme(val name: String) { +class Theme(val name: String) : Closeable { private val folder = File(ThemeManager.themesFolder, name) @@ -231,7 +246,8 @@ class Theme(val name: String) { } val image = NativeImageBackedTexture(readBackgroundImage() ?: return false) - loadedBackgroundImage = mc.textureManager.registerDynamicTexture("liquidbounce-theme-bg-$name", image) + loadedBackgroundImage = Identifier.of("liquidbounce-theme-bg-$name") + mc.textureManager.registerTexture(loadedBackgroundImage, image) logger.info("Loaded background image for theme $name") return true } @@ -280,6 +296,10 @@ class Theme(val name: String) { return componentList } + override fun close() { + mc.textureManager.destroyTexture(loadedBackgroundImage) + } + companion object { fun defaults() = runCatching { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/component/types/minimap/ChunkRenderer.kt b/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/component/types/minimap/ChunkRenderer.kt index 018933bd870..aaadf8a6c16 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/component/types/minimap/ChunkRenderer.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/component/types/minimap/ChunkRenderer.kt @@ -82,7 +82,7 @@ object ChunkRenderer { textureAtlasManager.editChunk(ChunkPos(posToUpdate)) { texture, atlasPosition -> val (x, y) = atlasPosition.getPosOnAtlas(posToUpdate.x and 15, posToUpdate.z and 15) - texture.image!!.setColor(x, y, color) + texture.image!!.setColorArgb(x, y, color) } } } @@ -165,7 +165,7 @@ object ChunkRenderer { val color = getColor(offX or (x shl 4), offZ or (z shl 4)) - texture.image!!.setColor(texX, texY, color) + texture.image!!.setColorArgb(texX, texY, color) } } } @@ -178,7 +178,7 @@ object ChunkRenderer { val color = getColor(offX or otherPos.startX, offZ or otherPos.startZ) - texture.image!!.setColor(texX, texY, color) + texture.image!!.setColorArgb(texX, texY, color) } } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/component/types/minimap/MinimapComponent.kt b/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/component/types/minimap/MinimapComponent.kt index 2c438dfe696..b4ccaf3310a 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/component/types/minimap/MinimapComponent.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/component/types/minimap/MinimapComponent.kt @@ -26,6 +26,7 @@ import net.ccbluex.liquidbounce.event.events.OverlayRenderEvent import net.ccbluex.liquidbounce.event.handler import net.ccbluex.liquidbounce.features.misc.HideAppearance import net.ccbluex.liquidbounce.features.module.modules.render.ModuleESP +import net.ccbluex.liquidbounce.integration.theme.component.Component import net.ccbluex.liquidbounce.render.* import net.ccbluex.liquidbounce.render.engine.Color4b import net.ccbluex.liquidbounce.render.engine.Vec3 @@ -35,9 +36,8 @@ import net.ccbluex.liquidbounce.utils.entity.interpolateCurrentPosition import net.ccbluex.liquidbounce.utils.entity.interpolateCurrentRotation import net.ccbluex.liquidbounce.utils.kotlin.EventPriorityConvention import net.ccbluex.liquidbounce.utils.math.Vec2i -import net.ccbluex.liquidbounce.integration.theme.component.Component +import net.minecraft.client.gl.ShaderProgramKeys import net.minecraft.client.render.BufferBuilder -import net.minecraft.client.render.GameRenderer import net.minecraft.client.render.VertexFormat import net.minecraft.client.render.VertexFormats import net.minecraft.client.util.math.MatrixStack @@ -113,7 +113,7 @@ object MinimapComponent : Component("Minimap", true) { drawCustomMesh( VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR, - GameRenderer.getPositionTexColorProgram()!!, + ShaderProgramKeys.POSITION_TEX_COLOR, ) { matrix -> buildMinimapMesh(this, matrix, Vec2i(baseX, baseZ), chunksToRenderAround, viewDistance) } @@ -121,7 +121,7 @@ object MinimapComponent : Component("Minimap", true) { drawCustomMesh( VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR, - GameRenderer.getPositionColorProgram()!!, + ShaderProgramKeys.POSITION_COLOR, ) { matrix -> for (renderedEntity in ModuleESP.findRenderedEntities()) { drawEntityOnMinimap( diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/component/types/minimap/MinimapTextureAtlasManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/component/types/minimap/MinimapTextureAtlasManager.kt index 094bf3f8863..87407324b13 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/component/types/minimap/MinimapTextureAtlasManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/integration/theme/component/types/minimap/MinimapTextureAtlasManager.kt @@ -27,7 +27,6 @@ import net.minecraft.client.texture.NativeImage import net.minecraft.client.texture.NativeImageBackedTexture import net.minecraft.util.math.ChunkPos import java.util.concurrent.ArrayBlockingQueue -import java.util.concurrent.Semaphore import java.util.concurrent.locks.ReentrantReadWriteLock import kotlin.concurrent.read import kotlin.concurrent.write @@ -73,7 +72,7 @@ class MinimapTextureAtlasManager { for (y in 0..15) { val color = if ((x and 1) xor (y and 1) == 0) Color4b.BLACK.toARGB() else Color4b.WHITE.toARGB() - this.texture.image!!.setColor(x, y, color) + this.texture.image!!.setColorArgb(x, y, color) } } @@ -183,7 +182,7 @@ class MinimapTextureAtlasManager { dirtyAtlasPosition.baseXOnAtlas, dirtyAtlasPosition.baseYOnAtlas, 0, 0, 16, 16, - false, false + false ) } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/RenderBufferBuilder.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/RenderBufferBuilder.kt index 6dcc29cf2a6..f76307675f7 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/RenderBufferBuilder.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/RenderBufferBuilder.kt @@ -24,7 +24,8 @@ import com.mojang.blaze3d.systems.RenderSystem import net.ccbluex.liquidbounce.render.engine.Color4b import net.ccbluex.liquidbounce.render.engine.UV2f import net.ccbluex.liquidbounce.render.engine.Vec3 -import net.minecraft.client.gl.ShaderProgram +import net.minecraft.client.gl.ShaderProgramKey +import net.minecraft.client.gl.ShaderProgramKeys import net.minecraft.client.render.* import net.minecraft.client.render.VertexFormat.DrawMode import net.minecraft.util.math.Box @@ -106,7 +107,7 @@ class RenderBufferBuilder( fun draw() { val built = buffer.endNullable() ?: return - RenderSystem.setShader { vertexFormat.shaderProgram } + RenderSystem.setShader(vertexFormat.shaderProgram) BufferRenderer.drawWithGlobalProgram(built) tesselator.clear() @@ -354,26 +355,27 @@ fun RenderBufferBuilder.drawLine( sealed class VertexInputType { abstract val vertexFormat: VertexFormat - abstract val shaderProgram: ShaderProgram + abstract val shaderProgram: ShaderProgramKey object Pos : VertexInputType() { override val vertexFormat: VertexFormat get() = VertexFormats.POSITION - override val shaderProgram: ShaderProgram - get() = GameRenderer.getPositionProgram()!! + override val shaderProgram: ShaderProgramKey + get() = ShaderProgramKeys.POSITION } object PosColor : VertexInputType() { override val vertexFormat: VertexFormat get() = VertexFormats.POSITION_COLOR - override val shaderProgram: ShaderProgram - get() = GameRenderer.getPositionColorProgram()!! + override val shaderProgram: ShaderProgramKey + get() = ShaderProgramKeys.POSITION_COLOR } object PosTexColor : VertexInputType() { override val vertexFormat: VertexFormat get() = VertexFormats.POSITION_TEXTURE_COLOR - override val shaderProgram: ShaderProgram - get() = GameRenderer.getPositionTexColorProgram()!! + override val shaderProgram: ShaderProgramKey + get() = ShaderProgramKeys.POSITION_TEX_COLOR } + } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/RenderShortcuts.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/RenderShortcuts.kt index e65b555270e..50bf1f08e26 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/RenderShortcuts.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/RenderShortcuts.kt @@ -27,7 +27,8 @@ import net.ccbluex.liquidbounce.render.engine.Vec3 import net.ccbluex.liquidbounce.render.engine.font.FontRenderer import net.ccbluex.liquidbounce.render.engine.font.FontRendererBuffers import net.ccbluex.liquidbounce.utils.client.mc -import net.minecraft.client.gl.ShaderProgram +import net.minecraft.client.gl.ShaderProgramKey +import net.minecraft.client.gl.ShaderProgramKeys import net.minecraft.client.render.* import net.minecraft.client.render.VertexFormat.DrawMode import net.minecraft.client.util.math.MatrixStack @@ -119,7 +120,7 @@ inline fun renderEnvironmentForWorld(matrixStack: MatrixStack, draw: WorldRender } inline fun renderEnvironmentForGUI(matrixStack: MatrixStack = MatrixStack(), draw: GUIRenderEnvironment.() -> Unit) { - RenderSystem.setShader { GameRenderer.getPositionTexColorProgram() } + RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR) RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f) RenderSystem.enableBlend() @@ -236,7 +237,7 @@ private fun RenderEnvironment.drawLines(lines: Array, mode: DrawMode = // Begin drawing lines with position format val buffer = tessellator.begin(mode, VertexFormats.POSITION) // Set the shader to the position program - RenderSystem.setShader { GameRenderer.getPositionProgram() } + RenderSystem.setShader(ShaderProgramKeys.POSITION) // Draw the vertices of the box with(buffer) { @@ -256,7 +257,7 @@ fun RenderEnvironment.drawTextureQuad(pos1: Vec3d, pos2: Vec3d) { val tessellator = RenderSystem.renderThreadTesselator() // Begin drawing lines with position format val buffer = tessellator.begin(DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR) - RenderSystem.setShader { GameRenderer.getPositionTexColorProgram() } + RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR) val matrix = matrixStack.peek().positionMatrix @@ -287,13 +288,13 @@ fun RenderEnvironment.drawTextureQuad(pos1: Vec3d, pos2: Vec3d) { inline fun RenderEnvironment.drawCustomMesh( drawMode: DrawMode, vertexFormat: VertexFormat, - shader: ShaderProgram, + shader: ShaderProgramKey, drawer: BufferBuilder.(Matrix4f) -> Unit ) { val tessellator = RenderSystem.renderThreadTesselator() val buffer = tessellator.begin(drawMode, vertexFormat) - RenderSystem.setShader { shader } + RenderSystem.setShader(shader) val matrix = matrixStack.peek().positionMatrix @@ -313,7 +314,7 @@ fun RenderEnvironment.drawQuad(pos1: Vec3, pos2: Vec3) { // Begin drawing lines with position format val buffer = tessellator.begin(DrawMode.QUADS, VertexFormats.POSITION) - RenderSystem.setShader { GameRenderer.getPositionProgram() } + RenderSystem.setShader(ShaderProgramKeys.POSITION) val matrix = matrixStack.peek().positionMatrix @@ -334,7 +335,7 @@ fun RenderEnvironment.drawQuadOutlines(pos1: Vec3, pos2: Vec3) { // Begin drawing lines with position format val buffer = tessellator.begin(DrawMode.DEBUG_LINES, VertexFormats.POSITION) - RenderSystem.setShader { GameRenderer.getPositionProgram() } + RenderSystem.setShader(ShaderProgramKeys.POSITION) val matrix = matrixStack.peek().positionMatrix @@ -362,7 +363,7 @@ fun RenderEnvironment.drawTriangle(p1: Vec3, p2: Vec3, p3: Vec3) { // Begin drawing lines with position format val bufferBuilder = tessellator.begin(DrawMode.TRIANGLES, VertexFormats.POSITION) - RenderSystem.setShader { GameRenderer.getPositionProgram() } + RenderSystem.setShader(ShaderProgramKeys.POSITION) val matrix = matrixStack.peek().positionMatrix @@ -401,7 +402,7 @@ fun RenderEnvironment.drawSideBox(box: Box, side: Direction, onlyOutline: Boolea ) // Set the shader to the position program - RenderSystem.setShader { GameRenderer.getPositionProgram() } + RenderSystem.setShader(ShaderProgramKeys.POSITION) // Draw the vertices of the box with(buffer) { @@ -472,7 +473,7 @@ fun RenderEnvironment.drawGradientQuad(vertices: List, colors: List @@ -515,7 +516,7 @@ fun RenderEnvironment.drawGradientCircle( val buffer = tessellator.begin(DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR) // Set the shader to the position and color program - RenderSystem.setShader { GameRenderer.getPositionColorProgram() } + RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR) with(buffer) { for (p in circlePoints) { @@ -544,7 +545,7 @@ fun RenderEnvironment.drawCircleOutline(radius: Float, color4b: Color4b) { val buffer = tessellator.begin(DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR) // Set the shader to the position and color program - RenderSystem.setShader { GameRenderer.getPositionColorProgram() } + RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR) with(buffer) { for (p in circlePoints) { @@ -570,7 +571,7 @@ fun RenderEnvironment.drawOutlinedBox(box: Box) { val buffer = tessellator.begin(DrawMode.DEBUG_LINES, VertexFormats.POSITION) // Set the shader to the position program - RenderSystem.setShader { GameRenderer.getPositionProgram() } + RenderSystem.setShader(ShaderProgramKeys.POSITION) // Draw the vertices of the box with(buffer) { @@ -623,7 +624,7 @@ fun RenderEnvironment.drawSolidBox(box: Box) { val buffer = tessellator.begin(DrawMode.QUADS, VertexFormats.POSITION) // Set the shader to the position program - RenderSystem.setShader { GameRenderer.getPositionProgram() } + RenderSystem.setShader(ShaderProgramKeys.POSITION) // Begin drawing quads with position format diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/MinecraftFramebufferShader.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/MinecraftFramebufferShader.kt deleted file mode 100644 index 7d25f4e0211..00000000000 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/MinecraftFramebufferShader.kt +++ /dev/null @@ -1,114 +0,0 @@ -/* - * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) - * - * Copyright (c) 2015 - 2024 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 . - */ -package net.ccbluex.liquidbounce.render.engine - -import net.ccbluex.liquidbounce.utils.client.mc -import net.minecraft.client.MinecraftClient -import net.minecraft.client.gl.Framebuffer -import net.minecraft.client.gl.GlUniform -import net.minecraft.client.gl.PostEffectProcessor -import net.minecraft.client.render.OutlineVertexConsumerProvider -import net.minecraft.util.Identifier - -abstract class MinecraftFramebufferShader(private val shaderName: String) { - var framebuffer: Framebuffer? = null - var vertexConsumerProvider: OutlineVertexConsumerProvider? = null - - var isDirty = false - private set - - private var postEffectProcessor: PostEffectProcessor? = null - - val isReady: Boolean - get() = framebuffer != null && vertexConsumerProvider != null && postEffectProcessor != null - - fun load() { - val identifier = Identifier.of("liquidbounce", "shaders/post/$shaderName.json") - - val outlinesShader = PostEffectProcessor( - mc.textureManager, - mc.resourceManager, - mc.framebuffer, - identifier - ) - - outlinesShader.setupDimensions(mc.window.framebufferWidth, mc.window.framebufferHeight) - - framebuffer = outlinesShader.getSecondaryTarget("final") - vertexConsumerProvider = OutlineVertexConsumerProvider(mc.bufferBuilders.entityVertexConsumers) - - this.postEffectProcessor = outlinesShader - } - - fun close() { - postEffectProcessor?.close() - this.postEffectProcessor = null - } - - protected fun beginInternal() { - // Clear the buffer if it is dirty - if (this.isDirty) { - assureLoaded(framebuffer).clear(MinecraftClient.IS_SYSTEM_MAC) - - this.isDirty = false - } - - mc.framebuffer.beginWrite(false) - } - - fun end(tickDelta: Float) { - // Render the framebuffer if something was rendered to it - if (this.isDirty) { - val framebuffer = assureLoaded(framebuffer) - val originalFramebuffer = mc.worldRenderer.entityOutlinesFramebuffer - - mc.worldRenderer.entityOutlinesFramebuffer = framebuffer - vertexConsumerProvider?.draw() - mc.worldRenderer.entityOutlinesFramebuffer = originalFramebuffer - postEffectProcessor?.render(tickDelta) - } - - mc.framebuffer.beginWrite(false) - } - - fun setDirty() { - this.isDirty = true - } - - fun drawFramebuffer() { - assureLoaded(framebuffer).draw(mc.window.framebufferWidth, mc.window.framebufferHeight, false) - } - - fun onResized(width: Int, height: Int) { - this.postEffectProcessor?.setupDimensions(width, height) - } - - protected fun setUniform1f(name: String, value: Float) { - glUniform(name).set(value) - } - - private fun glUniform(name: String): GlUniform { - return (assureLoaded(this.postEffectProcessor).passes[0].program.getUniformByName(name) - ?: throw IllegalArgumentException("There is no uniform with the name $name")) - } - - private inline fun assureLoaded(t: T?): T = - t ?: error("${this.shaderName} is not loaded") - -} diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/UIRenderer.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/UiRenderer.kt similarity index 54% rename from src/main/kotlin/net/ccbluex/liquidbounce/render/engine/UIRenderer.kt rename to src/main/kotlin/net/ccbluex/liquidbounce/render/engine/UiRenderer.kt index 0d124db81fa..1e8de93b200 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/UIRenderer.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/UiRenderer.kt @@ -2,27 +2,40 @@ package net.ccbluex.liquidbounce.render.engine import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.systems.RenderSystem +import net.ccbluex.liquidbounce.common.GlobalFramebuffer import net.ccbluex.liquidbounce.event.EventManager.callEvent import net.ccbluex.liquidbounce.event.events.OverlayRenderEvent -import net.ccbluex.liquidbounce.features.module.modules.render.ModuleHud +import net.ccbluex.liquidbounce.features.module.MinecraftShortcuts +import net.ccbluex.liquidbounce.features.module.modules.render.ModuleHud.isBlurable import net.ccbluex.liquidbounce.render.ui.ItemImageAtlas import net.ccbluex.liquidbounce.utils.client.Chronometer -import net.ccbluex.liquidbounce.utils.client.mc -import net.minecraft.client.MinecraftClient import net.minecraft.client.gl.SimpleFramebuffer import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ChatScreen +import net.minecraft.client.render.DefaultFramebufferSet +import net.minecraft.client.render.RenderPhase +import net.minecraft.client.util.Pool +import net.minecraft.util.Identifier +import org.lwjgl.opengl.GL13 import kotlin.math.sin +object UiRenderer : MinecraftShortcuts { -object UIRenderer { + /** + * UI Blur Post-Effect Processor + * + * @author superblaubeere27 + */ + private val BLUR = Identifier.of("liquidbounce", "ui_blur") + private val pool = Pool(3) - private var isDrawingHudFramebuffer: Boolean = false + private var isDrawingHudFramebuffer = false - val overlayFramebuffer: SimpleFramebuffer by lazy { + private val overlayFramebuffer by lazy { val fb = SimpleFramebuffer( mc.window.framebufferWidth, - mc.window.framebufferHeight, true, MinecraftClient.IS_SYSTEM_MAC + mc.window.framebufferHeight, + true ) fb.setClearColor(0.0f, 0.0f, 0.0f, 0.0f) @@ -30,10 +43,16 @@ object UIRenderer { fb } + val OUTLINE_TARGET = RenderPhase.Target("overlay_target", { + if (isDrawingHudFramebuffer) { + overlayFramebuffer.beginWrite(true) + } + }, {}) + private val lastTimeScreenOpened = Chronometer() private var wasScreenOpen = false - fun easeFunction(x: Float): Float { + private fun easeFunction(x: Float): Float { return sin((x * Math.PI) / 2.0).toFloat() } @@ -53,18 +72,19 @@ object UIRenderer { } } - fun getBlurRadius(): Float { + private fun getBlurRadius(): Float { return (this.getBlurRadiusFactor() * 20.0F).coerceIn(5.0F..20.0F) } fun startUIOverlayDrawing(context: DrawContext, tickDelta: Float) { ItemImageAtlas.updateAtlas(context) - if (ModuleHud.isBlurable) { + if (isBlurable) { this.isDrawingHudFramebuffer = true - this.overlayFramebuffer.clear(true) + this.overlayFramebuffer.clear() this.overlayFramebuffer.beginWrite(true) + GlobalFramebuffer.push(overlayFramebuffer) } callEvent(OverlayRenderEvent(context, tickDelta)) @@ -77,26 +97,49 @@ object UIRenderer { this.isDrawingHudFramebuffer = false - RenderSystem.enableBlend() - RenderSystem.blendFunc(GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA) - + GlobalFramebuffer.pop() this.overlayFramebuffer.endWrite() - mc.framebuffer.beginWrite(true) - // Remember the previous projection matrix because the draw method changes it AND NEVER FUCKING CHANGES IT // BACK IN ORDER TO INTRODUCE HARD TO FUCKING FIND BUGS. Thanks Mojang :+1: val projectionMatrix = RenderSystem.getProjectionMatrix() - val vertexSorting = RenderSystem.getVertexSorting() + val vertexSorting = RenderSystem.getProjectionType() + + blur() + + RenderSystem.enableBlend() + RenderSystem.blendFunc(GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA) - this.overlayFramebuffer.draw(mc.window.framebufferWidth, mc.window.framebufferHeight, false) + this.overlayFramebuffer.drawInternal(mc.window.framebufferWidth, mc.window.framebufferHeight) RenderSystem.setProjectionMatrix(projectionMatrix, vertexSorting) RenderSystem.defaultBlendFunc() } + fun blur() { + RenderSystem.disableBlend() +// RenderSystem.disableDepthTest() +// RenderSystem.resetTextureMatrix() + + val overlayFramebuffer = overlayFramebuffer + + val postEffectProcessor = mc.shaderLoader.loadPostEffect(BLUR, DefaultFramebufferSet.MAIN_ONLY)!! + + val active = GlStateManager._getActiveTexture() + GlStateManager._activeTexture(GL13.GL_TEXTURE9) + GlStateManager._bindTexture(overlayFramebuffer.colorAttachment) + postEffectProcessor.passes.first().program.getUniform("Overlay")!!.set(9) + GlStateManager._activeTexture(active) + + postEffectProcessor.passes.first().program.getUniform("Radius")!!.set(getBlurRadius()) + + postEffectProcessor.render(mc.framebuffer, pool) + + mc.framebuffer.beginWrite(true) + } + fun setupDimensions(width: Int, height: Int) { - this.overlayFramebuffer.resize(width, height, true) + this.overlayFramebuffer.resize(width, height) } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/FontRenderer.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/FontRenderer.kt index 4f0c6dd84e6..adbc19e779e 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/FontRenderer.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/FontRenderer.kt @@ -19,7 +19,6 @@ package net.ccbluex.liquidbounce.render.engine.font import com.mojang.blaze3d.systems.RenderSystem -import net.ccbluex.liquidbounce.features.module.modules.misc.nameprotect.ModuleNameProtect import net.ccbluex.liquidbounce.features.module.modules.misc.nameprotect.sanitizeForeignInput import net.ccbluex.liquidbounce.render.* import net.ccbluex.liquidbounce.render.FontManager.DEFAULT_FONT_SIZE diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/GlyphPage.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/GlyphPage.kt index ff323461c75..8d31dbb6432 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/GlyphPage.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/GlyphPage.kt @@ -270,7 +270,7 @@ internal fun BufferedImage.toNativeImage(): NativeImage { // Fuck Minecraft native image for (x in 0 until this.width) { for (y in 0 until this.height) { - nativeImage.setColor(x, y, this.getRGB(x, y)) + nativeImage.setColorArgb(x, y, this.getRGB(x, y)) } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/StaticGlyphPage.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/StaticGlyphPage.kt index 9c64c8a7f0c..2f0bd212791 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/StaticGlyphPage.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/StaticGlyphPage.kt @@ -85,7 +85,7 @@ class StaticGlyphPage( val texture = NativeImageBackedTexture(nativeImage) texture.bindTexture() - texture.image!!.upload(0, 0, 0, 0, 0, nativeImage.width, nativeImage.height, true, false, true, false) + texture.image!!.upload(0, 0, 0, 0, 0, nativeImage.width, nativeImage.height, true) return StaticGlyphPage( texture, diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/dynamic/DynamicFontCacheManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/dynamic/DynamicFontCacheManager.kt index e51f3310f15..2408ca359f6 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/dynamic/DynamicFontCacheManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/dynamic/DynamicFontCacheManager.kt @@ -86,7 +86,7 @@ class DynamicFontCacheManager( bb.xMin.toInt(), bb.yMin.toInt(), 0, 0, width, height, - false, false + false ) } @@ -246,14 +246,14 @@ private data class GlyphIdentifier(val codepoint: Char, val font: Int) private const val MAX_CACHE_TIME_MS = 30 * 1000 -private const val UNCACHED = 0; -private const val CACHED = 1; -private const val BLOCKED = 2; +private const val UNCACHED = 0 +private const val CACHED = 1 +private const val BLOCKED = 2 private class CharCacheData( /** * Possible values: [UNCACHED], [CACHED] and [BLOCKED] */ var cacheState: AtomicInteger = AtomicInteger(UNCACHED), - val lastUsage: AtomicLong = AtomicLong(0L), + val lastUsage: AtomicLong = AtomicLong(0L) ) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/dynamic/DynamicGlyphPage.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/dynamic/DynamicGlyphPage.kt index 121c39fe394..70ebc0706a2 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/dynamic/DynamicGlyphPage.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/engine/font/dynamic/DynamicGlyphPage.kt @@ -1,11 +1,6 @@ package net.ccbluex.liquidbounce.render.engine.font.dynamic -import net.ccbluex.liquidbounce.render.engine.font.AtlasSliceHandle -import net.ccbluex.liquidbounce.render.engine.font.DynamicAtlasAllocator -import net.ccbluex.liquidbounce.render.engine.font.FontGlyph -import net.ccbluex.liquidbounce.render.engine.font.GlyphPage -import net.ccbluex.liquidbounce.render.engine.font.GlyphRenderInfo -import net.ccbluex.liquidbounce.render.engine.font.toNativeImage +import net.ccbluex.liquidbounce.render.engine.font.* import net.minecraft.client.texture.NativeImage import net.minecraft.client.texture.NativeImageBackedTexture import java.awt.Dimension @@ -115,7 +110,7 @@ class DynamicGlyphPage(val atlasSize: Dimension, fontHeight: Int) : GlyphPage() for (j in 0 until patchSize.height) { val color = fromImage.getRGB(fromLocation.x + i, fromLocation.y + j) - toImage.setColor(toLocation.x + i, toLocation.y + j, color) + toImage.setColorArgb(toLocation.x + i, toLocation.y + j, color) } } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/BlitShader.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/BlitShader.kt new file mode 100644 index 00000000000..9113f0ce1e0 --- /dev/null +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/BlitShader.kt @@ -0,0 +1,55 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ +package net.ccbluex.liquidbounce.render.shader + +import com.mojang.blaze3d.systems.RenderSystem +import net.minecraft.client.gl.GlUsage +import net.minecraft.client.gl.VertexBuffer +import net.minecraft.client.render.Tessellator +import net.minecraft.client.render.VertexFormat +import net.minecraft.client.render.VertexFormats + +open class BlitShader(vertex: String, fragment: String, uniforms: Array = emptyArray()) : + Shader(vertex, fragment, uniforms) { + + private var buffer = VertexBuffer(GlUsage.DYNAMIC_WRITE) + + init { + val builder = Tessellator.getInstance() + val bufferBuilder = builder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE) + bufferBuilder.vertex(-1f, -1f, 0f).texture(0f, 0f) + bufferBuilder.vertex(1f, -1f, 0f).texture(1f, 0f) + bufferBuilder.vertex(1f, 1f, 0f).texture(1f, 1f) + bufferBuilder.vertex(-1f, 1f, 0f).texture(0f, 1f) + buffer.bind() + buffer.upload(bufferBuilder.end()) + VertexBuffer.unbind() + } + + fun blit() { + RenderSystem.disableBlend() + use() + buffer.bind() + buffer.draw() + VertexBuffer.unbind() + stop() + RenderSystem.enableBlend() + } + +} diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/CanvasShader.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/CanvasShader.kt index 5ffb63bf32e..17f50915766 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/CanvasShader.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/CanvasShader.kt @@ -20,6 +20,7 @@ package net.ccbluex.liquidbounce.render.shader import net.ccbluex.liquidbounce.utils.client.mc import net.minecraft.client.gl.GlUniform +import net.minecraft.client.gl.GlUsage import net.minecraft.client.gl.VertexBuffer import net.minecraft.client.render.Tessellator import net.minecraft.client.render.VertexFormat @@ -32,10 +33,11 @@ import org.lwjgl.opengl.GL30 * Inspired from the GLSL Panorama Shader Mod * https://github.com/magistermaks/mod-glsl */ -class CanvasShader(vertex: String, fragment: String) : Shader(vertex, fragment) { +open class CanvasShader(vertex: String, fragment: String, uniforms: Array = emptyArray()) + : Shader(vertex, fragment, uniforms) { private var canvas = ScalableCanvas() - private var buffer = VertexBuffer(VertexBuffer.Usage.DYNAMIC) + private var buffer = VertexBuffer(GlUsage.DYNAMIC_WRITE) private val timeLocation: Int private val mouseLocation: Int @@ -73,10 +75,18 @@ class CanvasShader(vertex: String, fragment: String) : Shader(vertex, fragment) canvas.write() // update uniforms - GL30.glUniform1f(timeLocation, time) - time += (delta / 10f) - GL30.glUniform2f(mouseLocation, mouseX.toFloat(), mouseY.toFloat()) - GL30.glUniform2f(resolutionLocation, canvas.width().toFloat(), canvas.height().toFloat()) + if (timeLocation != -1) { + GL30.glUniform1f(timeLocation, time) + time += (delta / 10f) + } + + if (mouseLocation != -1) { + GL30.glUniform2f(mouseLocation, mouseX.toFloat(), mouseY.toFloat()) + } + + if (resolutionLocation != -1) { + GL30.glUniform2f(resolutionLocation, canvas.width().toFloat(), canvas.height().toFloat()) + } // draw buffer.bind() diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/FramebufferShader.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/FramebufferShader.kt index a149cbf9b80..9da1aac6a76 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/FramebufferShader.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/FramebufferShader.kt @@ -20,7 +20,9 @@ package net.ccbluex.liquidbounce.render.shader import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.systems.RenderSystem +import net.ccbluex.liquidbounce.common.GlobalFramebuffer import net.ccbluex.liquidbounce.features.module.MinecraftShortcuts +import net.minecraft.client.gl.GlUsage import net.minecraft.client.gl.SimpleFramebuffer import net.minecraft.client.gl.VertexBuffer import net.minecraft.client.render.Tessellator @@ -35,14 +37,14 @@ import java.io.Closeable */ open class FramebufferShader(vararg val shaders: Shader) : MinecraftShortcuts, Closeable { - private val framebuffers = mutableListOf() - private var buffer = VertexBuffer(VertexBuffer.Usage.DYNAMIC) + protected val framebuffers = mutableListOf() + protected var buffer = VertexBuffer(GlUsage.DYNAMIC_WRITE) init { val width = mc.window.framebufferWidth val height = mc.window.framebufferHeight shaders.forEach { _ -> - val framebuffer = SimpleFramebuffer(width, height, false, false) + val framebuffer = SimpleFramebuffer(width, height, false) framebuffer.setClearColor(0f, 0f, 0f, 0f) framebuffers.add(framebuffer) } @@ -63,15 +65,21 @@ open class FramebufferShader(vararg val shaders: Shader) : MinecraftShortcuts, C val height = mc.window.framebufferHeight framebuffers.forEach { if (it.textureWidth != width || it.textureHeight != height) { - it.resize(width, height, false) + it.resize(width, height) } } - framebuffers[0].clear(false) + framebuffers[0].clear() framebuffers[0].beginWrite(true) + + GlobalFramebuffer.push(framebuffers[0]) } - fun apply() { + open fun apply(popFramebufferStack: Boolean = true) { + if (popFramebufferStack) { + GlobalFramebuffer.pop() + } + val active = GlStateManager._getActiveTexture() val alphaTest = GL11.glIsEnabled(GL11.GL_ALPHA_TEST) @@ -79,15 +87,14 @@ open class FramebufferShader(vararg val shaders: Shader) : MinecraftShortcuts, C GlStateManager._bindTexture(0) RenderSystem.disableDepthTest() - RenderSystem.enableBlend() - RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA) + enableBlend() - RenderSystem.setShaderColor(1f, 1f, 1f, 0f) + RenderSystem.setShaderColor(1f, 1f, 1f, 1f) shaders.forEachIndexed { i, shader -> val inputFramebuffer = framebuffers.getOrNull(i) ?: framebuffers.first() val outputFramebuffer = framebuffers.getOrNull(i + 1) - outputFramebuffer?.clear(false) + outputFramebuffer?.clear() outputFramebuffer?.beginWrite(true) ?: mc.framebuffer.beginWrite(false) GlStateManager._activeTexture(GL13.GL_TEXTURE0 + i) @@ -107,6 +114,7 @@ open class FramebufferShader(vararg val shaders: Shader) : MinecraftShortcuts, C GlStateManager._bindTexture(0) } + endBlend() RenderSystem.enableDepthTest() GlStateManager._activeTexture(active) if (alphaTest) { @@ -114,6 +122,14 @@ open class FramebufferShader(vararg val shaders: Shader) : MinecraftShortcuts, C } } + protected open fun enableBlend() { + RenderSystem.enableBlend() + RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA) + } + + protected open fun endBlend() { + } + fun render(drawAction: () -> Unit) { prepare() drawAction() diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/ScalableCanvas.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/ScalableCanvas.kt index 326343c2a6d..66665b90714 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/ScalableCanvas.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/ScalableCanvas.kt @@ -21,10 +21,11 @@ package net.ccbluex.liquidbounce.render.shader import com.mojang.blaze3d.systems.RenderSystem +import net.ccbluex.liquidbounce.utils.client.mc import net.minecraft.client.MinecraftClient +import net.minecraft.client.gl.ShaderProgramKeys import net.minecraft.client.gl.SimpleFramebuffer import net.minecraft.client.gl.VertexBuffer -import net.minecraft.client.render.GameRenderer import org.joml.Matrix4f import java.io.Closeable @@ -32,12 +33,12 @@ class ScalableCanvas : Closeable { private val identity = Matrix4f() private val output = MinecraftClient.getInstance().framebuffer - private val input = SimpleFramebuffer(output.textureWidth, output.textureHeight, - false, false) + private val input = SimpleFramebuffer(output.textureWidth, output.textureHeight, false) + private val shaderProgram by lazy { mc.shaderLoader.getOrCreateProgram(ShaderProgramKeys.POSITION_TEX_COLOR) } fun resize(width: Int, height: Int) { if (width() != width && height() != height && width > 0 && height > 0) { - input.resize(width, height, MinecraftClient.IS_SYSTEM_MAC) + input.resize(width, height) } } @@ -56,7 +57,7 @@ class ScalableCanvas : Closeable { RenderSystem.setShaderColor(1f, 1f, 1f, alpha) RenderSystem.enableBlend() - buffer.draw(identity, identity, GameRenderer.getPositionTexColorProgram()) + buffer.draw(identity, identity, shaderProgram) } override fun close() { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/Shader.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/Shader.kt index 33ea3b55305..b95dfef5709 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/Shader.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/Shader.kt @@ -20,7 +20,6 @@ package net.ccbluex.liquidbounce.render.shader import com.mojang.blaze3d.platform.GlConst import com.mojang.blaze3d.platform.GlStateManager -import net.minecraft.client.gl.GlProgramManager import java.io.Closeable open class Shader(vertex: String, fragment: String, private val uniforms: Array = emptyArray()) : @@ -55,7 +54,7 @@ open class Shader(vertex: String, fragment: String, private val uniforms: Array< private fun compileShader(source: String, type: Int): Int { val shader = GlStateManager.glCreateShader(type) - GlStateManager.glShaderSource(shader, listOf(source)) + GlStateManager.glShaderSource(shader, source) GlStateManager.glCompileShader(shader) // check compilation status @@ -68,14 +67,14 @@ open class Shader(vertex: String, fragment: String, private val uniforms: Array< } fun use() { - GlProgramManager.useProgram(this.program) + GlStateManager._glUseProgram(this.program) uniforms.forEach { uniform -> uniform.set(uniform.pointer) } } fun stop() { - GlProgramManager.useProgram(0) + GlStateManager._glUseProgram(0) } override fun close() { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/UniformProvider.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/UniformProvider.kt index 3fe956d049a..febdd6af5f3 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/UniformProvider.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/UniformProvider.kt @@ -18,9 +18,20 @@ */ package net.ccbluex.liquidbounce.render.shader +import com.mojang.blaze3d.systems.RenderSystem import net.minecraft.client.gl.GlUniform +import org.lwjgl.opengl.GL20 +import org.lwjgl.system.MemoryUtil -class UniformProvider(val name: String, val set: (pointer: Int) -> Unit) { +private val BUFFER = MemoryUtil.memAllocFloat(16) + +object ProjMatUniform : UniformProvider("projMat", { pointer -> + BUFFER.position(0) + RenderSystem.getProjectionMatrix().get(BUFFER) + GL20.glUniformMatrix4fv(pointer, false, BUFFER) +}) + +open class UniformProvider(val name: String, val set: (pointer: Int) -> Unit) { var pointer = -1 diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/BlendShader.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/BlendShader.kt new file mode 100644 index 00000000000..aa14a09fe9c --- /dev/null +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/BlendShader.kt @@ -0,0 +1,38 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ +package net.ccbluex.liquidbounce.render.shader.shaders + +import net.ccbluex.liquidbounce.render.engine.Color4b +import net.ccbluex.liquidbounce.render.shader.BlitShader +import net.ccbluex.liquidbounce.render.shader.UniformProvider +import net.ccbluex.liquidbounce.utils.io.resourceToString +import org.lwjgl.opengl.GL20 + +object BlendShaderData { + var color = Color4b.WHITE +} + +object BlendShader : BlitShader( + resourceToString("/assets/liquidbounce/shaders/position_tex.vert"), + resourceToString("/assets/liquidbounce/shaders/blend.frag"), + arrayOf( + UniformProvider("texture0") { pointer -> GL20.glUniform1i(pointer, 0) }, + UniformProvider("mixColor") { pointer -> BlendShaderData.color.putToUniform(pointer) } + ) +) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/OutlineEffectShader.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/OutlineEffectShader.kt index 4ab5800f7d0..d776fed18f8 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/OutlineEffectShader.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/OutlineEffectShader.kt @@ -18,7 +18,7 @@ object OutlineEffectShaderData { object OutlineEffectShader : FramebufferShader( Shader( - resourceToString("/assets/liquidbounce/shaders/glow/plane_projection.vert"), + resourceToString("/assets/liquidbounce/shaders/plane_projection.vert"), resourceToString("/assets/liquidbounce/shaders/glow/glow.frag"), arrayOf( UniformProvider("texture0") { pointer -> GL20.glUniform1i(pointer, 0) }, diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/OutlineShader.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/OutlineShader.kt index 08de6edbaf7..324a52399ff 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/OutlineShader.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/shader/shaders/OutlineShader.kt @@ -19,17 +19,58 @@ package net.ccbluex.liquidbounce.render.shader.shaders import net.ccbluex.liquidbounce.render.engine.Color4b -import net.ccbluex.liquidbounce.render.engine.MinecraftFramebufferShader +import net.ccbluex.liquidbounce.render.shader.FramebufferShader +import net.ccbluex.liquidbounce.render.shader.Shader +import net.ccbluex.liquidbounce.render.shader.UniformProvider +import net.ccbluex.liquidbounce.utils.client.ImmutableHandle +import net.ccbluex.liquidbounce.utils.io.resourceToString +import net.minecraft.client.gl.Framebuffer +import net.minecraft.client.render.OutlineVertexConsumerProvider +import net.minecraft.client.util.Handle +import org.lwjgl.opengl.GL20 -object OutlineShader : MinecraftFramebufferShader("outline_shader") { +object OutlineShader : FramebufferShader(Shader( + resourceToString("/assets/liquidbounce/shaders/sobel.vert"), + resourceToString("/assets/liquidbounce/shaders/outline/entity_outline.frag"), + arrayOf( + UniformProvider("texture0") { pointer -> GL20.glUniform1i(pointer, 0) } + ) +)) { - fun begin(width: Float) { - this.setUniform1f("radius", width) - this.beginInternal() + var dirty = false + var vertexConsumerProvider = OutlineVertexConsumerProvider(mc.bufferBuilders.entityVertexConsumers) + val handle: Handle = ImmutableHandle(framebuffers[0]) + private var outlineFbo: Handle? = null + private var outlineFbo2: Framebuffer? = null + + fun update() { + val width = mc.window.framebufferWidth + val height = mc.window.framebufferHeight + framebuffers.forEach { + if (it.textureWidth != width || it.textureHeight != height) { + it.resize(width, height) + } + } + + if (dirty) { + framebuffers[0].clear() + } + + dirty = false + } + + fun setColor(color4b: Color4b) { + vertexConsumerProvider.setColor(color4b.r, color4b.g, color4b.b, color4b.a) } - fun setColor(color: Color4b) { - this.vertexConsumerProvider?.setColor(color.r, color.g, color.b, color.a) + fun draw() { + outlineFbo2 = mc.worldRenderer.entityOutlineFramebuffer + outlineFbo = mc.worldRenderer.framebufferSet.entityOutlineFramebuffer + mc.worldRenderer.entityOutlineFramebuffer = framebuffers[0] + mc.worldRenderer.framebufferSet.entityOutlineFramebuffer = handle + vertexConsumerProvider.draw() + mc.worldRenderer.entityOutlineFramebuffer = outlineFbo2 + mc.worldRenderer.framebufferSet.entityOutlineFramebuffer = outlineFbo } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/ui/ItemImageAtlas.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/ui/ItemImageAtlas.kt index a4cff791751..fbc2cedaa77 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/ui/ItemImageAtlas.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/ui/ItemImageAtlas.kt @@ -1,13 +1,14 @@ package net.ccbluex.liquidbounce.render.ui +import com.mojang.blaze3d.systems.ProjectionType import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.systems.VertexSorter +import net.ccbluex.liquidbounce.common.GlobalFramebuffer import net.ccbluex.liquidbounce.event.EventListener import net.ccbluex.liquidbounce.event.events.ResourceReloadEvent import net.ccbluex.liquidbounce.event.handler +import net.ccbluex.liquidbounce.features.module.MinecraftShortcuts import net.ccbluex.liquidbounce.utils.client.mc import net.ccbluex.liquidbounce.utils.math.Vec2i -import net.minecraft.client.MinecraftClient import net.minecraft.client.gl.Framebuffer import net.minecraft.client.gl.SimpleFramebuffer import net.minecraft.client.gui.DrawContext @@ -18,7 +19,6 @@ import net.minecraft.registry.Registries import net.minecraft.util.Identifier import net.minecraft.util.math.BlockPos import org.joml.Matrix4f -import java.awt.Color import java.awt.image.BufferedImage import java.util.stream.Collectors import kotlin.math.ceil @@ -44,8 +44,9 @@ object ItemImageAtlas: EventListener { private var atlas: Atlas? = null fun updateAtlas(drawContext: DrawContext) { - if (this.atlas != null) + if (this.atlas != null) { return + } val renderer = ItemFramebufferRenderer( Registries.ITEM.stream().collect(Collectors.toList()), @@ -60,12 +61,7 @@ object ItemImageAtlas: EventListener { for (x in 0 until image.width) { for (y in 0 until image.height) { - val r = image.getRed(x, y).toInt() and 0xFF - val g = image.getGreen(x, y).toInt() and 0xFF - val b = image.getBlue(x, y).toInt() and 0xFF - val a = image.getOpacity(x, y).toInt() and 0xFF - - img.setRGB(x, y, Color(r, g, b, a).rgb) + img.setRGB(x, y, image.getColorArgb(x, y)) } } @@ -78,7 +74,7 @@ object ItemImageAtlas: EventListener { val map = hashMapOf() Registries.BLOCK.forEach { - val pickUpState = it.getPickStack(mc.world!!, BlockPos.ORIGIN, it.defaultState) + val pickUpState = it.getPickStack(mc.world!!, BlockPos.ORIGIN, it.defaultState, false) if (pickUpState.item != it) { val blockId = Registries.BLOCK.getId(it) @@ -120,15 +116,14 @@ object ItemImageAtlas: EventListener { private class ItemFramebufferRenderer( val items: List, val scale: Int, -) { +): MinecraftShortcuts { val itemsPerDimension = ceil(sqrt(items.size.toDouble())).toInt() val framebuffer: Framebuffer = run { val fb = SimpleFramebuffer( NATIVE_ITEM_SIZE * scale * itemsPerDimension, NATIVE_ITEM_SIZE * scale * itemsPerDimension, - true, - MinecraftClient.IS_SYSTEM_MAC + true ) fb.setClearColor(0.0f, 0.0f, 0.0f, 0.0f) @@ -158,7 +153,8 @@ private class ItemFramebufferRenderer( 21000.0f ) - RenderSystem.setProjectionMatrix(matrix4f, VertexSorter.BY_Z) + RenderSystem.setProjectionMatrix(matrix4f, ProjectionType.ORTHOGRAPHIC) + GlobalFramebuffer.push(framebuffer) val map = this.items.mapIndexed { idx, item -> val from = Vec2i( @@ -179,9 +175,10 @@ private class ItemFramebufferRenderer( ctx.matrices.pop() - MinecraftClient.getInstance().framebuffer.beginWrite(true) + GlobalFramebuffer.pop() + mc.framebuffer.beginWrite(true) - RenderSystem.setProjectionMatrix(projectionMatrix, VertexSorter.BY_Z) + RenderSystem.setProjectionMatrix(projectionMatrix, ProjectionType.ORTHOGRAPHIC) return map } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/script/bindings/api/ScriptNetworkUtil.kt b/src/main/kotlin/net/ccbluex/liquidbounce/script/bindings/api/ScriptNetworkUtil.kt index edbcf3ebfce..cea1ffc6eae 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/script/bindings/api/ScriptNetworkUtil.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/script/bindings/api/ScriptNetworkUtil.kt @@ -25,19 +25,29 @@ import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket object ScriptNetworkUtil { @JvmName("movePlayerGround") - fun movePlayerGround(onGround: Boolean) = network.sendPacket(PlayerMoveC2SPacket.OnGroundOnly(onGround)) + fun movePlayerGround(onGround: Boolean, horizontalCollision: Boolean) = + network.sendPacket(PlayerMoveC2SPacket.OnGroundOnly(onGround, horizontalCollision)) @JvmName("movePlayerPosition") - fun movePlayerPosition(x: Double, y: Double, z: Double, onGround: Boolean) = - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(x, y, z, onGround)) + fun movePlayerPosition(x: Double, y: Double, z: Double, onGround: Boolean, horizontalCollision: Boolean) = + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(x, y, z, onGround, horizontalCollision)) + @Suppress("LongParameterList") @JvmName("movePlayerPositionAndLook") - fun movePlayerPositionAndLook(x: Double, y: Double, z: Double, yaw: Float, pitch: Float, onGround: Boolean) = - network.sendPacket(PlayerMoveC2SPacket.Full(x, y, z, yaw, pitch, onGround)) + fun movePlayerPositionAndLook( + x: Double, + y: Double, + z: Double, + yaw: Float, + pitch: Float, + onGround: Boolean, + horizontalCollision: Boolean + ) = + network.sendPacket(PlayerMoveC2SPacket.Full(x, y, z, yaw, pitch, onGround, horizontalCollision)) @JvmName("movePlayerLook") - fun movePlayerLook(yaw: Float, pitch: Float, onGround: Boolean) = - network.sendPacket(PlayerMoveC2SPacket.LookAndOnGround(yaw, pitch, onGround)) + fun movePlayerLook(yaw: Float, pitch: Float, onGround: Boolean, horizontalCollision: Boolean) = + network.sendPacket(PlayerMoveC2SPacket.LookAndOnGround(yaw, pitch, onGround, horizontalCollision)) @JvmName("sendChatMessage") fun sendChatMessage(message: String) = network.sendChatMessage(message) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationModes.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationModes.kt index 152c115e269..98a4259f70f 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationModes.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationModes.kt @@ -81,7 +81,8 @@ class NoRotationMode(configurable: ChoiceConfigurable, module: Cli if (send) { val fixedRotation = rotation.normalize() network.connection!!.send( - PlayerMoveC2SPacket.LookAndOnGround(fixedRotation.yaw, fixedRotation.pitch, player.isOnGround), + PlayerMoveC2SPacket.LookAndOnGround(fixedRotation.yaw, fixedRotation.pitch, player.isOnGround, + player.horizontalCollision), null ) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationsUtil.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationsUtil.kt index 9ac84763966..da4495cb39d 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationsUtil.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/aiming/RotationsUtil.kt @@ -355,8 +355,10 @@ object RotationManager : EventListener { val tickHandler = handler(priority = EventPriorityConvention.READ_FINAL_STATE) { event -> val input = SimulatedPlayer.SimulatedPlayerInput.fromClientPlayer(event.directionalInput) - input.sneaking = event.sneaking - input.jumping = event.jumping + input.set( + sneak = event.sneak, + jump = event.jump + ) val simulatedPlayer = SimulatedPlayer.fromClientPlayer(input) simulatedPlayer.tick() @@ -398,7 +400,7 @@ object RotationManager : EventListener { // We trust that we have sent a normalized rotation, if not, ... why? Rotation(packet.yaw, packet.pitch, isNormalized = true) } - is PlayerPositionLookS2CPacket -> Rotation(packet.yaw, packet.pitch, isNormalized = true) + is PlayerPositionLookS2CPacket -> Rotation(packet.change.yaw, packet.change.pitch, isNormalized = true) is PlayerInteractItemC2SPacket -> Rotation(packet.yaw, packet.pitch, isNormalized = true) else -> return@handler } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/BlockExtensions.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/BlockExtensions.kt index 469c6bde274..ff458abfb4b 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/BlockExtensions.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/BlockExtensions.kt @@ -489,7 +489,7 @@ private inline fun handleActionsOnAccept( onPlacementSuccess: () -> Boolean, swingMode: SwingMode = SwingMode.DO_NOT_HIDE, ) { - if (!interactionResult.shouldSwingHand()) { + if (interactionResult.shouldSwingHand()) { return } @@ -504,6 +504,12 @@ private inline fun handleActionsOnAccept( return } +private fun ActionResult.shouldSwingHand(): Boolean { + return this !is ActionResult.Success || + this.swingSource != ActionResult.SwingSource.SERVER +} + + /** * Just interacts with the item in the hand instead of using it on the block */ diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/ChunkScanner.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/ChunkScanner.kt index 49c780ad56d..a18a6b1a0a4 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/ChunkScanner.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/ChunkScanner.kt @@ -233,7 +233,7 @@ object ChunkScanner : EventListener, MinecraftShortcuts { val startX = chunk.pos.startX val startZ = chunk.pos.startZ - (chunk.bottomY..chunk.topY).map { y -> + (chunk.bottomY..chunk.topYInclusive + 1).map { y -> scope.launch { /** * @see WorldChunk.getBlockState diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/Region.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/Region.kt index 6e9663de825..a894f1fd1e1 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/Region.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/Region.kt @@ -51,14 +51,14 @@ class Region(from: BlockPos, to: BlockPos) : ClosedRange, Iterable - if (chunk != null && (pos.y <= chunk.bottomY || pos.y - 1 >= chunk.topY)) { + if (chunk != null && (pos.y <= chunk.bottomY || pos.y - 1 >= chunk.topYInclusive + 1)) { return@forEach } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/placer/BlockPlacer.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/placer/BlockPlacer.kt index 385ea46e720..0587ff09b26 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/placer/BlockPlacer.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/placer/BlockPlacer.kt @@ -145,7 +145,7 @@ class BlockPlacer( if (sneakTimes > 0) { sneakTimes-- - it.movementEvent.sneaking = true + it.movementEvent.sneak = true } if (blocks.isEmpty()) { @@ -266,7 +266,7 @@ class BlockPlacer( ) ) { sneakTimes = sneak - 1 - it.movementEvent.sneaking = true + it.movementEvent.sneak = true } if (rotationMode.activeChoice(entry.booleanValue, pos, placementTarget)) { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/placer/BlockPlacerRotationModes.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/placer/BlockPlacerRotationModes.kt index a73b6681fbe..63da34074a4 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/placer/BlockPlacerRotationModes.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/block/placer/BlockPlacerRotationModes.kt @@ -118,7 +118,8 @@ class NoRotationMode(configurable: ChoiceConfigurable, if (send) { val rotation = placementTarget.rotation.normalize() network.connection!!.send( - PlayerMoveC2SPacket.LookAndOnGround(rotation.yaw, rotation.pitch, player.isOnGround), + PlayerMoveC2SPacket.LookAndOnGround(rotation.yaw, rotation.pitch, player.isOnGround, + player.horizontalCollision), null ) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/ImmutableHandle.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/ImmutableHandle.kt new file mode 100644 index 00000000000..9a35a5bbc22 --- /dev/null +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/ImmutableHandle.kt @@ -0,0 +1,25 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ +package net.ccbluex.liquidbounce.utils.client + +import net.minecraft.client.util.Handle + +class ImmutableHandle(val value: T) : Handle { + override fun get() = value +} diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/InteractionTracker.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/InteractionTracker.kt index 6bdc2e72b1a..1b65cbe8404 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/InteractionTracker.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/InteractionTracker.kt @@ -4,11 +4,11 @@ import net.ccbluex.liquidbounce.event.EventListener import net.ccbluex.liquidbounce.event.events.PacketEvent import net.ccbluex.liquidbounce.event.handler import net.ccbluex.liquidbounce.features.module.modules.movement.noslow.modes.blocking.NoSlowBlock.player +import net.minecraft.item.consume.UseAction import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket import net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket import net.minecraft.util.Hand -import net.minecraft.util.UseAction object InteractionTracker : EventListener { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/NetworkUtils.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/NetworkUtils.kt index dc408a44ffa..0f47441edf2 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/NetworkUtils.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/NetworkUtils.kt @@ -29,6 +29,7 @@ import net.minecraft.client.network.ClientPlayerEntity import net.minecraft.client.network.ClientPlayerInteractionManager import net.minecraft.client.network.SequencedPacketCreator import net.minecraft.entity.player.PlayerEntity +import net.minecraft.item.ItemStack import net.minecraft.item.ItemUsageContext import net.minecraft.network.listener.ClientPlayPacketListener import net.minecraft.network.packet.Packet @@ -41,12 +42,13 @@ import net.minecraft.util.Hand import net.minecraft.util.hit.BlockHitResult import net.minecraft.world.GameMode import org.apache.commons.lang3.mutable.MutableObject +import java.util.* fun clickBlockWithSlot( player: ClientPlayerEntity, rayTraceResult: BlockHitResult, slot: Int, - placementSwingMode: SwingMode, + swingMode: SwingMode, switchMode: SwitchMode = SwitchMode.SILENT ) { val hand = if (slot == OFFHAND_SLOT.hotbarSlotForServer) { @@ -87,8 +89,8 @@ fun clickBlockWithSlot( actionResult = itemStack.useOnBlock(itemUsageContext) } - if (actionResult.shouldSwingHand()) { - placementSwingMode.swing(hand) + if (actionResult is ActionResult.Success && actionResult.swingSource == ActionResult.SwingSource.CLIENT) { + swingMode.swing(hand) } if (slot != prevHotbarSlot && hand == Hand.MAIN_HAND && switchMode == SwitchMode.SILENT) { @@ -116,18 +118,25 @@ fun ClientPlayerInteractionManager.interactItem( this.sendSequencedPacket(world, SequencedPacketCreator { sequence: Int -> val playerInteractItemC2SPacket = PlayerInteractItemC2SPacket(hand, sequence, yaw, pitch) val itemStack = player.getStackInHand(hand) - if (player.itemCooldownManager.isCoolingDown(itemStack.item)) { - mutableObject.value = ActionResult.PASS + if (player.itemCooldownManager.isCoolingDown(itemStack)) { + mutableObject.setValue(ActionResult.PASS) return@SequencedPacketCreator playerInteractItemC2SPacket } val typedActionResult = itemStack.use(world, player, hand) - val itemStack2 = typedActionResult.value + val itemStack2 = if (typedActionResult is ActionResult.Success) { + Objects.requireNonNullElseGet( + typedActionResult.newHandStack + ) { player.getStackInHand(hand) } as ItemStack + } else { + player.getStackInHand(hand) + } + if (itemStack2 != itemStack) { player.setStackInHand(hand, itemStack2) } - mutableObject.value = typedActionResult.result + mutableObject.setValue(typedActionResult) return@SequencedPacketCreator playerInteractItemC2SPacket }) @@ -147,15 +156,17 @@ fun sendPacketSilently(packet: Packet<*>) { enum class MovePacketType(override val choiceName: String, val generatePacket: () -> PlayerMoveC2SPacket) : NamedChoice { ON_GROUND_ONLY("OnGroundOnly", { - PlayerMoveC2SPacket.OnGroundOnly(player.isOnGround) + PlayerMoveC2SPacket.OnGroundOnly(player.isOnGround, player.horizontalCollision) }), POSITION_AND_ON_GROUND("PositionAndOnGround", { - PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, player.isOnGround) + PlayerMoveC2SPacket.PositionAndOnGround(player.x, player.y, player.z, player.isOnGround, + player.horizontalCollision) }), LOOK_AND_ON_GROUND("LookAndOnGround", { - PlayerMoveC2SPacket.LookAndOnGround(player.yaw, player.pitch, player.isOnGround) + PlayerMoveC2SPacket.LookAndOnGround(player.yaw, player.pitch, player.isOnGround, player.horizontalCollision) }), FULL("Full", { - PlayerMoveC2SPacket.Full(player.x, player.y, player.z, player.yaw, player.pitch, player.isOnGround) + PlayerMoveC2SPacket.Full(player.x, player.y, player.z, player.yaw, player.pitch, player.isOnGround, + player.horizontalCollision) }); } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/ProtocolUtil.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/ProtocolUtil.kt index 56580376272..841225f0eda 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/ProtocolUtil.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/client/ProtocolUtil.kt @@ -130,15 +130,6 @@ fun openVfpProtocolSelection() { VfpCompatibility.INSTANCE.unsafeOpenVfpProtocolSelection() } -fun disableConflictingVfpOptions() { - // Check if the ViaFabricPlus mod is loaded - if (!usesViaFabricPlus || !hasVisualSettings) { - return - } - - VfpCompatibility.INSTANCE.unsafeDisableConflictingVfpOptions() -} - fun sendSignUpdate(blockPos: BlockPos, lines: Array) { require(hasProtocolTranslator) { "ProtocolTranslator is missing" } require(isEqual1_8) { "Not 1.8 protocol" } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/combat/CombatExtensions.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/combat/CombatExtensions.kt index dc3c55e3795..fb051064b84 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/combat/CombatExtensions.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/combat/CombatExtensions.kt @@ -221,7 +221,7 @@ fun Entity.attack(swing: Boolean, keepSprint: Boolean = false) { if (this.isUsingRiptide) { this.riptideAttackDamage } else { - getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE).toFloat() + getAttributeValue(EntityAttributes.ATTACK_DAMAGE).toFloat() } val damageSource = this.damageSources.playerAttack(this) var enchantAttackDamage = this.getDamageAgainst(this@attack, genericAttackDamage, diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/EntityExtensions.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/EntityExtensions.kt index f2df9d3da47..6d418f98204 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/EntityExtensions.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/EntityExtensions.kt @@ -43,20 +43,19 @@ import net.minecraft.entity.effect.StatusEffects import net.minecraft.entity.mob.CreeperEntity import net.minecraft.entity.player.PlayerEntity import net.minecraft.entity.vehicle.TntMinecartEntity +import net.minecraft.item.consume.UseAction import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket import net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket import net.minecraft.scoreboard.ScoreboardDisplaySlot import net.minecraft.stat.Stats -import net.minecraft.util.UseAction import net.minecraft.util.hit.HitResult import net.minecraft.util.math.* import net.minecraft.util.shape.VoxelShapes import net.minecraft.world.Difficulty -import net.minecraft.world.GameRules import net.minecraft.world.RaycastContext import net.minecraft.world.explosion.Explosion import net.minecraft.world.explosion.ExplosionBehavior -import java.util.function.Predicate +import net.minecraft.world.explosion.ExplosionImpl import kotlin.math.cos import kotlin.math.floor import kotlin.math.sin @@ -85,8 +84,10 @@ fun ClientPlayerEntity.isCloseToEdge( val simulatedInput = SimulatedPlayer.SimulatedPlayerInput.fromClientPlayer(directionalInput) - simulatedInput.jumping = false - simulatedInput.sneaking = false + simulatedInput.set( + jump = false, + sneak = false + ) val simulatedPlayer = SimulatedPlayer.fromClientPlayer( simulatedInput @@ -117,7 +118,7 @@ fun ClientPlayerEntity.isCloseToEdge( } val ClientPlayerEntity.pressingMovementButton - get() = input.pressingForward || input.pressingBack || input.pressingLeft || input.pressingRight + get() = input.playerInput.forward || input.playerInput.backward || input.playerInput.left || input.playerInput.right val Entity.exactPosition get() = Vec3d(x, y, z) @@ -361,12 +362,14 @@ fun PlayerEntity.wouldBlockHit(source: PlayerEntity): Boolean { fun LivingEntity.getEffectiveDamage(source: DamageSource, damage: Float, ignoreShield: Boolean = false): Float { val world = this.world - if (this.isInvulnerableTo(source)) + if (this.isAlwaysInvulnerableTo(source)) { return 0.0F + } // EDGE CASE!!! Might cause weird bugs - if (this.isDead) + if (this.isDead) { return 0.0F + } var amount = damage @@ -409,16 +412,16 @@ fun LivingEntity.getEffectiveDamage(source: DamageSource, damage: Float, ignoreS fun LivingEntity.getExplosionDamageFromEntity(entity: Entity): Float { return when (entity) { - is EndCrystalEntity -> getDamageFromExplosion(entity.pos, entity, 6f, 12f, 144f) - is TntEntity -> getDamageFromExplosion(entity.pos.add(0.0, 0.0625, 0.0), entity, 4f, 8f, 64f) + is EndCrystalEntity -> getDamageFromExplosion(entity.pos, 6f, 12f, 144f) + is TntEntity -> getDamageFromExplosion(entity.pos.add(0.0, 0.0625, 0.0), 4f, 8f, 64f) is TntMinecartEntity -> { val d = 5f - getDamageFromExplosion(entity.pos, entity, 4f + d * 1.5f) + getDamageFromExplosion(entity.pos, 4f + d * 1.5f) } is CreeperEntity -> { - val f = if (entity.shouldRenderOverlay()) 2f else 1f - getDamageFromExplosion(entity.pos, entity, entity.explosionRadius * f) + val f = if (entity.isCharged) 2f else 1f + getDamageFromExplosion(entity.pos, entity.explosionRadius * f) } else -> 0f @@ -431,7 +434,6 @@ fun LivingEntity.getExplosionDamageFromEntity(entity: Entity): Float { @Suppress("LongParameterList") fun LivingEntity.getDamageFromExplosion( pos: Vec3d, - exploding: Entity? = null, power: Float = 6f, explosionRange: Float = power * 2f, // allows setting precomputed values damageDistance: Float = explosionRange * explosionRange, @@ -456,7 +458,7 @@ fun LivingEntity.getDamageFromExplosion( val exposure = if (useTweakedMethod) { getExposureToExplosion(pos, exclude, include, maxBlastResistance, entityBoundingBox) } else { - Explosion.getExposure(pos, this) + ExplosionImpl.calculateReceivedDamage(pos, this) } val distanceDecay = 1.0 - (sqrt(this.squaredDistanceTo(pos)) / explosionRange.toDouble()) @@ -467,25 +469,14 @@ fun LivingEntity.getDamageFromExplosion( return 0f } - val explosion = Explosion( - world, - exploding, - pos.x, - pos.y, - pos.z, - power, - false, - world.getDestructionType(GameRules.BLOCK_EXPLOSION_DROP_DECAY) - ) - - return getEffectiveDamage(world.damageSources.explosion(explosion), preprocessedDamage.toFloat()) + return getEffectiveDamage(world.damageSources.explosion(null), preprocessedDamage.toFloat()) } finally { ShapeFlag.noShapeChange = false } } /** - * Basically [Explosion.getExposure] but this method allows us to exclude blocks using [exclude]. + * Basically [ExplosionImpl.calculateReceivedDamage] but this method allows us to exclude blocks using [exclude]. */ @Suppress("NestedBlockDepth") fun LivingEntity.getExposureToExplosion( @@ -501,9 +492,9 @@ fun LivingEntity.getExposureToExplosion( isDescending, entityBoundingBox1.minY, mainHandStack, - Predicate { state -> canWalkOnFluid(state) }, + { state -> canWalkOnFluid(state) }, this - ) // TODO does this work? + ) } ?: ShapeContext.of(this) val stepX = 1.0 / ((entityBoundingBox1.maxX - entityBoundingBox1.minX) * 2.0 + 1.0) @@ -623,14 +614,14 @@ fun ClientPlayerEntity.warp(pos: Vec3d? = null, onGround: Boolean = false) { if (vehicle != null) { pos?.let(vehicle::setPosition) - network.sendPacket(VehicleMoveC2SPacket(vehicle)) + network.sendPacket(VehicleMoveC2SPacket.fromVehicle(vehicle)) return } if (pos != null) { - network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(pos.x, pos.y, pos.z, onGround)) + network.sendPacket(PlayerMoveC2SPacket.PositionAndOnGround(pos.x, pos.y, pos.z, onGround, horizontalCollision)) } else { - network.sendPacket(PlayerMoveC2SPacket.OnGroundOnly(onGround)) + network.sendPacket(PlayerMoveC2SPacket.OnGroundOnly(onGround, horizontalCollision)) } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/InputAdditions.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/InputAdditions.kt new file mode 100644 index 00000000000..8f7a451faae --- /dev/null +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/InputAdditions.kt @@ -0,0 +1,65 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ +package net.ccbluex.liquidbounce.utils.entity + +import net.minecraft.client.input.Input +import net.minecraft.util.ActionResult +import net.minecraft.util.PlayerInput + +@Suppress("LongParameterList") +fun PlayerInput.modified( + forward: Boolean = this.forward, + backward: Boolean = this.backward, + left: Boolean = this.left, + right: Boolean = this.right, + jump: Boolean = this.jump, + sneak: Boolean = this.sneak, + sprint: Boolean = this.sprint +): PlayerInput { + return PlayerInput( + forward, + backward, + left, + right, + jump, + sneak, + sprint + ) +} + +@Suppress("LongParameterList") +fun Input.set( + forward: Boolean = playerInput.forward, + backward: Boolean = playerInput.backward, + left: Boolean = playerInput.left, + right: Boolean = playerInput.right, + jump: Boolean = playerInput.jump, + sneak: Boolean = playerInput.sneak, + sprint: Boolean = playerInput.sprint +) { + this.playerInput = PlayerInput( + forward, + backward, + left, + right, + jump, + sneak, + sprint + ) +} diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/SimulatedPlayer.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/SimulatedPlayer.kt index fe15e92a3a2..1ba555ff3f6 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/SimulatedPlayer.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/entity/SimulatedPlayer.kt @@ -22,7 +22,6 @@ package net.ccbluex.liquidbounce.utils.entity import it.unimi.dsi.fastutil.objects.Object2DoubleArrayMap import it.unimi.dsi.fastutil.objects.Object2DoubleMap -import net.ccbluex.liquidbounce.event.EventManager import net.ccbluex.liquidbounce.event.EventManager.callEvent import net.ccbluex.liquidbounce.event.events.PlayerMoveEvent import net.ccbluex.liquidbounce.event.events.PlayerSafeWalkEvent @@ -107,7 +106,7 @@ class SimulatedPlayer( player.fallDistance, player.jumpingCooldown, player.jumping, - player.isFallFlying, + player.isGliding, player.isOnGround, player.horizontalCollision, player.verticalCollision, @@ -135,7 +134,7 @@ class SimulatedPlayer( player.fallDistance, player.jumpingCooldown, player.jumping, - player.isFallFlying, + player.isGliding, player.isOnGround, player.horizontalCollision, player.verticalCollision, @@ -172,7 +171,7 @@ class SimulatedPlayer( this.jumpingCooldown-- } - this.isJumping = this.input.jumping + this.isJumping = this.input.playerInput.jump val d: Vec3d = this.velocity @@ -227,7 +226,7 @@ class SimulatedPlayer( if (this.isSwimming && !this.player.hasVehicle()) { val g = this.getRotationVector().y val h = if (g < -0.2) 0.085 else 0.06 - if (g <= 0.0 || this.input.jumping || !this.player.world + if (g <= 0.0 || this.input.playerInput.jump || !this.player.world .getBlockState(BlockPos.ofFloored(this.pos.x, this.pos.y + 1.0 - 0.1, this.pos.z)) .fluidState.isEmpty ) { @@ -257,7 +256,7 @@ class SimulatedPlayer( val e: Double = this.pos.y var f = if (isSprinting()) 0.9f else 0.8f // this.player.getBaseMovementSpeedMultiplier() var g = 0.02f - var h = this.getAttributeValue(EntityAttributes.GENERIC_WATER_MOVEMENT_EFFICIENCY).toFloat() + var h = this.getAttributeValue(EntityAttributes.WATER_MOVEMENT_EFFICIENCY).toFloat() if (!onGround) { h *= 0.5f @@ -634,7 +633,7 @@ class SimulatedPlayer( } protected fun shouldClipAtLedge(): Boolean { - return this.input.sneaking || this.input.forceSafeWalk + return this.input.playerInput.sneak || this.input.forceSafeWalk } private fun method_30263(): Boolean { @@ -885,31 +884,39 @@ class SimulatedPlayer( var forceSafeWalk: Boolean = false init { - this.pressingForward = directionalInput.forwards - this.pressingBack = directionalInput.backwards - this.pressingLeft = directionalInput.left - this.pressingRight = directionalInput.right - this.jumping = jumping - this.sneaking = sneaking + set( + forward = directionalInput.forwards, + backward = directionalInput.backwards, + left = directionalInput.left, + right = directionalInput.right, + jump = jumping, + sneak = sneaking + ) } fun update() { - if (this.pressingForward != this.pressingBack) { - this.movementForward = if (this.pressingForward) 1.0f else -1.0f + if (this.playerInput.forward != this.playerInput.backward) { + this.movementForward = if (this.playerInput.forward) 1.0f else -1.0f } else { this.movementForward = 0.0f } - movementSideways = if (pressingLeft == pressingRight) 0.0f else if (pressingLeft) 1.0f else -1.0f + movementSideways = if (playerInput.left == playerInput.right) { + 0.0f + } else if (playerInput.left) { + 1.0f + } else { + -1.0f + } - if (sneaking) { + if (playerInput.sneak) { movementSideways = (movementSideways.toDouble() * 0.3).toFloat() movementForward = (movementForward.toDouble() * 0.3).toFloat() } } override fun toString(): String { - return "SimulatedPlayerInput(forwards={${this.pressingForward}}, backwards={${this.pressingBack}}, left={${this.pressingLeft}}, right={${this.pressingRight}}, jumping={${this.jumping}}, sprinting=$sprinting, slowDown=$sneaking)" + return "SimulatedPlayerInput(forwards={${this.playerInput.forward}}, backwards={${this.playerInput.backward}}, left={${this.playerInput.left}}, right={${this.playerInput.right}}, jumping={${this.playerInput.jump}}, sprinting=$sprinting, slowDown=${playerInput.sneak})" } companion object { @@ -917,20 +924,20 @@ class SimulatedPlayer( fun fromClientPlayer( directionalInput: DirectionalInput, - jumping: Boolean = player.input.jumping, + jump: Boolean = player.input.playerInput.jump, sprinting: Boolean = player.isSprinting, sneaking: Boolean = player.isSneaking ): SimulatedPlayerInput { val input = SimulatedPlayerInput( directionalInput, - jumping, + jump, sprinting, sneaking ) val safeWalkEvent = PlayerSafeWalkEvent() - EventManager.callEvent(safeWalkEvent) + callEvent(safeWalkEvent) if (safeWalkEvent.isSafeWalk) { input.forceSafeWalk = true diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/inventory/InventoryUtils.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/inventory/InventoryUtils.kt index 7865a210d8b..1c5921a71a0 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/inventory/InventoryUtils.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/inventory/InventoryUtils.kt @@ -40,6 +40,7 @@ import net.minecraft.item.ItemStack import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket import net.minecraft.registry.Registries import net.minecraft.registry.tag.ItemTags +import net.minecraft.util.ActionResult import net.minecraft.util.Hand import kotlin.math.abs @@ -208,7 +209,7 @@ fun interactItem( preInteraction() interaction.interactItem(player, hand, yaw, pitch).takeIf { it.isAccepted }?.let { - if (it.shouldSwingHand()) { + if (it is ActionResult.Success && it.swingSource == ActionResult.SwingSource.CLIENT) { player.swingHand(hand) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/inventory/ViewedInventoryScreen.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/inventory/ViewedInventoryScreen.kt index 08869b4bba9..47403e13ef8 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/inventory/ViewedInventoryScreen.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/inventory/ViewedInventoryScreen.kt @@ -100,13 +100,16 @@ class ViewedInventoryScreen(private val player: () -> PlayerEntity?) : Screen(Te context.matrices.push() context.matrices.translate(0f, 0f, 232f) context.drawItem(stack, x, y) - context.drawItemInSlot(textRenderer, stack, x, y, null) + context.drawStackOverlay(textRenderer, stack, x, y, null) context.matrices.pop() } private fun drawBackground(context: DrawContext, mouseX: Int, mouseY: Int) { val backgroundTexture = Identifier.ofVanilla("textures/gui/container/inventory.png") - context.drawTexture(backgroundTexture, x, y, 0, 0, backgroundWidth, backgroundHeight) + context.drawTexture( + RenderLayer::getGuiTextured, backgroundTexture, x, y, 0f, 0f, backgroundWidth, backgroundHeight, + backgroundWidth, backgroundHeight + ) player()?.let { player -> drawEntity( context, x + 26, y + 8, x + 75, y + 78, @@ -121,10 +124,10 @@ class ViewedInventoryScreen(private val player: () -> PlayerEntity?) : Screen(Te context.matrices.push() context.matrices.translate(0f, 0f, 100f) if (slot.stack.isEmpty && slot.isEnabled) { - val pair = slot.backgroundSprite - if (pair != null) { - val sprite = mc.getSpriteAtlas(pair.first).apply(pair.second) as Sprite - context.drawSprite(slot.x, slot.y, 0, 16, 16, sprite) + val identifier = slot.backgroundSprite + if (identifier != null) { + val sprite = mc.getSpriteAtlas(identifier).apply(identifier) as Sprite + context.drawSpriteStretched(RenderLayer::getGuiTextured, sprite, slot.x, slot.y, 16, 16) spriteDrawn = true } } @@ -137,7 +140,7 @@ class ViewedInventoryScreen(private val player: () -> PlayerEntity?) : Screen(Te context.drawItem(slot.stack, slot.x, slot.y, seed) } - context.drawItemInSlot(textRenderer, slot.stack, slot.x, slot.y, null) + context.drawStackOverlay(textRenderer, slot.stack, slot.x, slot.y, null) } context.matrices.pop() diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/ArmorComparator.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/ArmorComparator.kt index 1b00c0599d1..f437e7544fd 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/ArmorComparator.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/ArmorComparator.kt @@ -20,6 +20,7 @@ package net.ccbluex.liquidbounce.utils.item import net.ccbluex.liquidbounce.utils.sorting.ComparatorChain import net.ccbluex.liquidbounce.utils.sorting.compareByCondition +import net.minecraft.component.DataComponentTypes import net.minecraft.enchantment.Enchantment import net.minecraft.enchantment.Enchantments import net.minecraft.entity.EquipmentSlot @@ -108,7 +109,7 @@ class ArmorComparator( compareByDescending { round(getThresholdedDamageReduction(it.itemSlot.itemStack).toDouble(), 3) }, compareBy { round(getEnchantmentThreshold(it.itemSlot.itemStack).toDouble(), 3) }, compareBy { it.itemSlot.itemStack.getEnchantmentCount() }, - compareBy { (it.itemSlot.itemStack.item as ArmorItem).enchantability }, + compareBy { it.itemSlot.itemStack.get(DataComponentTypes.ENCHANTABLE)?.value ?: 0 }, compareByCondition(ArmorPiece::isAlreadyEquipped), compareByCondition(ArmorPiece::isReachableByHand) ) @@ -119,12 +120,14 @@ class ArmorComparator( private fun getThresholdedDamageReduction(itemStack: ItemStack): Float { val item = itemStack.item as ArmorItem - val parameters = this.armorKitParametersForSlot.getParametersForSlot(item.slotType) + val parameters = this.armorKitParametersForSlot.getParametersForSlot( + itemStack.get(DataComponentTypes.EQUIPPABLE)!!.slot + ) return getDamageFactor( damage = expectedDamage, - defensePoints = parameters.defensePoints + item.material.value().getProtection(item.type), - toughness = parameters.toughness + item.material.value().toughness + defensePoints = parameters.defensePoints + item.material().defense.getOrDefault(item.type(), 0), + toughness = parameters.toughness + item.material().toughness ) * (1 - getThresholdedEnchantmentDamageReduction(itemStack)) } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/ArmorPiece.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/ArmorPiece.kt index 2f06eb5618e..2035686b867 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/ArmorPiece.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/ArmorPiece.kt @@ -25,7 +25,7 @@ import net.minecraft.item.ArmorItem class ArmorPiece(val itemSlot: ItemSlot) { val slotType: EquipmentSlot - get() = (itemSlot.itemStack.item as ArmorItem).slotType + get() = (itemSlot.itemStack.item as ArmorItem).type().equipmentSlot val entitySlotId: Int get() = this.slotType.entitySlotId val inventorySlot: Int @@ -36,11 +36,11 @@ class ArmorPiece(val itemSlot: ItemSlot) { get() = itemSlot.slotType == ItemSlotType.HOTBAR val toughness: Float - get() = (itemSlot.itemStack.item as ArmorItem).toughness + get() = (itemSlot.itemStack.item as ArmorItem).material().toughness val defensePoints: Float get() { val item = itemSlot.itemStack.item as ArmorItem - return item.material.value().getProtection(item.type).toFloat() + return item.material().defense.getOrDefault(item.type(), 0).toFloat() } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/ItemExtensions.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/ItemExtensions.kt index c592fb3424e..8f904523136 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/ItemExtensions.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/ItemExtensions.kt @@ -42,10 +42,10 @@ import net.minecraft.entity.attribute.EntityAttributeInstance import net.minecraft.entity.attribute.EntityAttributes import net.minecraft.entity.effect.StatusEffectInstance import net.minecraft.item.* +import net.minecraft.item.consume.UseAction import net.minecraft.registry.RegistryKey import net.minecraft.registry.RegistryKeys import net.minecraft.registry.entry.RegistryEntry -import net.minecraft.util.UseAction import net.minecraft.util.math.BlockPos import java.util.* import kotlin.contracts.ExperimentalContracts @@ -67,7 +67,7 @@ fun createSplashPotion(name: String, vararg effects: StatusEffectInstance): Item itemStack.set(DataComponentTypes.CUSTOM_NAME, regular(name)) itemStack.set( DataComponentTypes.POTION_CONTENTS, - PotionContentsComponent(Optional.empty(), Optional.empty(), effects.asList()) + PotionContentsComponent(Optional.empty(), Optional.empty(), effects.asList(), Optional.empty()) ) return itemStack @@ -137,7 +137,7 @@ val ItemStack.foodComponent: FoodComponent? fun isHotbarSlot(slot: Int) = slot == 45 || slot in 36..44 -val ToolItem.type: Int +val MiningToolItem.type: Int get() = when (this) { is AxeItem -> 0 is PickaxeItem -> 1 @@ -157,8 +157,8 @@ fun ItemStack.getAttributeValue(attribute: RegistryEntry) = ite val ItemStack.attackDamage: Double get() { - val entityBaseDamage = player.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE) - val baseDamage = getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE) + val entityBaseDamage = player.getAttributeValue(EntityAttributes.ATTACK_DAMAGE) + val baseDamage = getAttributeValue(EntityAttributes.ATTACK_DAMAGE) ?: return 0.0 /* @@ -177,7 +177,7 @@ val ItemStack.sharpnessLevel: Int fun ItemStack.getSharpnessDamage(level: Int = sharpnessLevel) = if (level == 0) 0.0 else 0.5 * level + 0.5 val ItemStack.attackSpeed: Float - get() = item.getAttributeValue(EntityAttributes.GENERIC_ATTACK_SPEED) + get() = item.getAttributeValue(EntityAttributes.ATTACK_DAMAGE) private fun Item.getAttributeValue(attribute: RegistryEntry): Float { val attribInstance = EntityAttributeInstance(attribute) {} @@ -199,7 +199,7 @@ fun RegistryKey.toRegistryEntry(): RegistryEntry { val world = mc.world requireNotNull(world) { "World is null" } - val registry = world.registryManager.getWrapperOrThrow(RegistryKeys.ENCHANTMENT) + val registry = world.registryManager.getOrThrow(RegistryKeys.ENCHANTMENT) return registry.getOptional(this).orElseThrow { IllegalArgumentException("Unknown enchantment key $this") } } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/SpecialItemExtension.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/SpecialItemExtension.kt new file mode 100644 index 00000000000..1504df9104d --- /dev/null +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/item/SpecialItemExtension.kt @@ -0,0 +1,33 @@ +/* + * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) + * + * Copyright (c) 2015 - 2024 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 . + */ +package net.ccbluex.liquidbounce.utils.item + +import net.ccbluex.liquidbounce.interfaces.ArmorItemAdditions +import net.ccbluex.liquidbounce.interfaces.MiningToolItemAddition +import net.minecraft.item.ArmorItem +import net.minecraft.item.MiningToolItem +import net.minecraft.item.ToolMaterial +import net.minecraft.item.equipment.ArmorMaterial +import net.minecraft.item.equipment.EquipmentType + +fun ArmorItem.material(): ArmorMaterial = (this as ArmorItemAdditions).`liquid_bounce$getMaterial`() + +fun MiningToolItem.material(): ToolMaterial = (this as MiningToolItemAddition).`liquid_bounce$getMaterial`() + +fun ArmorItem.type(): EquipmentType = (this as ArmorItemAdditions).`liquid_bounce$getType`() diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/movement/MovementUtils.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/movement/MovementUtils.kt index 42ad4b10d81..799dbd0143a 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/movement/MovementUtils.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/movement/MovementUtils.kt @@ -41,7 +41,12 @@ data class DirectionalInput( val left: Boolean, val right: Boolean, ) { - constructor(input: Input) : this(input.pressingForward, input.pressingBack, input.pressingLeft, input.pressingRight) + constructor(input: Input) : this( + input.playerInput.forward, + input.playerInput.backward, + input.playerInput.left, + input.playerInput.right + ) override fun equals(other: Any?): Boolean { return other is DirectionalInput && diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/utils/render/TargetRenderer.kt b/src/main/kotlin/net/ccbluex/liquidbounce/utils/render/TargetRenderer.kt index 3bb84fcdc78..a8f7041e9a7 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/utils/render/TargetRenderer.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/utils/render/TargetRenderer.kt @@ -32,7 +32,7 @@ import net.ccbluex.liquidbounce.utils.entity.interpolateCurrentPosition import net.ccbluex.liquidbounce.utils.entity.lastRenderPos import net.ccbluex.liquidbounce.utils.math.plus import net.ccbluex.liquidbounce.utils.render.WorldToScreen.calculateScreenPos -import net.minecraft.client.render.GameRenderer +import net.minecraft.client.gl.ShaderProgramKeys import net.minecraft.client.render.VertexFormat import net.minecraft.client.render.VertexFormats import net.minecraft.client.util.math.MatrixStack @@ -180,7 +180,7 @@ class WorldTargetRenderer(module: ClientModule) : TargetRenderer vertex(matrix, 0.0f, -size, 0.0f) .texture(0.0f, 0.0f) @@ -448,7 +448,7 @@ class OverlayTargetRenderer(module: ClientModule) : TargetRenderer TrajectoryInfo.POTION is TridentEntity -> { - if (!entity.inGround) { + if (!entity.isInGround()) { TrajectoryInfo.TRIDENT } else { null diff --git a/src/main/resources/assets/liquidbounce/post_effect/ui_blur.json b/src/main/resources/assets/liquidbounce/post_effect/ui_blur.json new file mode 100644 index 00000000000..6b3ae344a86 --- /dev/null +++ b/src/main/resources/assets/liquidbounce/post_effect/ui_blur.json @@ -0,0 +1,27 @@ +{ + "targets": { + "swap": {} + }, + "passes": [ + { + "program": "liquidbounce:post/ui_blur", + "inputs": [ + { + "sampler_name": "In", + "target": "minecraft:main" + } + ], + "output": "swap" + }, + { + "program": "minecraft:post/blit", + "inputs": [ + { + "sampler_name": "In", + "target": "swap" + } + ], + "output": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/liquidbounce/shaders/blend.frag b/src/main/resources/assets/liquidbounce/shaders/blend.frag new file mode 100644 index 00000000000..84ce9b9a2d0 --- /dev/null +++ b/src/main/resources/assets/liquidbounce/shaders/blend.frag @@ -0,0 +1,12 @@ +#version 410 core + +in vec2 fragTexCoord; +out vec4 fragColor; + +uniform sampler2D texture0; +uniform vec4 mixColor; + +void main() { + vec4 color = textureLod(texture0, fragTexCoord.xy, 0.0); + fragColor = vec4(mixColor.rgb * mixColor.a + color.rgb * (1.0 - mixColor.a), 1.0); +} diff --git a/src/main/resources/assets/liquidbounce/shaders/outline/entity_outline.frag b/src/main/resources/assets/liquidbounce/shaders/outline/entity_outline.frag new file mode 100644 index 00000000000..10ccb5eddd6 --- /dev/null +++ b/src/main/resources/assets/liquidbounce/shaders/outline/entity_outline.frag @@ -0,0 +1,56 @@ +/** + * Author: ccetl + * Created: 2024 + * License: GPL-3.0 + */ +#version 410 core + +in vec2 fragTexCoord; +out vec4 fragColor; + +uniform sampler2D texture0; + +void main() { + vec2 uv = fragTexCoord.xy; + + vec4 color = textureLod(texture0, uv, 0.0); + if (color.a != 0.0) { + // inside of the entity + discard; + } + + vec2 texelSize = vec2(1.0) / textureSize(texture0, 0).xy; + vec3 outColor = vec3(0.0); + float outAlpha = 0.0; + int iterations = 0; + + for (int ix = -3; ix <= 3; ix++) { + for (int iy = -3; iy <= 3; iy++) { + if (ix == 0 && iy == 0) { + continue; + } + + // 1.0 could changed to some higher value to improve the shader look + // like in the item chams shader + float x = 1.0 * float(ix); + float y = 1.0 * float(iy); + + vec2 offset = vec2(texelSize.x * x, texelSize.y * y); + vec4 positionColor = textureLod(texture0, uv + offset, 0.0); + + float distance = length(vec2(x, y)); + float weight = max(0.0, 1.0 - (distance / 7.08)); + outAlpha += positionColor.a * weight; + if (positionColor.a != 0.0) { + outColor += positionColor.rgb; + iterations++; + } + } + } + + if (outAlpha == 0.0 || iterations == 0) { + discard; + } + + fragColor = vec4(outColor / iterations, outAlpha); +} diff --git a/src/main/resources/assets/liquidbounce/shaders/glow/plane_projection.vert b/src/main/resources/assets/liquidbounce/shaders/plane_projection.vert similarity index 100% rename from src/main/resources/assets/liquidbounce/shaders/glow/plane_projection.vert rename to src/main/resources/assets/liquidbounce/shaders/plane_projection.vert diff --git a/src/main/resources/assets/liquidbounce/shaders/position_tex.vert b/src/main/resources/assets/liquidbounce/shaders/position_tex.vert new file mode 100644 index 00000000000..a4f74693812 --- /dev/null +++ b/src/main/resources/assets/liquidbounce/shaders/position_tex.vert @@ -0,0 +1,11 @@ +#version 410 core + +in vec3 Position; +in vec2 UV0; + +out vec2 fragTexCoord; + +void main() { + gl_Position = vec4(Position, 1.0); + fragTexCoord = UV0; +} diff --git a/src/main/resources/assets/liquidbounce/shaders/post/dithering_shader.json b/src/main/resources/assets/liquidbounce/shaders/post/dithering_shader.json deleted file mode 100644 index 83e8311bb19..00000000000 --- a/src/main/resources/assets/liquidbounce/shaders/post/dithering_shader.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "targets": [ - "swap", - "final" - ], - "passes": [ - { - "name": "dithering_shader", - "intarget": "final", - "outtarget": "swap" - }, - { - "name": "blit", - "intarget": "swap", - "outtarget": "final" - } - ] -} diff --git a/src/main/resources/assets/liquidbounce/shaders/post/outline_shader.json b/src/main/resources/assets/liquidbounce/shaders/post/outline_shader.json deleted file mode 100644 index 92119276671..00000000000 --- a/src/main/resources/assets/liquidbounce/shaders/post/outline_shader.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "targets": [ - "swap", - "final" - ], - "passes": [ - { - "name": "outline_shader", - "intarget": "final", - "outtarget": "swap" - }, - { - "name": "blit", - "intarget": "swap", - "outtarget": "final" - } - ] -} diff --git a/src/main/resources/assets/minecraft/shaders/program/ui_blur.fsh b/src/main/resources/assets/liquidbounce/shaders/post/ui_blur.fsh similarity index 79% rename from src/main/resources/assets/minecraft/shaders/program/ui_blur.fsh rename to src/main/resources/assets/liquidbounce/shaders/post/ui_blur.fsh index 372eb6bb0b9..f0a0cbb378b 100644 --- a/src/main/resources/assets/minecraft/shaders/program/ui_blur.fsh +++ b/src/main/resources/assets/liquidbounce/shaders/post/ui_blur.fsh @@ -1,6 +1,7 @@ #version 150 -uniform sampler2D DiffuseSampler; +uniform sampler2D InSampler; + uniform sampler2D Overlay; in vec2 texCoord; @@ -16,21 +17,20 @@ const vec2 BlurDir = vec2(1.2, 0.8); void main() { vec4 overlay_color = texture(Overlay, texCoord); if (overlay_color.a <= 0.01) { - fragColor = vec4(texture(DiffuseSampler, texCoord).rgb, 1.0); - + fragColor = vec4(texture(InSampler, texCoord).rgb, 1.0); return; } float opacity = clamp((overlay_color.a - 0.1) * 2.0, 0.1, 1.0); - vec4 origColor = texture(DiffuseSampler, texCoord); + vec4 origColor = texture(InSampler, texCoord); vec4 blurred = vec4(0.0); float totalStrength = 0.0; float totalAlpha = 0.0; float totalSamples = 0.0; for(float r = -Radius; r <= Radius; r += 1.0) { - vec4 sampleValue = texture(DiffuseSampler, texCoord + oneTexel * r * BlurDir); + vec4 sampleValue = texture(InSampler, texCoord + oneTexel * r * BlurDir); // Accumulate average alpha totalAlpha = totalAlpha + sampleValue.a; @@ -41,7 +41,7 @@ void main() { totalStrength = totalStrength + strength; blurred = blurred + sampleValue; } - fragColor = vec4(mix(origColor.rgb, blurred.rgb / (Radius * 2.0 + 1.0), opacity), 1.0); + fragColor = vec4(mix(origColor.rgb, blurred.rgb / (Radius * 2.0 + 1.0), opacity), 1.0); } diff --git a/src/main/resources/assets/liquidbounce/shaders/post/ui_blur.json b/src/main/resources/assets/liquidbounce/shaders/post/ui_blur.json index f88cc22231d..c70683c7b04 100644 --- a/src/main/resources/assets/liquidbounce/shaders/post/ui_blur.json +++ b/src/main/resources/assets/liquidbounce/shaders/post/ui_blur.json @@ -1,17 +1,21 @@ { - "targets": [ - "swap" + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "minecraft:post/sobel", + "fragment": "liquidbounce:post/ui_blur", + "attributes": [ "Position" ], + "samplers": [ + { "name": "InSampler" } ], - "passes": [ - { - "name": "ui_blur", - "intarget": "minecraft:main", - "outtarget": "swap" - }, - { - "name": "blit", - "intarget": "swap", - "outtarget": "minecraft:main" - } + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "BlurDir", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "Radius", "type": "float", "count": 1, "values": [ 20.0 ] }, + { "name": "Overlay", "type": "int", "count": 1, "values": [ 1 ] } ] } diff --git a/src/main/resources/assets/liquidbounce/shaders/sobel.vert b/src/main/resources/assets/liquidbounce/shaders/sobel.vert new file mode 100644 index 00000000000..2e7268e2b33 --- /dev/null +++ b/src/main/resources/assets/liquidbounce/shaders/sobel.vert @@ -0,0 +1,12 @@ +#version 150 + +in vec4 Position; +in vec2 UV0; + +out vec2 fragTexCoord; + +void main() { + vec4 outPos = vec4(Position.xy, 0.0, 1.0); + gl_Position = vec4(outPos.xy, 0.2, 1.0); + fragTexCoord = UV0; +} diff --git a/src/main/resources/assets/minecraft/shaders/program/dithering_shader.fsh b/src/main/resources/assets/minecraft/shaders/program/dithering_shader.fsh deleted file mode 100644 index 7ea764b43da..00000000000 --- a/src/main/resources/assets/minecraft/shaders/program/dithering_shader.fsh +++ /dev/null @@ -1,53 +0,0 @@ -// SOURCE: http://devlog-martinsh.blogspot.com/2011/03/glsl-8x8-bayer-matrix-dithering.html - -#version 430 - - -uniform sampler2D DiffuseSampler; - -varying vec2 texCoord; -varying vec2 oneTexel; - -uniform float ditherAmount; - -float floatMod(float a, float b) { - return a - (b * floor(a/b)); -} - - -float find_closest(int x, int y, float c0) { - - int dither[8][8] = { - { 0, 32, 8, 40, 2, 34, 10, 42 }, /* 8x8 Bayer ordered dithering */ - { 48, 16, 56, 24, 50, 18, 58, 26 }, /* pattern. Each input pixel */ - { 12, 44, 4, 36, 14, 46, 6, 38 }, /* is scaled to the 0..63 range */ - { 60, 28, 52, 20, 62, 30, 54, 22 }, /* before looking in this table */ - { 3, 35, 11, 43, 1, 33, 9, 41 }, /* to determine the action. */ - { 51, 19, 59, 27, 49, 17, 57, 25 }, - { 15, 47, 7, 39, 13, 45, 5, 37 }, - { 63, 31, 55, 23, 61, 29, 53, 21 } - }; - - float limit = 0.0; - - if (x < 8){ - limit = (dither[x][y]+1)/64.0; - } - - - if (c0 < limit) - return 0.0; - - return 1.0; -} - -void main() { - int x = int(mod(texCoord.x / oneTexel.x, 8.0)); - int y = int(mod(texCoord.y / oneTexel.y, 8.0)); - - if (find_closest(x, y, ditherAmount) == 0.0) { - discard; - } - - gl_FragColor = texture2D(DiffuseSampler, texCoord.xy); -} diff --git a/src/main/resources/assets/minecraft/shaders/program/dithering_shader.json b/src/main/resources/assets/minecraft/shaders/program/dithering_shader.json deleted file mode 100644 index daf13dbeab2..00000000000 --- a/src/main/resources/assets/minecraft/shaders/program/dithering_shader.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "blend": { - "func": "add", - "srcrgb": "srcalpha", - "dstrgb": "1-srcalpha" - }, - "vertex": "sobel", - "fragment": "dithering_shader", - "attributes": [ - "Position" - ], - "samplers": [ - { - "name": "DiffuseSampler" - } - ], - "uniforms": [ - { - "name": "ProjMat", - "type": "matrix4x4", - "count": 16, - "values": [ - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - { - "name": "InSize", - "type": "float", - "count": 2, - "values": [ - 1.0, - 1.0 - ] - }, - { - "name": "OutSize", - "type": "float", - "count": 2, - "values": [ - 1.0, - 1.0 - ] - }, - { - "name": "ditherAmount", - "type": "float", - "count": 1, - "values": [ - 1.0 - ] - } - ] -} diff --git a/src/main/resources/assets/minecraft/shaders/program/outline_shader.fsh b/src/main/resources/assets/minecraft/shaders/program/outline_shader.fsh deleted file mode 100644 index c4b360b85e4..00000000000 --- a/src/main/resources/assets/minecraft/shaders/program/outline_shader.fsh +++ /dev/null @@ -1,30 +0,0 @@ -#version 120 - -uniform sampler2D DiffuseSampler; - -varying vec2 texCoord; -varying vec2 oneTexel; - -uniform float radius; - -void main(void) { - vec4 centerCol = texture2D(DiffuseSampler, texCoord.xy); - - if (centerCol.a != 0) { - discard; - } - - vec4 finalColor = vec4(0.0); - - for (float x = -radius; x <= radius; x += 0.5) { - for (float y = -radius; y <= radius; y += 0.5) { - vec2 offset = vec2(oneTexel.x * x, oneTexel.y * y); - vec4 currentColor = texture2D(DiffuseSampler, texCoord.xy + offset); - - float weight = smoothstep(0.0, 1.0, radius - length(offset)); - finalColor += currentColor * weight; - } - } - - gl_FragColor = finalColor; -} diff --git a/src/main/resources/assets/minecraft/shaders/program/outline_shader.json b/src/main/resources/assets/minecraft/shaders/program/outline_shader.json deleted file mode 100644 index 788717a95c7..00000000000 --- a/src/main/resources/assets/minecraft/shaders/program/outline_shader.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "blend": { - "func": "add", - "srcrgb": "srcalpha", - "dstrgb": "1-srcalpha" - }, - "vertex": "sobel", - "fragment": "outline_shader", - "attributes": [ - "Position" - ], - "samplers": [ - { - "name": "DiffuseSampler" - } - ], - "uniforms": [ - { - "name": "ProjMat", - "type": "matrix4x4", - "count": 16, - "values": [ - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - { - "name": "InSize", - "type": "float", - "count": 2, - "values": [ - 1.0, - 1.0 - ] - }, - { - "name": "OutSize", - "type": "float", - "count": 2, - "values": [ - 1.0, - 1.0 - ] - }, - { - "name": "radius", - "type": "float", - "count": 1, - "values": [ - 1.0 - ] - } - ] -} diff --git a/src/main/resources/assets/minecraft/shaders/program/ui_blur.json b/src/main/resources/assets/minecraft/shaders/program/ui_blur.json deleted file mode 100644 index e92b7ecf12d..00000000000 --- a/src/main/resources/assets/minecraft/shaders/program/ui_blur.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "blend": { - "func": "add", - "srcrgb": "one", - "dstrgb": "zero" - }, - "vertex": "sobel", - "fragment": "ui_blur", - "attributes": [ "Position" ], - "samplers": [ - { "name": "DiffuseSampler" }, - { "name": "Overlay" } - ], - "uniforms": [ - { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, - { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, - { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, - { "name": "BlurDir", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, - { "name": "Radius", "type": "float", "count": 1, "values": [ 20.0 ] } - ] -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a494a0ca35e..863eaf54bd0 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,7 +30,7 @@ "liquidbounce.mixins.json" ], "depends": { - "minecraft": ["1.21", "${minecraft_version}"], + "minecraft": ["${minecraft_version}"], "fabricloader": ">=${min_loader_version}", "fabric-language-kotlin": ">=${fabric_kotlin_version}" }, diff --git a/src/main/resources/liquidbounce.accesswidener b/src/main/resources/liquidbounce.accesswidener index 5b826734f17..a2c968f2482 100644 --- a/src/main/resources/liquidbounce.accesswidener +++ b/src/main/resources/liquidbounce.accesswidener @@ -23,8 +23,6 @@ mutable field net/minecraft/network/packet/c2s/common/KeepAliveC2SPacket id J accessible field net/minecraft/network/packet/c2s/common/KeepAliveC2SPacket id J accessible field net/minecraft/network/packet/c2s/play/ChatMessageC2SPacket chatMessage Ljava/lang/String; -accessible field net/minecraft/server/network/ServerPlayerEntity joinInvulnerabilityTicks I - accessible field net/minecraft/client/network/ClientPlayerEntity lastX D accessible field net/minecraft/client/network/ClientPlayerEntity lastBaseY D accessible field net/minecraft/client/network/ClientPlayerEntity lastZ D @@ -71,7 +69,7 @@ accessible field net/minecraft/client/option/KeyBinding boundKey Lnet/minecraft/ accessible field net/minecraft/entity/LivingEntity lastAttackedTicks I accessible field net/minecraft/entity/LivingEntity jumping Z accessible field net/minecraft/entity/LivingEntity jumpingCooldown I -accessible field net/minecraft/entity/projectile/PersistentProjectileEntity inGround Z +accessible method net/minecraft/entity/Entity isAlwaysInvulnerableTo (Lnet/minecraft/entity/damage/DamageSource;)Z accessible field net/minecraft/client/option/GameOptions enabledPlayerModelParts Ljava/util/Set; @@ -89,23 +87,12 @@ mutable field net/minecraft/network/packet/s2c/play/EntityVelocityUpdateS2CPacke mutable field net/minecraft/network/packet/s2c/play/EntityVelocityUpdateS2CPacket velocityY I mutable field net/minecraft/network/packet/s2c/play/EntityVelocityUpdateS2CPacket velocityZ I -accessible field net/minecraft/network/packet/s2c/play/ExplosionS2CPacket playerVelocityX F -accessible field net/minecraft/network/packet/s2c/play/ExplosionS2CPacket playerVelocityY F -accessible field net/minecraft/network/packet/s2c/play/ExplosionS2CPacket playerVelocityZ F - -mutable field net/minecraft/network/packet/s2c/play/ExplosionS2CPacket playerVelocityX F -mutable field net/minecraft/network/packet/s2c/play/ExplosionS2CPacket playerVelocityY F -mutable field net/minecraft/network/packet/s2c/play/ExplosionS2CPacket playerVelocityZ F - accessible field net/minecraft/client/world/ClientChunkManager chunks Lnet/minecraft/client/world/ClientChunkManager$ClientChunkMap; accessible field net/minecraft/world/chunk/WorldChunk loadedToWorld Z accessible field net/minecraft/client/world/ClientChunkManager$ClientChunkMap chunks Ljava/util/concurrent/atomic/AtomicReferenceArray; -accessible field net/minecraft/client/render/WorldRenderer entityOutlinesFramebuffer Lnet/minecraft/client/gl/Framebuffer; accessible field net/minecraft/client/render/WorldRenderer blockBreakingProgressions Lit/unimi/dsi/fastutil/longs/Long2ObjectMap; -accessible method net/minecraft/world/World getDestructionType (Lnet/minecraft/world/GameRules$Key;)Lnet/minecraft/world/explosion/Explosion$DestructionType; - accessible field net/minecraft/entity/projectile/ProjectileEntity ownerUuid Ljava/util/UUID; accessible method net/minecraft/entity/LivingEntity getJumpVelocity ()F @@ -116,8 +103,6 @@ accessible field net/minecraft/entity/mob/CreeperEntity explosionRadius I accessible method net/minecraft/client/render/Camera setPos (DDD)V accessible method net/minecraft/client/render/Camera setPos (Lnet/minecraft/util/math/Vec3d;)V -accessible method net/minecraft/client/render/GameRenderer loadPostProcessor (Lnet/minecraft/util/Identifier;)V - accessible method net/minecraft/client/network/ClientPlayerInteractionManager sendSequencedPacket (Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/client/network/SequencedPacketCreator;)V accessible field net/minecraft/client/gui/screen/ingame/CreativeInventoryScreen selectedTab Lnet/minecraft/item/ItemGroup; @@ -150,9 +135,6 @@ accessible field net/minecraft/client/gui/hud/PlayerListHud footer Lnet/minecraf accessible class net/minecraft/client/render/OutlineVertexConsumerProvider$OutlineVertexConsumer accessible method net/minecraft/client/render/OutlineVertexConsumerProvider$OutlineVertexConsumer (Lnet/minecraft/client/render/VertexConsumer;IIII)V -accessible field net/minecraft/client/texture/PlayerSkinTexture url Ljava/lang/String; -accessible field net/minecraft/client/texture/PlayerSkinTexture cacheFile Ljava/io/File; - accessible field net/minecraft/network/packet/s2c/common/CommonPingS2CPacket parameter I mutable field net/minecraft/network/packet/s2c/common/CommonPingS2CPacket parameter I @@ -179,11 +161,19 @@ accessible field net/minecraft/util/math/Direction HORIZONTAL [Lnet/minecraft/ut accessible field net/minecraft/client/util/InputUtil$Type map Lit/unimi/dsi/fastutil/ints/Int2ObjectMap; -accessible field net/minecraft/network/packet/c2s/play/PlayerInputC2SPacket sneaking Z -mutable field net/minecraft/network/packet/c2s/play/PlayerInputC2SPacket sneaking Z - accessible method net/minecraft/client/network/ClientPlayerInteractionManager syncSelectedSlot ()V accessible method net/minecraft/block/EntityShapeContext (ZDLnet/minecraft/item/ItemStack;Ljava/util/function/Predicate;Lnet/minecraft/entity/Entity;)V accessible method net/minecraft/entity/Entity unsetRemoved ()V + +accessible field net/minecraft/client/render/WorldRenderer framebufferSet Lnet/minecraft/client/render/DefaultFramebufferSet; + +accessible method net/minecraft/entity/projectile/PersistentProjectileEntity isInGround ()Z + +accessible method net/minecraft/block/AbstractBlock getPickStack (Lnet/minecraft/world/WorldView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Z)Lnet/minecraft/item/ItemStack; + +accessible method net/minecraft/client/texture/NativeImage write (Ljava/nio/channels/WritableByteChannel;)Z + +accessible field net/minecraft/client/render/LightmapTextureManager lightmapFramebuffer Lnet/minecraft/client/gl/SimpleFramebuffer; +accessible field net/minecraft/client/render/WorldRenderer entityOutlineFramebuffer Lnet/minecraft/client/gl/Framebuffer; diff --git a/src/main/resources/liquidbounce.mixins.json b/src/main/resources/liquidbounce.mixins.json index 586b4410fa9..179325edce2 100644 --- a/src/main/resources/liquidbounce.mixins.json +++ b/src/main/resources/liquidbounce.mixins.json @@ -7,6 +7,7 @@ "mixinPriority": 1337, "client": [ "authlib.MixinMinecraftClient", + "blaze3d.MixinRenderSystem", "minecraft.block.MixinBlock", "minecraft.block.MixinBlockCollisionSpliterator", "minecraft.block.MixinBlockView", @@ -35,7 +36,6 @@ "minecraft.entity.MixinClientPlayerEntity", "minecraft.entity.MixinEntity", "minecraft.entity.MixinLivingEntity", - "minecraft.entity.MixinOtherClientPlayerEntity", "minecraft.entity.MixinPlayerEntity", "minecraft.entity.MixinPlayerEntityAccessor", "minecraft.fluid.MixinFlowableFluid", @@ -48,7 +48,6 @@ "minecraft.gui.MixinPlayerListHud", "minecraft.gui.MixinScoreboard", "minecraft.gui.MixinScreen", - "minecraft.gui.MixinSignText", "minecraft.gui.MixinSplashOverlay", "minecraft.gui.MixinStringHelper", "minecraft.gui.custom.MixinConnectScreen", @@ -78,17 +77,19 @@ "minecraft.render.MixinEntityRenderDispatcher", "minecraft.render.MixinEntityRenderer", "minecraft.render.MixinGameRenderer", + "minecraft.render.MixinInactivityFpsLimiter", "minecraft.render.MixinInGameOverlayRenderer", "minecraft.render.MixinItemRender", "minecraft.render.MixinLightmapTextureManager", "minecraft.render.MixinLivingEntityRenderer", "minecraft.render.MixinOutlineVertexConsumerProvider", "minecraft.render.MixinPlayerEntityRenderer", - "minecraft.render.MixinPostEffectPass", "minecraft.render.MixinRenderTickCounter", "minecraft.render.MixinSignText", "minecraft.render.MixinTextRenderer", + "minecraft.render.MixinWeatherRendering", "minecraft.render.MixinWorldRenderer", + "minecraft.render.entity.MixinEntityRenderState", "minecraft.render.entity.feature.MixinDeadmau5FeatureRenderer", "minecraft.text.MixinChatHudLine", "minecraft.text.MixinChatHudLineVisible", @@ -99,6 +100,8 @@ "truffle.MixinHostClassDesc", "truffle.MixinHostClassLoader", "truffle.MixinHostContext", + "minecraft.item.MixinArmorItem", + "minecraft.item.MixinMiningToolItem", "truffle.MixinTruffleLanguage" ], "server": [],