Skip to content

Commit be7fd72

Browse files
committed
Merge branch 'feature/packetmine-rewrite' of https://github.com/Avanatiker/NeoLambda into feature/packetmine-rewrite
2 parents 023d6e6 + 445f360 commit be7fd72

File tree

141 files changed

+3673
-1465
lines changed

Some content is hidden

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

141 files changed

+3673
-1465
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import baritone.Baritone;
2121
import baritone.api.utils.Rotation;
2222
import baritone.utils.player.BaritonePlayerContext;
23-
import com.lambda.interaction.request.rotation.RotationManager;
23+
import com.lambda.interaction.request.rotating.RotationManager;
2424
import com.lambda.util.BaritoneUtils;
2525
import org.spongepowered.asm.mixin.Final;
2626
import org.spongepowered.asm.mixin.Mixin;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import baritone.api.event.events.RotationMoveEvent;
2222
import baritone.api.utils.Rotation;
2323
import baritone.behavior.LookBehavior;
24-
import com.lambda.interaction.request.rotation.RotationManager;
24+
import com.lambda.interaction.request.rotating.RotationManager;
2525
import com.lambda.util.BaritoneUtils;
2626
import org.spongepowered.asm.mixin.Mixin;
2727
import org.spongepowered.asm.mixin.injection.At;

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import net.minecraft.client.network.ClientPlayerEntity;
3636
import net.minecraft.entity.MovementType;
3737
import net.minecraft.entity.damage.DamageSource;
38-
import net.minecraft.util.Hand;
3938
import net.minecraft.util.math.Vec3d;
4039
import org.spongepowered.asm.mixin.Final;
4140
import org.spongepowered.asm.mixin.Mixin;
@@ -119,7 +118,7 @@ void redirectSneaking(CallbackInfoReturnable<Boolean> cir) {
119118
if (self != Lambda.getMc().player) return;
120119

121120
if (self.input == null) return;
122-
cir.setReturnValue(EventFlow.post(new MovementEvent.Sneak(self.input.playerInput.sneak())).getSneak());
121+
cir.setReturnValue(EventFlow.post(new MovementEvent.Sneak(self.input.sneaking)).getSneak());
123122
}
124123

