Skip to content

Commit 42dfdaa

Browse files
committed
merged master
2 parents ecef97c + 19d70c1 commit 42dfdaa

File tree

93 files changed

+2574
-285
lines changed

Some content is hidden

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

93 files changed

+2574
-285
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Feature
2+
description: Request or implement a feature.
3+
title: "[Version] [Mod Loader] [Feature]: "
4+
assignees:
5+
- Edouard127
6+
body:
7+
- type: markdown
8+
attributes:
9+
value: |
10+
Before submitting your feature, please check to see if it has already been requested.
11+
- type: textarea
12+
id: feature-idea
13+
attributes:
14+
label: Feature
15+
value: "I would like to implement a feature that..."
16+
validations:
17+
required: true
18+
- type: textarea
19+
id: extra
20+
attributes:
21+
label: Additional Information
22+
description: Is there anything else you would like to add?
23+
- type: checkboxes
24+
id: pr
25+
attributes:
26+
label: Pull Request
27+
options:
28+
- label: I will be submitting a pull request
29+
- type: checkboxes
30+
id: terms
31+
attributes:
32+
label: Code of Conduct
33+
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/lambda-client/lambda/blob/master/.github/CODE_OF_CONDUCT.md).
34+
options:
35+
- label: I agree to follow this project's Code of Conduct
36+
required: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ build/
1616
out/
1717
!**/src/main/**/out/
1818
!**/src/test/**/out/
19+
.kotlin/
1920

2021
### Eclipse ###
2122
.apt_generated

common/src/main/java/com/lambda/mixin/ClientConnectionMixin.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
import io.netty.channel.ChannelHandlerContext;
77
import net.minecraft.network.ClientConnection;
88
import net.minecraft.network.NetworkSide;
9+
import net.minecraft.network.listener.ClientPacketListener;
910
import net.minecraft.network.listener.PacketListener;
11+
import net.minecraft.network.listener.ServerPacketListener;
1012
import net.minecraft.network.packet.Packet;
1113
import net.minecraft.network.packet.c2s.handshake.ConnectionIntent;
1214
import net.minecraft.text.Text;
@@ -25,14 +27,18 @@ public class ClientConnectionMixin {
2527

2628
@Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true)
2729
private void sendingPacket(Packet<?> packet, final CallbackInfo callbackInfo) {
28-
if (EventFlow.post(new PacketEvent.Send.Pre(packet)).isCanceled()) {
30+
if (side != NetworkSide.SERVERBOUND) return;
31+
32+
if (EventFlow.post(new PacketEvent.Send.Pre((Packet<ServerPacketListener>) packet)).isCanceled()) {
2933
callbackInfo.cancel();
3034
}
3135
}
3236

3337
@Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("RETURN"))
3438
private void sendingPacketPost(Packet<?> packet, final CallbackInfo callbackInfo) {
35-
EventFlow.post(new PacketEvent.Send.Post(packet));
39+
if (side != NetworkSide.SERVERBOUND) return;
40+
41+
EventFlow.post(new PacketEvent.Send.Post((Packet<ServerPacketListener>) packet));
3642
}
3743

