Skip to content

Commit af92d25

Browse files
committed
Merge remote-tracking branch 'origin/1.21.5' into feature/module/ElytraAttitudeControl
2 parents 9a8f58a + 1a0977b commit af92d25

File tree

209 files changed

+3089
-2840
lines changed

Some content is hidden

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

209 files changed

+3089
-2840
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ modVersion=0.0.1
2222
modDescription=Minecraft utility mod for automation
2323
modIcon=assets/lambda/lambda.png
2424
mavenGroup=com.lambda
25-
modAuthors=Avanatiker, Blade, beanbag44, Emy
25+
modAuthors=Constructor (Avanatiker), Blade, beanbag44, Emy
2626

2727
# General
2828
minecraftVersion=1.21.5

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import com.lambda.module.modules.player.InventoryMove;
3030
import com.lambda.module.modules.player.PacketMine;
3131
import com.lambda.util.WindowUtils;
32+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
33+
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
3234
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
3335
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
3436
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
@@ -49,7 +51,6 @@
4951
import org.spongepowered.asm.mixin.Unique;
5052
import org.spongepowered.asm.mixin.injection.At;
5153
import org.spongepowered.asm.mixin.injection.Inject;
52-
import org.spongepowered.asm.mixin.injection.Redirect;
5354
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
5455

5556
@Mixin(value = MinecraftClient.class, priority = Integer.MAX_VALUE)
@@ -154,10 +155,10 @@ private void onScreenRemove(@Nullable Screen screen, CallbackInfo ci) {
154155
}
155156
}
156157

