Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions src/main/java/com/lambda/mixin/MinecraftClientMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.lambda.module.modules.player.InventoryMove;
import com.lambda.module.modules.player.PacketMine;
import com.lambda.util.WindowUtils;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
Expand All @@ -49,7 +51,6 @@
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.callback.CallbackInfo;

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

@Redirect(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;unpressAll()V"))
private void redirectUnPressAll() {
@WrapOperation(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;unpressAll()V"))
private void redirectUnPressAll(Operation<Void> original) {
if (!InventoryMove.getShouldMove()) {
KeyBinding.unpressAll();
original.call();
return;
}
KeyBinding.KEYS_BY_ID.values().forEach(bind -> {
Expand All @@ -167,20 +168,16 @@ private void redirectUnPressAll() {
});
}

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

@Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isBreakingBlock()Z"))
boolean redirectMultiActon(ClientPlayerInteractionManager instance) {
if (instance == null) return true;

@ModifyExpressionValue(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isBreakingBlock()Z"))
boolean redirectMultiActon(boolean original) {
if (Interact.INSTANCE.isEnabled() && Interact.getMultiAction()) return false;
return instance.isBreakingBlock();
return original;
}

@Inject(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isRiding()Z"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.lambda.event.events.InventoryEvent;
import com.lambda.event.events.PlayerEvent;
import com.lambda.interaction.managers.inventory.InventoryManager;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import net.minecraft.client.network.ClientPlayerEntity;
Expand All @@ -42,7 +43,6 @@
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

Expand Down Expand Up @@ -103,9 +103,9 @@ public void clickSlotHead(int syncId, int slotId, int button, SlotActionType act
* }
* }</pre>
*/
@Redirect(method = "syncSelectedSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;getSelectedSlot()I"))
public int overrideSelectedSlotSync(PlayerInventory instance) {
return EventFlow.post(new InventoryEvent.HotbarSlot.Update(instance.getSelectedSlot())).getSlot();
@ModifyExpressionValue(method = "syncSelectedSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;getSelectedSlot()I"))
public int overrideSelectedSlotSync(int original) {
return EventFlow.post(new InventoryEvent.HotbarSlot.Update(original)).getSlot();
}

@Inject(method = "updateBlockBreakingProgress", at = @At("HEAD"), cancellable = true)
Expand Down
53 changes: 27 additions & 26 deletions src/main/java/com/lambda/mixin/entity/ClientPlayerEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
import com.lambda.interaction.managers.rotating.RotationManager;
import com.lambda.module.modules.player.PortalGui;
import com.lambda.module.modules.render.ViewModel;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
Expand All @@ -43,7 +45,6 @@
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

Expand All @@ -59,16 +60,16 @@ public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile) {
super(world, profile);
}

@Redirect(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;move(Lnet/minecraft/entity/MovementType;Lnet/minecraft/util/math/Vec3d;)V"))
private void emitMovementEvents(AbstractClientPlayerEntity instance, MovementType movementType, Vec3d movement) {
EventFlow.post(new MovementEvent.Player.Pre(movementType, movement));
super.move(movementType, movement);
EventFlow.post(new MovementEvent.Player.Post(movementType, movement));
@WrapOperation(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;move(Lnet/minecraft/entity/MovementType;Lnet/minecraft/util/math/Vec3d;)V"))
private void emitMovementEvents(ClientPlayerEntity instance, MovementType movementType, Vec3d vec3d, Operation<Void> original) {
EventFlow.post(new MovementEvent.Player.Pre(movementType, vec3d));
original.call(instance, movementType, vec3d);
EventFlow.post(new MovementEvent.Player.Post(movementType, vec3d));
}

@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick()V"))
void processMovement(Input input) {
input.tick();
@WrapOperation(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick()V"))
void processMovement(Input input, Operation<Void> original) {
original.call(input);
RotationManager.processRotations();
RotationManager.redirectStrafeInputs(input);
EventFlow.post(new MovementEvent.InputUpdate(input));
Expand All @@ -84,14 +85,14 @@ void sendLambdaMovement(CallbackInfo ci) {
autoJumpEnabled = Lambda.getMc().options.getAutoJump().getValue();
}

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

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

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

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

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

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

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

if (!viewModel.isEnabled()) {
instance.swingHand(hand, false);
original.call(instance, hand);
return;
}

Expand All @@ -157,9 +158,9 @@ public void damage(float health, CallbackInfo ci) {
* }
* }</pre>
*/
@Redirect(method = "tickNausea", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;"))
Screen keepScreensInPortal(MinecraftClient instance) {
@ModifyExpressionValue(method = "tickNausea", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;"))
Screen keepScreensInPortal(Screen original) {
if (PortalGui.INSTANCE.isEnabled()) return null;
else return client.currentScreen;
else return original;
}
}
35 changes: 18 additions & 17 deletions src/main/java/com/lambda/mixin/entity/EntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import com.lambda.util.math.Vec2d;
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 net.minecraft.entity.Entity;
import net.minecraft.entity.MovementType;
import net.minecraft.entity.data.TrackedData;
Expand All @@ -36,7 +38,6 @@
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Entity.class)
Expand All @@ -51,12 +52,12 @@ public void move(MovementType movementType, Vec3d movement) {
/**
* Modifies the player yaw when there is an active rotation to apply the player velocity correctly
*/
@Redirect(method = "updateVelocity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getYaw()F"))
public float velocityYaw(Entity entity) {
if ((Object) this != Lambda.getMc().player) return getYaw();
@WrapOperation(method = "updateVelocity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getYaw()F"))
public float velocityYaw(Entity entity, Operation<Float> original) {
if ((Object) this != Lambda.getMc().player) return original.call(entity);

Float y = RotationManager.getMovementYaw();
if (y == null) return getYaw();
if (y == null) return original.call(entity);

return y;
}
Expand All @@ -69,10 +70,10 @@ public float velocityYaw(Entity entity) {
* }
* }</pre>
*/
@Redirect(method = "getRotationVec", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getYaw(F)F"))
float fixDirectionYaw(Entity entity, float tickDelta) {
@WrapOperation(method = "getRotationVec", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getYaw(F)F"))
float fixDirectionYaw(Entity entity, float tickDelta, Operation<Float> original) {
Vec2d rot = RotationManager.getRotationForVector(tickDelta);
if (entity != Lambda.getMc().player || rot == null) return entity.getYaw(tickDelta);
if (entity != Lambda.getMc().player || rot == null) return original.call(entity, tickDelta);

return (float) rot.getX();
}
Expand All @@ -85,10 +86,10 @@ float fixDirectionYaw(Entity entity, float tickDelta) {
* }
* }</pre>
*/
@Redirect(method = "getRotationVec", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPitch(F)F"))
float fixDirectionPitch(Entity entity, float tickDelta) {
@WrapOperation(method = "getRotationVec", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPitch(F)F"))
float fixDirectionPitch(Entity entity, float tickDelta, Operation<Float> original) {
Vec2d rot = RotationManager.getRotationForVector(tickDelta);
if (entity != Lambda.getMc().player || rot == null) return entity.getPitch(tickDelta);
if (entity != Lambda.getMc().player || rot == null) return original.call(entity, tickDelta);

return (float) rot.getY();
}
Expand All @@ -101,10 +102,10 @@ float fixDirectionPitch(Entity entity, float tickDelta) {
* }
* }</pre>
*/
@Redirect(method = "getRotationVector()Lnet/minecraft/util/math/Vec3d;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getYaw()F"))
float fixDirectionYaw2(Entity entity) {
@WrapOperation(method = "getRotationVector()Lnet/minecraft/util/math/Vec3d;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getYaw()F"))
float fixDirectionYaw2(Entity entity, Operation<Float> original) {
Vec2d rot = RotationManager.getRotationForVector(1.0);
if (entity != Lambda.getMc().player || rot == null) return entity.getYaw();
if (entity != Lambda.getMc().player || rot == null) return original.call(entity);

return (float) rot.getX();
}
Expand All @@ -117,10 +118,10 @@ float fixDirectionYaw2(Entity entity) {
* }
* }</pre>
*/
@Redirect(method = "getRotationVector()Lnet/minecraft/util/math/Vec3d;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPitch()F"))
float fixDirectionPitch2(Entity entity) {
@WrapOperation(method = "getRotationVector()Lnet/minecraft/util/math/Vec3d;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPitch()F"))
float fixDirectionPitch2(Entity entity, Operation<Float> original) {
Vec2d rot = RotationManager.getRotationForVector(1.0);
if (entity != Lambda.getMc().player || rot == null) return entity.getPitch();
if (entity != Lambda.getMc().player || rot == null) return original.call(entity);

return (float) rot.getY();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@
package com.lambda.mixin.entity;

import com.lambda.module.modules.movement.ElytraFly;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.projectile.FireworkRocketEntity;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(FireworkRocketEntity.class)
public class FireworkRocketEntityMixin {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V"))
private void redirectSetVelocity(LivingEntity shooter, Vec3d vec3d) {
@WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V"))
private void wrapSetVelocity(LivingEntity shooter, Vec3d vec3d, Operation<Void> original) {
if (ElytraFly.getDoBoost()) {
ElytraFly.boostRocket();
} else shooter.setVelocity(vec3d);
} else original.call(shooter, vec3d);
}
}
Loading
Loading