3
3
import dev .igalaxy .takeitslow .TakeItSlow ;
4
4
import net .minecraft .client .Minecraft ;
5
5
import net .minecraft .client .player .LocalPlayer ;
6
+ import net .minecraft .world .entity .LivingEntity ;
6
7
import net .minecraft .world .level .GameType ;
7
8
import org .spongepowered .asm .mixin .Final ;
8
9
import org .spongepowered .asm .mixin .Mixin ;
16
17
public abstract class LocalPlayerMixin {
17
18
@ Shadow @ Final protected Minecraft minecraft ;
18
19
@ Shadow public abstract boolean isUnderWater ();
19
- @ Shadow public abstract void setSprinting (boolean bl );
20
-
21
- @ ModifyVariable (method = "setSprinting(Z)V" , at = @ At ("HEAD" ))
22
- private boolean modifySetSprinting (boolean bl ) {
23
- GameType localPlayerMode = ((MultiPlayerGameModeAccessor )this .minecraft .gameMode ).getLocalPlayerMode ();
24
-
25
- boolean allowSwimming = TakeItSlow .getConfig ().allowSwimming ;
26
- boolean allowCreative = TakeItSlow .getConfig ().allowCreative ;
27
-
28
- boolean isUnderwater = this .isUnderWater ();
29
- boolean isCreative = localPlayerMode == GameType .CREATIVE ;
30
- boolean isSpectator = localPlayerMode == GameType .SPECTATOR ;
31
-
32
- return (isUnderwater && bl && allowSwimming ) || (isCreative && bl && allowCreative ) || (isSpectator && bl && allowCreative );
33
- }
34
20
35
21
@ Inject (method = "updateIsUnderwater" , at = @ At ("TAIL" ))
36
22
private void modifyUpdateIsUnderwater (CallbackInfoReturnable <Boolean > cir ) {
@@ -41,7 +27,7 @@ private void modifyUpdateIsUnderwater(CallbackInfoReturnable<Boolean> cir) {
41
27
boolean isSpectator = localPlayerMode == GameType .SPECTATOR ;
42
28
43
29
if (!isUnderwater && !isCreative && !isSpectator ) {
44
- this .setSprinting (false );
30
+ (( LivingEntity ) ( Object ) this ) .setSprinting (false );
45
31
}
46
32
}
47
33
}
0 commit comments