157-
@Redirect(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;unpressAll()V"))
158-
private void redirectUnPressAll() {
158+
@WrapOperation(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;unpressAll()V"))
159+
private void redirectUnPressAll(Operation<Void> original) {
159160
if (!InventoryMove.getShouldMove()) {
160-
KeyBinding.unpressAll();
161+
original.call();
161162
return;
162163
}
163164
KeyBinding.KEYS_BY_ID.values().forEach(bind -> {
@@ -167,20 +168,16 @@ private void redirectUnPressAll() {
167168
});
168169
}
169170

170-
@Redirect(method = "doAttack()Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
171-
private void redirectHandSwing(ClientPlayerEntity instance, Hand hand) {
172-
if (this.crosshairTarget == null) return;
173-
if (this.crosshairTarget.getType() != HitResult.Type.BLOCK || PacketMine.INSTANCE.isDisabled()) {
174-
instance.swingHand(hand);
175-
}
171+
@WrapWithCondition(method = "doAttack()Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
172+
private boolean redirectHandSwing(ClientPlayerEntity instance, Hand hand) {
173+
if (this.crosshairTarget == null) return false;
174+
return this.crosshairTarget.getType() != HitResult.Type.BLOCK || PacketMine.INSTANCE.isDisabled();
176175
}
177176

178-
@Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isBreakingBlock()Z"))
179-
boolean redirectMultiActon(ClientPlayerInteractionManager instance) {
180-
if (instance == null) return true;
181-
177+
@ModifyExpressionValue(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isBreakingBlock()Z"))
178+
boolean redirectMultiActon(boolean original) {
182179
if (Interact.INSTANCE.isEnabled() && Interact.getMultiAction()) return false;
183-
return instance.isBreakingBlock();
180+
return original;
184181
}
185182

186183
@Inject(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isRiding()Z"))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import baritone.api.utils.Rotation;
2222
import baritone.utils.player.BaritonePlayerContext;
2323
import com.lambda.interaction.BaritoneManager;
24-
import com.lambda.interaction.request.rotating.RotationManager;
24+
import com.lambda.interaction.managers.rotating.RotationManager;
2525
import org.spongepowered.asm.mixin.Final;
2626
import org.spongepowered.asm.mixin.Mixin;
2727
import org.spongepowered.asm.mixin.Shadow;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import baritone.api.utils.Rotation;
2323
import baritone.behavior.LookBehavior;
2424
import com.lambda.interaction.BaritoneManager;
25-
import com.lambda.interaction.request.rotating.RotationManager;
25+
import com.lambda.interaction.managers.rotating.RotationManager;
2626
import org.spongepowered.asm.mixin.Mixin;
2727
import org.spongepowered.asm.mixin.injection.At;
2828
import org.spongepowered.asm.mixin.injection.Inject;

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@
2020
import com.lambda.event.EventFlow;
2121
import com.lambda.event.events.InventoryEvent;
2222
import com.lambda.event.events.PlayerEvent;
23+
import com.lambda.interaction.managers.inventory.InventoryManager;
24+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
25+
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
26+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
2327
import net.minecraft.client.network.ClientPlayerEntity;
2428
import net.minecraft.client.network.ClientPlayerInteractionManager;
29+
import net.minecraft.client.recipebook.ClientRecipeBook;
30+
import net.minecraft.client.world.ClientWorld;
2531
import net.minecraft.entity.Entity;
2632
import net.minecraft.entity.player.PlayerEntity;
2733
import net.minecraft.entity.player.PlayerInventory;
2834
import net.minecraft.screen.slot.SlotActionType;
35+
import net.minecraft.stat.StatHandler;
2936
import net.minecraft.util.ActionResult;
3037
import net.minecraft.util.Hand;
3138
import net.minecraft.util.hit.BlockHitResult;
@@ -36,13 +43,11 @@
3643
import org.spongepowered.asm.mixin.Shadow;
3744
import org.spongepowered.asm.mixin.injection.At;
3845
import org.spongepowered.asm.mixin.injection.Inject;
39-
import org.spongepowered.asm.mixin.injection.Redirect;
4046
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
4147
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
4248

4349
@Mixin(ClientPlayerInteractionManager.class)
4450
public class ClientPlayInteractionManagerMixin {
45-
4651
@Shadow
4752
public float currentBreakingProgress;
4853

@@ -98,9 +103,9 @@ public void clickSlotHead(int syncId, int slotId, int button, SlotActionType act
98103
* }
99104
* }</pre>
100105
*/
101-
@Redirect(method = "syncSelectedSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;getSelectedSlot()I"))
102-
public int overrideSelectedSlotSync(PlayerInventory instance) {
103-
return EventFlow.post(new InventoryEvent.HotbarSlot.Update(instance.getSelectedSlot())).getSlot();
106+
@ModifyExpressionValue(method = "syncSelectedSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;getSelectedSlot()I"))
107+
public int overrideSelectedSlotSync(int original) {
108+
return EventFlow.post(new InventoryEvent.HotbarSlot.Update(original)).getSlot();
104109
}
105110

106111
@Inject(method = "updateBlockBreakingProgress", at = @At("HEAD"), cancellable = true)
@@ -115,4 +120,11 @@ private void updateBlockBreakingProgressPre(BlockPos pos, Direction side, Callba
115120
private void cancelBlockBreakingPre(CallbackInfo ci) {
116121
if (EventFlow.post(new PlayerEvent.Breaking.Cancel(currentBreakingProgress)).isCanceled()) ci.cancel();
117122
}
123+
124+
@WrapMethod(method = "createPlayer(Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/stat/StatHandler;Lnet/minecraft/client/recipebook/ClientRecipeBook;ZZ)Lnet/minecraft/client/network/ClientPlayerEntity;")
125+
private ClientPlayerEntity injectCreatePlayer(ClientWorld world, StatHandler statHandler, ClientRecipeBook recipeBook, boolean lastSneaking, boolean lastSprinting, Operation<ClientPlayerEntity> original) {
126+
var player = original.call(world, statHandler, recipeBook, lastSneaking, lastSprinting);
127+
InventoryManager.INSTANCE.setScreenHandler(player.playerScreenHandler);
128+
return player;
129+
}
118130
}

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

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
import com.lambda.event.events.MovementEvent;
2323
import com.lambda.event.events.PlayerEvent;
2424
import com.lambda.event.events.TickEvent;
25-
import com.lambda.interaction.PlayerPacketManager;
26-
import com.lambda.interaction.request.rotating.RotationManager;
25+
import com.lambda.interaction.PlayerPacketHandler;
26+
import com.lambda.interaction.managers.rotating.RotationManager;
2727
import com.lambda.module.modules.player.PortalGui;
2828
import com.lambda.module.modules.render.ViewModel;
29+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
2930
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
3031
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
32+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
3133
import com.mojang.authlib.GameProfile;
3234
import net.minecraft.client.MinecraftClient;
3335
import net.minecraft.client.gui.screen.Screen;
@@ -43,7 +45,6 @@
4345
import org.spongepowered.asm.mixin.Shadow;
4446
import org.spongepowered.asm.mixin.injection.At;
4547
import org.spongepowered.asm.mixin.injection.Inject;
46-
import org.spongepowered.asm.mixin.injection.Redirect;
4748
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
4849
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
4950

@@ -59,16 +60,16 @@ public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile) {
5960
super(world, profile);
6061
}
6162

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) {
64-
EventFlow.post(new MovementEvent.Player.Pre(movementType, movement));
65-
super.move(movementType, movement);
66-
EventFlow.post(new MovementEvent.Player.Post(movementType, movement));
63+
@WrapOperation(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;move(Lnet/minecraft/entity/MovementType;Lnet/minecraft/util/math/Vec3d;)V"))
64+
private void emitMovementEvents(ClientPlayerEntity instance, MovementType movementType, Vec3d vec3d, Operation<Void> original) {
65+
EventFlow.post(new MovementEvent.Player.Pre(movementType, vec3d));
66+
original.call(instance, movementType, vec3d);
67+
EventFlow.post(new MovementEvent.Player.Post(movementType, vec3d));
6768
}
6869

69-
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick()V"))
70-
void processMovement(Input input) {
71-
input.tick();
70+
@WrapOperation(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick()V"))
71+
void processMovement(Input input, Operation<Void> original) {
72+
original.call(input);
7273
RotationManager.processRotations();
7374
RotationManager.redirectStrafeInputs(input);
7475
EventFlow.post(new MovementEvent.InputUpdate(input));
@@ -80,18 +81,18 @@ void processMovement(Input input) {
8081
@Inject(method = "sendMovementPackets", at = @At(value = "HEAD"), cancellable = true)
8182
void sendLambdaMovement(CallbackInfo ci) {
8283
ci.cancel();
83-
PlayerPacketManager.sendPlayerPackets();
84+
PlayerPacketHandler.sendPlayerPackets();
8485
autoJumpEnabled = Lambda.getMc().options.getAutoJump().getValue();
8586
}
8687

87-
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendSneakingPacket()V"))
88-
void sendSneakingPacket(ClientPlayerEntity entity) {
89-
PlayerPacketManager.sendSneakPackets();
88+
@WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendSneakingPacket()V"))
89+
void sendSneakingPacket(ClientPlayerEntity entity, Operation<Void> original) {
90+
PlayerPacketHandler.sendSneakPackets();
9091
}
9192

92-
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSprinting()Z"))
93-
boolean isSprinting(ClientPlayerEntity entity) {
94-
return EventFlow.post(new MovementEvent.Sprint(entity.isSprinting())).getSprint();
93+
@ModifyExpressionValue(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSprinting()Z"))
94+
boolean isSprinting(boolean original) {
95+
return EventFlow.post(new MovementEvent.Sprint(original)).getSprint();
9596
}
9697

9798
@Inject(method = "isSneaking", at = @At(value = "HEAD"), cancellable = true)
@@ -110,27 +111,27 @@ void onTick(Operation<Void> original) {
110111
EventFlow.post(TickEvent.Player.Post.INSTANCE);
111112
}
112113

113-
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getYaw()F"))
114-
float fixHeldItemYaw(ClientPlayerEntity instance) {
115-
return Objects.requireNonNullElse(RotationManager.getHandYaw(), instance.getYaw());
114+
@WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getYaw()F"))
115+
float fixHeldItemYaw(ClientPlayerEntity instance, Operation<Float> original) {
116+
return Objects.requireNonNullElse(RotationManager.getHandYaw(), original.call(instance));
116117
}
117118

118-
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getPitch()F"))
119-
float fixHeldItemPitch(ClientPlayerEntity instance) {
120-
return Objects.requireNonNullElse(RotationManager.getHandPitch(), instance.getPitch());
119+
@WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getPitch()F"))
120+
float fixHeldItemPitch(ClientPlayerEntity instance, Operation<Float> original) {
121+
return Objects.requireNonNullElse(RotationManager.getHandPitch(), original.call(instance));
121122
}
122123

123124
@Inject(method = "swingHand", at = @At("HEAD"), cancellable = true)
124125
void onSwing(Hand hand, CallbackInfo ci) {
125126
if (EventFlow.post(new PlayerEvent.SwingHand(hand)).isCanceled()) ci.cancel();
126127
}
127128

128-
@Redirect(method = "swingHand", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
129-
private void adjustSwing(AbstractClientPlayerEntity instance, Hand hand) {
129+
@WrapOperation(method = "swingHand", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
130+
private void adjustSwing(ClientPlayerEntity instance, Hand hand, Operation<Void> original) {
130131
ViewModel viewModel = ViewModel.INSTANCE;
131132

132133
if (!viewModel.isEnabled()) {
133-
instance.swingHand(hand, false);
134+
original.call(instance, hand);
134135
return;
135136
}
136137

@@ -157,9 +158,9 @@ public void damage(float health, CallbackInfo ci) {
157158
* }
158159
* }</pre>
159160
*/
160-
@Redirect(method = "tickNausea", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;"))
161-
Screen keepScreensInPortal(MinecraftClient instance) {
161+
@ModifyExpressionValue(method = "tickNausea", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;"))
162+
Screen keepScreensInPortal(Screen original) {
162163
if (PortalGui.INSTANCE.isEnabled()) return null;
163-
else return client.currentScreen;
164+
else return original;
164165
}
165166
}

0 commit comments

Comments
 (0)