3844
@Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/packet/Packet;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;handlePacket(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;)V", shift = At.Shift.BEFORE), cancellable = true, require = 1)
@@ -42,7 +48,8 @@ private void receivingPacket(
4248
CallbackInfo callbackInfo
4349
) {
4450
if (side != NetworkSide.CLIENTBOUND) return;
45-
if (EventFlow.post(new PacketEvent.Receive.Pre(packet)).isCanceled()) {
51+
52+
if (EventFlow.post(new PacketEvent.Receive.Pre((Packet<ClientPacketListener>) packet)).isCanceled()) {
4653
callbackInfo.cancel();
4754
}
4855
}
@@ -55,7 +62,7 @@ private void receivingPacketPost(
5562
) {
5663
if (side != NetworkSide.CLIENTBOUND) return;
5764

58-
EventFlow.post(new PacketEvent.Receive.Post(packet));
65+
EventFlow.post(new PacketEvent.Receive.Post((Packet<ClientPacketListener>) packet));
5966
}
6067

6168
@Inject(method = "connect(Ljava/lang/String;ILnet/minecraft/network/listener/PacketListener;Lnet/minecraft/network/packet/c2s/handshake/ConnectionIntent;)V", at = @At("HEAD"))

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import com.lambda.event.events.ScreenEvent;
77
import com.lambda.event.events.ScreenHandlerEvent;
88
import com.lambda.event.events.TickEvent;
9+
import com.lambda.interaction.RotationManager;
910
import com.lambda.module.modules.player.Interact;
1011
import net.minecraft.client.MinecraftClient;
1112
import net.minecraft.client.gui.screen.Screen;
12-
import net.minecraft.client.gui.screen.ingame.HandledScreen;
1313
import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider;
1414
import net.minecraft.client.network.ClientPlayerInteractionManager;
1515
import org.jetbrains.annotations.Nullable;
@@ -27,6 +27,7 @@ public class MinecraftClientMixin {
2727
@Inject(method = "tick", at = @At("HEAD"))
2828
void onTickPre(CallbackInfo ci) {
2929
EventFlow.post(new TickEvent.Pre());
30+
RotationManager.update();
3031
}
3132

3233
@Inject(method = "tick", at = @At("RETURN"))
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.lambda.mixin.client.sound;
2+
3+
import com.lambda.event.EventFlow;
4+
import com.lambda.event.events.ClientEvent;
5+
import net.minecraft.client.sound.SoundInstance;
6+
import net.minecraft.client.sound.SoundSystem;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.Inject;
10+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
11+
12+
@Mixin(SoundSystem.class)
13+
public class SoundSystemMixin {
14+
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", at = @At(value = "HEAD"), cancellable = true)
15+
public void onPlay(SoundInstance sound, CallbackInfo ci) {
16+
if (EventFlow.post(new ClientEvent.Sound(sound)).isCanceled()) {
17+
ci.cancel();
18+
}
19+
}
20+
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.lambda.mixin.entity;
22

33
import com.lambda.event.EventFlow;
4+
import com.lambda.event.events.AttackEvent;
45
import com.lambda.event.events.InteractionEvent;
56
import net.minecraft.client.MinecraftClient;
67
import net.minecraft.client.network.ClientPlayerEntity;
78
import net.minecraft.client.network.ClientPlayerInteractionManager;
9+
import net.minecraft.entity.Entity;
10+
import net.minecraft.entity.player.PlayerEntity;
811
import net.minecraft.util.ActionResult;
912
import net.minecraft.util.Hand;
1013
import net.minecraft.util.hit.BlockHitResult;
@@ -15,6 +18,7 @@
1518
import org.spongepowered.asm.mixin.Shadow;
1619
import org.spongepowered.asm.mixin.injection.At;
1720
import org.spongepowered.asm.mixin.injection.Inject;
21+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1822
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1923

2024
@Mixin(ClientPlayerInteractionManager.class)
@@ -33,6 +37,16 @@ public void interactBlockHead(final ClientPlayerEntity player, final Hand hand,
3337
EventFlow.post(new InteractionEvent.Block(client.world, hitResult));
3438
}
3539

40+
@Inject(method = "attackEntity", at = @At("HEAD"), cancellable = true)
41+
void onAttackPre(PlayerEntity player, Entity target, CallbackInfo ci) {
42+
if (EventFlow.post(new AttackEvent.Pre(target)).isCanceled()) ci.cancel();
43+
}
44+
45+
@Inject(method = "attackEntity", at = @At("TAIL"))
46+
void onAttackPost(PlayerEntity player, Entity target, CallbackInfo ci) {
47+
EventFlow.post(new AttackEvent.Post(target));
48+
}
49+
3650
@Inject(method = "attackBlock", at = @At("HEAD"), cancellable = true)
3751
public void onAttackBlock(BlockPos pos, Direction side, CallbackInfoReturnable<Boolean> cir) {
3852
if (EventFlow.post(new InteractionEvent.BlockAttack.Pre(pos, side)).isCanceled()) cir.cancel();

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.lambda.event.EventFlow;
55
import com.lambda.event.events.EntityEvent;
66
import com.lambda.event.events.MovementEvent;
7+
import com.lambda.event.events.TickEvent;
78
import com.lambda.interaction.PlayerPacketManager;
89
import com.lambda.interaction.RotationManager;
910
import net.minecraft.client.input.Input;
@@ -57,6 +58,7 @@ void onMove(MovementType movementType, Vec3d movement, CallbackInfo ci) {
5758
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick(ZF)V"))
5859
void processMovement(Input input, boolean slowDown, float slowDownFactor) {
5960
input.tick(slowDown, slowDownFactor);
61+
RotationManager.BaritoneProcessor.processPlayerMovement(input, slowDown, slowDownFactor);
6062
EventFlow.post(new MovementEvent.InputUpdate(input, slowDown, slowDownFactor));
6163
}
6264

@@ -72,6 +74,16 @@ void sendBegin(CallbackInfo ci) {
7274
autoJumpEnabled = Lambda.getMc().options.getAutoJump().getValue();
7375
}
7476

77+
@Inject(method = "tick", at = @At(value = "HEAD"))
78+
void onTickPre(CallbackInfo ci) {
79+
EventFlow.post(new TickEvent.Player.Pre());
80+
}
81+
82+
@Inject(method = "tick", at = @At(value = "RETURN"))
83+
void onTickPost(CallbackInfo ci) {
84+
EventFlow.post(new TickEvent.Player.Post());
85+
}
86+
7587
@Redirect(method = "tickNewAi", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getYaw()F"))
7688
float fixHeldItemYaw(ClientPlayerEntity instance) {
7789
return Objects.requireNonNullElse(RotationManager.getHandYaw(), instance.getYaw());

common/src/main/java/com/lambda/mixin/entity/LivingEntityMixin.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@ void onJump(CallbackInfo ci) {
4545
self.velocityDirty = true;
4646
}
4747

48+
@Inject(method = "travel", at = @At("HEAD"), cancellable = true)
49+
void onTravelPre(Vec3d movementInput, CallbackInfo ci) {
50+
LivingEntity self = (LivingEntity) (Object) this;
51+
if (self != Lambda.getMc().player) return;
52+
53+
if (EventFlow.post(new MovementEvent.Travel.Pre()).isCanceled()) ci.cancel();
54+
}
55+
56+
@Inject(method = "travel", at = @At("TAIL"))
57+
void onTravelPost(Vec3d movementInput, CallbackInfo ci) {
58+
LivingEntity self = (LivingEntity) (Object) this;
59+
if (self != Lambda.getMc().player) return;
60+
61+
EventFlow.post(new MovementEvent.Travel.Post());
62+
}
63+
4864
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getPitch()F"))
4965
private float hookModifyFallFlyingPitch(LivingEntity entity) {
5066
Float pitch = RotationManager.getMovementPitch();

common/src/main/java/com/lambda/mixin/entity/PlayerEntityMixin.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,14 @@ private float injectHeadYaw(PlayerEntity instance) {
2828
Float yaw = RotationManager.getRenderYaw();
2929
return (yaw != null) ? yaw : instance.getYaw();
3030
}
31+
32+
@Redirect(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getYaw()F"))
33+
private float injectAttackFix(PlayerEntity instance) {
34+
if ((Object) this != MinecraftClient.getInstance().player) {
35+
return instance.getYaw();
36+
}
37+
38+
Float yaw = RotationManager.getMovementYaw();
39+
return (yaw != null) ? yaw : instance.getYaw();
40+
}
3141
}

common/src/main/java/com/lambda/mixin/input/KeyBindingMixin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.lambda.module.modules.movement.Speed;
44
import com.lambda.module.modules.movement.Sprint;
5+
import com.lambda.module.modules.movement.TargetStrafe;
56
import net.minecraft.client.option.KeyBinding;
67
import org.spongepowered.asm.mixin.Mixin;
78
import org.spongepowered.asm.mixin.injection.At;
@@ -19,5 +20,6 @@ void autoSprint(CallbackInfoReturnable<Boolean> cir) {
1920

2021
if (Sprint.INSTANCE.isEnabled()) cir.setReturnValue(true);
2122
if (Speed.INSTANCE.isEnabled() && Speed.getMode() == Speed.Mode.GRIM_STRAFE) cir.setReturnValue(true);
23+
if (TargetStrafe.INSTANCE.isEnabled() && TargetStrafe.isActive()) cir.setReturnValue(true);
2224
}
2325
}

0 commit comments

Comments
 (0)