125124
/**
@@ -149,14 +148,21 @@ float fixHeldItemPitch(ClientPlayerEntity instance) {
149148
return Objects.requireNonNullElse(RotationManager.getHandPitch(), instance.getPitch());
150149
}
151150

152-
@Inject(method = "swingHand", at = @At("HEAD"), cancellable = true)
153-
void onSwingHandPre(Hand hand, CallbackInfo ci) {
154-
if (EventFlow.post(new PlayerEvent.SwingHand(hand)).isCanceled()) ci.cancel();
151+
@Redirect(method = "swingHand", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
152+
private void adjustSwing(AbstractClientPlayerEntity instance, Hand hand) {
153+
ViewModel viewModel = ViewModel.INSTANCE;
154+
155+
if (!viewModel.isEnabled()) {
156+
instance.swingHand(hand, false);
157+
return;
158+
}
159+
160+
viewModel.adjustSwing(hand, instance);
155161
}
156162

157-
@Inject(method = "updateHealth", at = @At("HEAD"))
158-
public void damage(float health, CallbackInfo ci) {
159-
EventFlow.post(new PlayerEvent.Damage(health));
163+
@Inject(method = "damage", at = @At("HEAD"), cancellable = true)
164+
public void damage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
165+
if (EventFlow.post(new PlayerEvent.Damage(source, amount)).isCanceled()) cir.setReturnValue(false);
160166
}
161167

162168
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import com.lambda.event.EventFlow;
2222
import com.lambda.event.events.EntityEvent;
2323
import com.lambda.event.events.PlayerEvent;
24-
import com.lambda.interaction.request.rotation.RotationManager;
24+
import com.lambda.interaction.request.rotating.RotationManager;
2525
import com.lambda.util.math.Vec2d;
2626
import net.minecraft.entity.Entity;
2727
import net.minecraft.entity.MovementType;

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

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@
2020
import com.lambda.Lambda;
2121
import com.lambda.event.EventFlow;
2222
import com.lambda.event.events.MovementEvent;
23-
import com.lambda.interaction.request.rotation.RotationManager;
23+
import com.lambda.module.modules.render.ViewModel;
24+
import com.lambda.interaction.request.rotating.RotationManager;
2425
import net.minecraft.entity.LivingEntity;
2526
import net.minecraft.util.math.MathHelper;
2627
import net.minecraft.util.math.Vec3d;
2728
import org.spongepowered.asm.mixin.Mixin;
2829
import org.spongepowered.asm.mixin.Shadow;
29-
import org.spongepowered.asm.mixin.injection.At;
30-
import org.spongepowered.asm.mixin.injection.Inject;
31-
import org.spongepowered.asm.mixin.injection.Redirect;
32-
import org.spongepowered.asm.mixin.injection.Slice;
30+
import org.spongepowered.asm.mixin.Unique;
31+
import org.spongepowered.asm.mixin.injection.*;
3332
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
3433

3534
@Mixin(LivingEntity.class)
@@ -38,6 +37,9 @@ public abstract class LivingEntityMixin extends EntityMixin {
3837
@Shadow
3938
protected abstract float getJumpVelocity();
4039

40+
@Unique
41+
private final LivingEntity lambda$instance = (LivingEntity) (Object) this;
42+
4143
/**
4244
* Overwrites the jump function to use our rotation and movements
4345
* <pre>{@code
@@ -55,7 +57,7 @@ public abstract class LivingEntityMixin extends EntityMixin {
5557
*/
5658
@Inject(method = "jump", at = @At("HEAD"), cancellable = true)
5759
void onJump(CallbackInfo ci) {
58-
LivingEntity self = (LivingEntity) (Object) this;
60+
LivingEntity self = lambda$instance;
5961
if (self != Lambda.getMc().player) return;
6062
ci.cancel();
6163

@@ -78,15 +80,14 @@ void onJump(CallbackInfo ci) {
7880

7981
@Inject(method = "travel", at = @At("HEAD"), cancellable = true)
8082
void onTravelPre(Vec3d movementInput, CallbackInfo ci) {
81-
LivingEntity entity = (LivingEntity) (Object) this;
82-
if (EventFlow.post(new MovementEvent.Entity.Pre(entity, movementInput)).isCanceled()) {
83+
if (EventFlow.post(new MovementEvent.Entity.Pre(lambda$instance, movementInput)).isCanceled()) {
8384
ci.cancel();
8485
}
8586
}
8687

8788
@Inject(method = "travel", at = @At("TAIL"))
8889
void onTravelPost(Vec3d movementInput, CallbackInfo ci) {
89-
EventFlow.post(new MovementEvent.Entity.Post((LivingEntity) (Object) this, movementInput));
90+
EventFlow.post(new MovementEvent.Entity.Post(lambda$instance, movementInput));
9091
}
9192

9293
/**
@@ -123,11 +124,11 @@ private float hookModifyFallFlyingPitch(LivingEntity entity) {
123124
*/
124125
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getYaw()F"), slice = @Slice(to = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getYaw()F", ordinal = 1)))
125126
private float rotBody(LivingEntity entity) {
126-
if ((Object) this != Lambda.getMc().player) {
127+
if (lambda$instance != Lambda.getMc().player) {
127128
return entity.getYaw();
128129
}
129130

130-
Float yaw = RotationManager.getRenderYaw();
131+
Float yaw = RotationManager.getHeadYaw();
131132
return (yaw == null) ? entity.getYaw() : yaw;
132133
}
133134

@@ -154,11 +155,18 @@ private float rotBody(LivingEntity entity) {
154155
*/
155156
@Redirect(method = "turnHead", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getYaw()F"))
156157
private float rotHead(LivingEntity entity) {
157-
if ((Object) this != Lambda.getMc().player) {
158+
if (lambda$instance != Lambda.getMc().player) {
158159
return entity.getYaw();
159160
}
160161

161-
Float yaw = RotationManager.getRenderYaw();
162+
Float yaw = RotationManager.getHeadYaw();
162163
return (yaw == null) ? entity.getYaw() : yaw;
163164
}
165+
166+
@ModifyConstant(method = "getHandSwingDuration", constant = @Constant(intValue = 6))
167+
private int getHandSwingDuration(int constant) {
168+
if (lambda$instance != Lambda.getMc().player || ViewModel.INSTANCE.isDisabled()) return constant;
169+
170+
return ViewModel.INSTANCE.getSwingDuration();
171+
}
164172
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.lambda.Lambda;
2121
import com.lambda.event.EventFlow;
2222
import com.lambda.event.events.MovementEvent;
23-
import com.lambda.interaction.request.rotation.RotationManager;
23+
import com.lambda.interaction.request.rotating.RotationManager;
2424
import net.minecraft.entity.player.PlayerEntity;
2525
import org.spongepowered.asm.mixin.Mixin;
2626
import org.spongepowered.asm.mixin.injection.At;
@@ -42,7 +42,7 @@ private float injectHeadYaw(PlayerEntity instance) {
4242
return instance.getYaw();
4343
}
4444

45-
Float yaw = RotationManager.getRenderYaw();
45+
Float yaw = RotationManager.getHeadYaw();
4646
return (yaw != null) ? yaw : instance.getYaw();
4747
}
4848

common/src/main/java/com/lambda/mixin/render/CameraMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.lambda.mixin.render;
1919

20-
import com.lambda.interaction.request.rotation.RotationManager;
20+
import com.lambda.interaction.request.rotating.RotationManager;
2121
import com.lambda.module.modules.player.Freecam;
2222
import com.lambda.module.modules.render.CameraTweaks;
2323
import net.minecraft.client.render.Camera;
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package com.lambda.mixin.render;
2+
3+
import com.google.common.base.MoreObjects;
4+
import com.lambda.Lambda;
5+
import com.lambda.module.modules.render.ViewModel;
6+
import net.minecraft.client.MinecraftClient;
7+
import net.minecraft.client.network.AbstractClientPlayerEntity;
8+
import net.minecraft.client.render.VertexConsumerProvider;
9+
import net.minecraft.client.render.item.HeldItemRenderer;
10+
import net.minecraft.client.util.math.MatrixStack;
11+
import net.minecraft.item.ItemStack;
12+
import net.minecraft.util.Hand;
13+
import org.spongepowered.asm.mixin.Final;
14+
import org.spongepowered.asm.mixin.Mixin;
15+
import org.spongepowered.asm.mixin.Shadow;
16+
import org.spongepowered.asm.mixin.injection.At;
17+
import org.spongepowered.asm.mixin.injection.Inject;
18+
import org.spongepowered.asm.mixin.injection.ModifyArg;
19+
import org.spongepowered.asm.mixin.injection.ModifyVariable;
20+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21+
22+
@Mixin(HeldItemRenderer.class)
23+
public class HeldItemRendererMixin {
24+
@Final @Shadow private MinecraftClient client;
25+
@Shadow private ItemStack mainHand;
26+
@Shadow private ItemStack offHand;
27+
@Shadow private float equipProgressMainHand;
28+
@Shadow private float equipProgressOffHand;
29+
30+
@Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderArmHoldingItem(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IFFLnet/minecraft/util/Arm;)V"))
31+
private void onRenderArmHoldingItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack itemStack, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
32+
if (!ViewModel.INSTANCE.isEnabled()) return;
33+
34+
ViewModel.INSTANCE.transform(itemStack, hand, matrices);
35+
}
36+
37+
@Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;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;I)V"))
38+
private void onRenderFirstPersonItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack itemStack, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
39+
if (!ViewModel.INSTANCE.isEnabled()) return;
40+
41+
ViewModel.INSTANCE.transform(itemStack, hand, matrices);
42+
}
43+
44+
@ModifyArg(method = "updateHeldItems", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F", ordinal = 2), index = 0)
45+
private float modifyEquipProgressMainHand(float value) {
46+
if (client.player == null || ViewModel.INSTANCE.isDisabled()) return value;
47+
48+
ViewModel config = ViewModel.INSTANCE;
49+
ItemStack currentStack = client.player.getMainHandStack();
50+
if (config.getOldAnimations() && !config.getSwapAnimation()) {
51+
mainHand = currentStack;
52+
}
53+
54+
float progress = config.getOldAnimations() ? 1 : (float) Math.pow(client.player.getAttackCooldownProgress(1), 3);
55+
56+
return (ItemStack.areEqual(mainHand, currentStack) ? progress : 0) - equipProgressMainHand;
57+
}
58+
59+
@ModifyArg(method = "updateHeldItems", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F", ordinal = 3), index = 0)
60+
private float modifyEquipProgressOffHand(float value) {
61+
if (client.player == null || ViewModel.INSTANCE.isDisabled()) return value;
62+
63+
ViewModel config = ViewModel.INSTANCE;
64+
65+
ItemStack currentStack = client.player.getOffHandStack();
66+
if (config.getOldAnimations() && !config.getSwapAnimation()) {
67+
offHand = currentStack;
68+
}
69+
70+
return (ItemStack.areEqual(offHand, currentStack) ? 1 : 0) - equipProgressOffHand;
71+
}
72+
73+
@ModifyVariable(method = "renderItem(FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;Lnet/minecraft/client/network/ClientPlayerEntity;I)V", at = @At(value = "STORE", ordinal = 0), index = 6)
74+
private float modifySwing(float swingProgress) {
75+
ViewModel config = ViewModel.INSTANCE;
76+
MinecraftClient mc = Lambda.getMc();
77+
if (config.isDisabled() || mc.player == null) return swingProgress;
78+
Hand hand = MoreObjects.firstNonNull(mc.player.preferredHand, Hand.MAIN_HAND);
79+
80+
if (hand == Hand.MAIN_HAND) {
81+
return swingProgress + config.getMainSwingProgress();
82+
} else if (hand == Hand.OFF_HAND) {
83+
return swingProgress + config.getOffhandSwingProgress();
84+
}
85+
86+
return swingProgress;
87+
}
88+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.lambda.mixin.render;
1919

20-
import com.lambda.interaction.request.rotation.RotationManager;
20+
import com.lambda.interaction.request.rotating.RotationManager;
2121
import net.minecraft.client.render.entity.LivingEntityRenderer;
2222
import net.minecraft.entity.LivingEntity;
2323
import org.spongepowered.asm.mixin.Mixin;

common/src/main/kotlin/com/lambda/config/Configurable.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ abstract class Configurable(
284284
description: String = "",
285285
unit: String = "",
286286
visibility: () -> Boolean = { true },
287-
) = DoubleSetting(name, defaultValue, range, step, description, visibility, unit).register()
287+
) = DoubleSetting(name, defaultValue, range, step, description, unit, visibility).register()
288288

289289
/**
290290
* Creates a [FloatSetting] with the provided parameters and adds it to the [settings].
@@ -309,7 +309,7 @@ abstract class Configurable(
309309
description: String = "",
310310
unit: String = "",
311311
visibility: () -> Boolean = { true },
312-
) = FloatSetting(name, defaultValue, range, step, description, visibility, unit).register()
312+
) = FloatSetting(name, defaultValue, range, step, description, unit, visibility).register()
313313

314314
/**
315315
* Creates an [IntegerSetting] with the provided parameters and adds it to the [settings].
@@ -334,7 +334,7 @@ abstract class Configurable(
334334
description: String = "",
335335
unit: String = "",
336336
visibility: () -> Boolean = { true },
337-
) = IntegerSetting(name, defaultValue, range, step, description, visibility, unit).register()
337+
) = IntegerSetting(name, defaultValue, range, step, description, unit, visibility).register()
338338

339339
/**
340340
* Creates a [LongSetting] with the provided parameters and adds it to the [settings].
@@ -359,7 +359,7 @@ abstract class Configurable(
359359
description: String = "",
360360
unit: String = "",
361361
visibility: () -> Boolean = { true },
362-
) = LongSetting(name, defaultValue, range, step, description, visibility, unit).register()
362+
) = LongSetting(name, defaultValue, range, step, description, unit, visibility).register()
363363

364364
/**
365365
* Creates a [KeyBindSetting] with the provided parameters and adds it to the [settings].

0 commit comments

Comments
 (0)