Skip to content

Commit 9b9892b

Browse files
committed
Update ClientPlayerEntityMixin.java
1 parent 5ecf6c9 commit 9b9892b

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

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

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Lambda
2+
* Copyright 2025 Lambda
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -26,13 +26,10 @@
2626
import com.lambda.interaction.request.rotation.RotationManager;
2727
import com.lambda.module.modules.player.PortalGui;
2828
import net.minecraft.client.MinecraftClient;
29-
import net.minecraft.client.gui.screen.DeathScreen;
3029
import net.minecraft.client.gui.screen.Screen;
31-
import net.minecraft.client.gui.screen.ingame.HandledScreen;
3230
import net.minecraft.client.input.Input;
3331
import net.minecraft.client.network.ClientPlayerEntity;
3432
import net.minecraft.entity.MovementType;
35-
import net.minecraft.entity.damage.DamageSource;
3633
import net.minecraft.util.Hand;
3734
import net.minecraft.util.math.Vec3d;
3835
import org.spongepowered.asm.mixin.Final;
@@ -49,8 +46,6 @@
4946
@Mixin(value = ClientPlayerEntity.class, priority = Integer.MAX_VALUE)
5047
public abstract class ClientPlayerEntityMixin extends EntityMixin {
5148

52-
@Shadow
53-
public Input input;
5449
@Shadow
5550
private boolean autoJumpEnabled;
5651

@@ -82,11 +77,11 @@ void onMove(MovementType movementType, Vec3d movement, CallbackInfo ci) {
8277
this.autoJump(currX - prevX, currZ - prevZ);
8378
}
8479

85-
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick(ZF)V"))
86-
void processMovement(Input input, boolean slowDown, float slowDownFactor) {
87-
input.tick(slowDown, slowDownFactor);
88-
RotationManager.BaritoneProcessor.processPlayerMovement(input, slowDown, slowDownFactor);
89-
EventFlow.post(new MovementEvent.InputUpdate(input, slowDown, slowDownFactor));
80+
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick()V"))
81+
void processMovement(Input input) {
82+
input.tick();
83+
RotationManager.BaritoneProcessor.processPlayerMovement(input);
84+
EventFlow.post(new MovementEvent.InputUpdate(input));
9085
}
9186

9287
/**
@@ -116,7 +111,7 @@ void redirectSneaking(CallbackInfoReturnable<Boolean> cir) {
116111
if (self != Lambda.getMc().player) return;
117112

118113
if (self.input == null) return;
119-
cir.setReturnValue(EventFlow.post(new MovementEvent.Sneak(self.input.sneaking)).getSneak());
114+
cir.setReturnValue(EventFlow.post(new MovementEvent.Sneak(self.input.playerInput.sneak())).getSneak());
120115
}
121116

122117
/**
@@ -139,12 +134,12 @@ void onTickPost(CallbackInfo ci) {
139134
EventFlow.post(new TickEvent.Player.Post());
140135
}
141136

142-
@Redirect(method = "tickNewAi", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getYaw()F"))
137+
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getYaw()F"))
143138
float fixHeldItemYaw(ClientPlayerEntity instance) {
144139
return Objects.requireNonNullElse(RotationManager.getHandYaw(), instance.getYaw());
145140
}
146141

147-
@Redirect(method = "tickNewAi", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getPitch()F"))
142+
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getPitch()F"))
148143
float fixHeldItemPitch(ClientPlayerEntity instance) {
149144
return Objects.requireNonNullElse(RotationManager.getHandPitch(), instance.getPitch());
150145
}
@@ -154,24 +149,27 @@ void onSwingHandPre(Hand hand, CallbackInfo ci) {
154149
if (EventFlow.post(new PlayerEvent.SwingHand(hand)).isCanceled()) ci.cancel();
155150
}
156151

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

162157
/**
163158
* Prevents the game from closing Guis when the player is in a nether portal
164159
* <pre>{@code
165-
* if (this.client.currentScreen != null && !this.client.currentScreen.shouldPause() && !(this.client.currentScreen instanceof DeathScreen)) {
160+
* if (this.client.currentScreen != null
161+
* && !this.client.currentScreen.shouldPause()
162+
* && !(this.client.currentScreen instanceof DeathScreen)
163+
* && !(this.client.currentScreen instanceof CreditsScreen)) {
166164
* if (this.client.currentScreen instanceof HandledScreen) {
167165
* this.closeHandledScreen();
168166
* }
169167
*
170-
* this.client.setScreen((Screen)null);
168+
* this.client.setScreen(null);
171169
* }
172170
* }</pre>
173171
*/
174-
@Redirect(method = "updateNausea", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;"))
172+
@Redirect(method = "tickNausea", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;"))
175173
Screen keepScreensInPortal(MinecraftClient instance) {
176174
if (PortalGui.INSTANCE.isEnabled()) return null;
177175
else return client.currentScreen;

0 commit comments

Comments
 (0)