Skip to content

Commit 282f90f

Browse files
committed
Merge branch '1.21.5' into feature/manager-loggers
# Conflicts: # src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt # src/main/kotlin/com/lambda/interaction/construction/context/BreakContext.kt # src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt # src/main/kotlin/com/lambda/interaction/request/placing/PlaceManager.kt
2 parents f8beaff + 0315755 commit 282f90f

File tree

71 files changed

+1584
-1557
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1584
-1557
lines changed

src/main/java/com/lambda/mixin/MinecraftClientMixin.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
package com.lambda.mixin;
1919

20-
import com.lambda.Lambda;
2120
import com.lambda.event.EventFlow;
2221
import com.lambda.event.events.ClientEvent;
2322
import com.lambda.event.events.InventoryEvent;
2423
import com.lambda.event.events.TickEvent;
2524
import com.lambda.gui.DearImGui;
2625
import com.lambda.module.modules.player.Interact;
26+
import com.lambda.module.modules.player.InventoryMove;
2727
import com.lambda.module.modules.player.PacketMine;
2828
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
2929
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
@@ -33,6 +33,7 @@
3333
import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider;
3434
import net.minecraft.client.network.ClientPlayerEntity;
3535
import net.minecraft.client.network.ClientPlayerInteractionManager;
36+
import net.minecraft.client.option.KeyBinding;
3637
import net.minecraft.client.render.WorldRenderer;
3738
import net.minecraft.client.sound.SoundManager;
3839
import net.minecraft.util.Hand;
@@ -51,10 +52,14 @@ public class MinecraftClientMixin {
5152
@Shadow
5253
@Nullable
5354
public Screen currentScreen;
55+
5456
@Shadow
5557
@Nullable
5658
public HitResult crosshairTarget;
5759

60+
@Shadow
61+
public int itemUseCooldown;
62+
5863
@Inject(method = "close", at = @At("HEAD"))
5964
void closeImGui(CallbackInfo ci) {
6065
DearImGui.INSTANCE.destroy();
@@ -131,6 +136,19 @@ private void onScreenRemove(@Nullable Screen screen, CallbackInfo ci) {
131136
}
132137
}
133138

139+
@Redirect(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;unpressAll()V"))
140+
private void redirectUnPressAll() {
141+
if (!InventoryMove.getShouldMove()) {
142+
KeyBinding.unpressAll();
143+
return;
144+
}
145+
KeyBinding.KEYS_BY_ID.values().forEach(bind -> {
146+
if (!InventoryMove.isKeyMovementRelated(bind.boundKey.getCode())) {
147+
bind.reset();
148+
}
149+
});
150+
}
151+
134152
@Redirect(method = "doAttack()Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
135153
private void redirectHandSwing(ClientPlayerEntity instance, Hand hand) {
136154
if (this.crosshairTarget == null) return;
@@ -151,6 +169,6 @@ boolean redirectMultiActon(ClientPlayerInteractionManager instance) {
151169
void injectFastPlace(CallbackInfo ci) {
152170
if (!Interact.INSTANCE.isEnabled()) return;
153171

154-
Lambda.getMc().itemUseCooldown = Interact.getPlaceDelay();
172+
itemUseCooldown = Interact.getPlaceDelay();
155173
}
156174
}

src/main/java/com/lambda/mixin/baritone/MixinLookBehavior.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void onTargetUpdate(Rotation rotation, boolean blockInteract, CallbackInfo ci) {
3636
LookBehavior instance = ((LookBehavior) (Object) this);
3737
if (instance.baritone != BaritoneUtils.getPrimary()) return;
3838

39-
RotationManager.BaritoneProcessor.handleBaritoneRotation(rotation.getYaw(), rotation.getPitch());
39+
RotationManager.handleBaritoneRotation(rotation.getYaw(), rotation.getPitch());
4040
ci.cancel();
4141
}
4242

src/main/java/com/lambda/mixin/entity/ClientPlayerEntityMixin.java

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import net.minecraft.client.world.ClientWorld;
3838
import net.minecraft.entity.MovementType;
3939
import net.minecraft.util.Hand;
40-
import net.minecraft.util.math.MathHelper;
4140
import net.minecraft.util.math.Vec3d;
4241
import org.spongepowered.asm.mixin.Final;
4342
import org.spongepowered.asm.mixin.Mixin;
@@ -60,80 +59,50 @@ public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile) {
6059
super(world, profile);
6160
}
6261

63-
@Shadow protected abstract void autoJump(float dx, float dz);
64-
65-
/**
66-
* Post movement events and applies the modified player velocity
67-
*/
68-
@Inject(method = "move", at = @At("HEAD"), cancellable = true)
69-
void onMove(MovementType movementType, Vec3d movement, CallbackInfo ci) {
70-
ClientPlayerEntity self = (ClientPlayerEntity) (Object) this;
71-
if (self != Lambda.getMc().player) return;
72-
73-
ci.cancel();
74-
75-
float prevX = (float) self.getX();
76-
float prevZ = (float) self.getZ();
77-
62+
@Redirect(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;move(Lnet/minecraft/entity/MovementType;Lnet/minecraft/util/math/Vec3d;)V"))
63+
private void emitMovementEvents(AbstractClientPlayerEntity instance, MovementType movementType, Vec3d movement) {
7864
EventFlow.post(new MovementEvent.Player.Pre(movementType, movement));
7965
super.move(movementType, movement);
8066
EventFlow.post(new MovementEvent.Player.Post(movementType, movement));
81-
82-
float deltaX = (float) self.getX() - prevX;
83-
float deltaZ = (float) self.getZ() - prevZ;
84-
85-
this.autoJump(deltaX, deltaZ);
86-
this.distanceMoved = this.distanceMoved + MathHelper.hypot(deltaX, deltaZ) * 0.6F;
8767
}
8868

8969
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick()V"))
9070
void processMovement(Input input) {
9171
input.tick();
9272
RotationManager.processRotations();
93-
RotationManager.BaritoneProcessor.processPlayerMovement(input);
73+
RotationManager.redirectStrafeInputs(input);
9474
EventFlow.post(new MovementEvent.InputUpdate(input));
9575
}
9676

9777
/**
98-
* Posts the {@link MovementEvent.Sprint} event
99-
* <pre>{@code
100-
* if (this.isSprinting()) {
101-
* boolean bl8 = !this.input.hasForwardMovement() || !this.canSprint();
102-
* boolean bl9 = bl8 || this.horizontalCollision && !this.collidedSoftly || this.isTouchingWater() && !this.isSubmergedInWater();
103-
* if (this.isSwimming()) {
104-
* if (!this.isOnGround() && !this.input.sneaking && bl8 || !this.isTouchingWater()) {
105-
* this.setSprinting(false);
106-
* }
107-
* } else if (bl9) {
108-
* this.setSprinting(false);
109-
* }
110-
* }
111-
* }</pre>
78+
* Overwrites the movement packet update function to use our code
11279
*/
80+
@Inject(method = "sendMovementPackets", at = @At(value = "HEAD"), cancellable = true)
81+
void sendLambdaMovement(CallbackInfo ci) {
82+
ci.cancel();
83+
PlayerPacketManager.sendPlayerPackets();
84+
autoJumpEnabled = Lambda.getMc().options.getAutoJump().getValue();
85+
}
86+
87+
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendSneakingPacket()V"))
88+
void sendSneakingPacket(ClientPlayerEntity entity) {
89+
PlayerPacketManager.sendSneakPackets();
90+
}
91+
11392
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSprinting()Z"))
11493
boolean isSprinting(ClientPlayerEntity entity) {
11594
return EventFlow.post(new MovementEvent.Sprint(entity.isSprinting())).getSprint();
11695
}
11796

11897
@Inject(method = "isSneaking", at = @At(value = "HEAD"), cancellable = true)
119-
void redirectSneaking(CallbackInfoReturnable<Boolean> cir) {
98+
void injectSneakingInput(CallbackInfoReturnable<Boolean> cir) {
12099
ClientPlayerEntity self = (ClientPlayerEntity) (Object) this;
121100
if (self != Lambda.getMc().player) return;
122101

123102
if (self.input == null) return;
124103
cir.setReturnValue(EventFlow.post(new MovementEvent.Sneak(self.input.playerInput.sneak())).getSneak());
125104
}
126105

127-
/**
128-
* Overwrites the movement packet update function to use our code
129-
*/
130-
@Inject(method = "sendMovementPackets", at = @At(value = "HEAD"), cancellable = true)
131-
void sendBegin(CallbackInfo ci) {
132-
ci.cancel();
133-
PlayerPacketManager.sendPlayerPackets();
134-
autoJumpEnabled = Lambda.getMc().options.getAutoJump().getValue();
135-
}
136-
137106
@WrapMethod(method = "tick")
138107
void onTick(Operation<Void> original) {
139108
EventFlow.post(TickEvent.Player.Pre.INSTANCE);

src/main/java/com/lambda/mixin/input/KeyboardMixin.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919

2020
import com.lambda.event.EventFlow;
2121
import com.lambda.event.events.KeyboardEvent;
22+
import com.lambda.module.modules.player.InventoryMove;
2223
import net.minecraft.client.Keyboard;
24+
import net.minecraft.client.option.KeyBinding;
25+
import net.minecraft.client.util.InputUtil;
2326
import org.spongepowered.asm.mixin.Mixin;
2427
import org.spongepowered.asm.mixin.injection.At;
2528
import org.spongepowered.asm.mixin.injection.Inject;
@@ -32,6 +35,13 @@ private void onKey(long window, int key, int scancode, int action, int modifiers
3235
EventFlow.post(new KeyboardEvent.Press(key, scancode, action, modifiers));
3336
}
3437

38+
@Inject(method = "onKey", at = @At("RETURN"))
39+
private void onKeyTail(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) {
40+
if (!InventoryMove.getShouldMove() || !InventoryMove.isKeyMovementRelated(key)) return;
41+
InputUtil.Key fromCode = InputUtil.fromKeyCode(key, scancode);
42+
KeyBinding.setKeyPressed(fromCode, action != 0);
43+
}
44+
3545
@Inject(method = "onChar", at = @At("HEAD"))
3646
private void onChar(long window, int codePoint, int modifiers, CallbackInfo ci) {
3747
char[] chars = Character.toChars(codePoint);

src/main/java/com/lambda/mixin/render/LivingEntityRendererMixin.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
2424
import net.minecraft.client.render.entity.LivingEntityRenderer;
2525
import net.minecraft.entity.LivingEntity;
26+
import org.jetbrains.annotations.Nullable;
2627
import org.spongepowered.asm.mixin.Mixin;
2728
import org.spongepowered.asm.mixin.injection.At;
2829

29-
import java.util.Objects;
30+
import static com.lambda.util.math.LinearKt.lerp;
3031

3132
// This mixin's purpose is to set the player's pitch the current render pitch to correctly show the rotation
3233
// regardless of the camera position
@@ -48,9 +49,12 @@ public class LivingEntityRendererMixin {
4849
* }</pre>
4950
*/
5051
@WrapOperation(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"))
51-
private float wrapGetLerpedPitch(LivingEntity instance, float v, Operation<Float> original) {
52-
return (instance == Lambda.getMc().player)
53-
? Objects.requireNonNullElse(RotationManager.getHeadPitch(), original.call(instance, v))
54-
: original.call(instance, v);
52+
private float wrapGetLerpedPitch(LivingEntity livingEntity, float v, Operation<Float> original) {
53+
Float headPitch = RotationManager.getHeadPitch();
54+
if (livingEntity != Lambda.getMc().player || headPitch == null) {
55+
return original.call(livingEntity, v);
56+
}
57+
58+
return lerp(v, RotationManager.getPrevServerRotation().getPitchF(), headPitch);
5559
}
5660
}

src/main/kotlin/com/lambda/config/AbstractSetting.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ abstract class AbstractSetting<T : Any>(
158158
groups.add(path.toList())
159159
}
160160

161+
fun group(path: NamedEnum?) = apply {
162+
path?.let { groups.add(listOf(it)) }
163+
}
164+
161165
fun reset(silent: Boolean = false) {
162166
if (!silent && value == defaultValue) {
163167
ConfigCommand.info(notChangedMessage())

src/main/kotlin/com/lambda/config/groups/RotationSettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import kotlin.random.Random
3030

3131
class RotationSettings(
3232
c: Configurable,
33-
baseGroup: NamedEnum,
33+
baseGroup: NamedEnum? = null,
3434
vis: () -> Boolean = { true }
3535
) : RotationConfig {
3636
override var rotationMode by c.setting("Mode", RotationMode.Sync, "How the player is being rotated on interaction", vis).group(baseGroup)

src/main/kotlin/com/lambda/config/groups/Targeting.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,33 +60,33 @@ abstract class Targeting(
6060
* The range within which entities can be targeted. This value is configurable and constrained
6161
* between 1.0 and [maxRange].
6262
*/
63-
override val targetingRange by owner.setting("Targeting Range", defaultRange, 1.0..maxRange, 0.05) { predicate() }
63+
override val targetingRange by owner.setting("Targeting Range", defaultRange, 1.0..maxRange, 0.05) { predicate() }.group(baseGroup)
6464

6565
/**
6666
* Whether players are included in the targeting scope.
6767
*/
68-
override val players by owner.setting("Players", true) { predicate() }
68+
override val players by owner.setting("Players", true) { predicate() }.group(baseGroup)
6969

7070
/**
7171
* Whether friends are included in the targeting scope.
7272
* Requires [players] to be true.
7373
*/
74-
override val friends by owner.setting("Friends", false) { predicate() && players }
74+
override val friends by owner.setting("Friends", false) { predicate() && players }.group(baseGroup)
7575

7676
/**
7777
* Whether mobs are included in the targeting scope.
7878
*/
79-
private val mobs by owner.setting("Mobs", true) { predicate() }
79+
private val mobs by owner.setting("Mobs", true) { predicate() }.group(baseGroup)
8080

8181
/**
8282
* Whether hostile mobs are included in the targeting scope
8383
*/
84-
private val hostilesSetting by owner.setting("Hostiles", true) { predicate() && mobs }
84+
private val hostilesSetting by owner.setting("Hostiles", true) { predicate() && mobs }.group(baseGroup)
8585

8686
/**
8787
* Whether passive animals are included in the targeting scope
8888
*/
89-
private val animalsSetting by owner.setting("Animals", true) { predicate() && mobs }
89+
private val animalsSetting by owner.setting("Animals", true) { predicate() && mobs }.group(baseGroup)
9090

9191
/**
9292
* Indicates whether hostile entities are included in the targeting scope.
@@ -101,12 +101,12 @@ abstract class Targeting(
101101
/**
102102
* Whether invisible entities are included in the targeting scope.
103103
*/
104-
override val invisible by owner.setting("Invisible", true) { predicate() }
104+
override val invisible by owner.setting("Invisible", true) { predicate() }.group(baseGroup)
105105

106106
/**
107107
* Whether dead entities are included in the targeting scope.
108108
*/
109-
override val dead by owner.setting("Dead", false) { predicate() }
109+
override val dead by owner.setting("Dead", false) { predicate() }.group(baseGroup)
110110

111111
/**
112112
* Validates whether a given entity is targetable by the player based on current settings.
@@ -144,7 +144,7 @@ abstract class Targeting(
144144
/**
145145
* The field of view limit for targeting entities. Configurable between 5 and 180 degrees.
146146
*/
147-
val fov by owner.setting("FOV Limit", 180, 5..180, 1) { predicate() }.group(baseGroup)
147+
val fov by owner.setting("FOV Limit", 180, 5..180, 1) { predicate() && priority == Priority.FOV }.group(baseGroup)
148148

149149
/**
150150
* The priority used to determine which entity is targeted. Configurable with default set to [Priority.DISTANCE].

src/main/kotlin/com/lambda/event/events/PlayerPacketEvent.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ sealed class PlayerPacketEvent {
3030
var rotation: Rotation,
3131
var onGround: Boolean,
3232
var isSprinting: Boolean,
33-
var isSneaking: Boolean,
3433
var isCollidingHorizontally: Boolean,
3534
) : ICancellable by Cancellable()
3635

src/main/kotlin/com/lambda/event/events/RenderEvent.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@
1717

1818
package com.lambda.event.events
1919

20+
import com.lambda.context.SafeContext
2021
import com.lambda.event.Event
2122
import com.lambda.event.callback.Cancellable
2223
import com.lambda.event.callback.ICancellable
23-
import com.lambda.graphics.renderer.esp.global.DynamicESP
24-
import com.lambda.graphics.renderer.esp.global.StaticESP
24+
import com.lambda.event.listener.SafeListener.Companion.listen
25+
import com.lambda.graphics.renderer.esp.ShapeBuilder
26+
import com.lambda.graphics.renderer.esp.Treed
2527

26-
sealed class RenderEvent {
27-
class World : Event
28-
29-
class StaticESP : Event {
30-
val renderer = StaticESP
31-
}
28+
fun Any.onStaticRender(block: SafeContext.(ShapeBuilder) -> Unit) =
29+
listen<RenderEvent.Upload> { block(ShapeBuilder(Treed.Static.faceBuilder, Treed.Static.edgeBuilder)) }
30+
fun Any.onDynamicRender(block: SafeContext.(ShapeBuilder) -> Unit) =
31+
listen<RenderEvent.Upload> { block(ShapeBuilder(Treed.Dynamic.faceBuilder, Treed.Dynamic.edgeBuilder)) }
3232

33-
class DynamicESP : Event {
34-
val renderer = DynamicESP
35-
}
33+
sealed class RenderEvent {
34+
object Upload : Event
35+
object Render : Event
3636

3737
class UpdateTarget : ICancellable by Cancellable()
3838
}

0 commit comments

Comments
 (0)