1
1
package mod .acgaming .universaltweaks .tweaks .entities .saturation .mixin ;
2
2
3
+ import net .minecraft .entity .EntityLivingBase ;
3
4
import net .minecraft .entity .player .EntityPlayer ;
5
+ import net .minecraft .util .math .MathHelper ;
6
+ import net .minecraft .world .World ;
4
7
8
+ import mod .acgaming .universaltweaks .UniversalTweaks ;
9
+ import mod .acgaming .universaltweaks .config .UTConfigGeneral ;
5
10
import mod .acgaming .universaltweaks .config .UTConfigTweaks ;
6
11
import org .spongepowered .asm .mixin .Mixin ;
7
12
import org .spongepowered .asm .mixin .injection .At ;
8
- import org .spongepowered .asm .mixin .injection .Redirect ;
13
+ import org .spongepowered .asm .mixin .injection .Inject ;
14
+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
9
15
10
16
@ Mixin (EntityPlayer .class )
11
- public class UTRidingExhaustionMixin
17
+ public abstract class UTRidingExhaustionMixin extends EntityLivingBase
12
18
{
13
- @ Redirect (method = "addMovementStat" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/entity/player/EntityPlayer;isRiding()Z" ))
14
- public boolean utRidingExhaustion (EntityPlayer player )
19
+ protected UTRidingExhaustionMixin (World worldIn )
15
20
{
16
- return player .isRiding () || UTConfigTweaks .ENTITIES .utRidingExhaustionToggle ;
21
+ super (worldIn );
22
+ }
23
+
24
+ @ Inject (method = "addMountedMovementStat" , at = @ At (value = "TAIL" ))
25
+ public void utRidingExhaustion (double speedX , double speedY , double speedZ , CallbackInfo ci )
26
+ {
27
+ if (UTConfigGeneral .DEBUG .utDebugToggle ) UniversalTweaks .LOGGER .debug ("UTRidingExhaustion ::: Add exhaustion while riding" );
28
+ if (this .isRiding ())
29
+ {
30
+ int i = Math .round (MathHelper .sqrt (speedX * speedX + speedY * speedY + speedZ * speedZ ));
31
+
32
+ if (i > 0 )
33
+ {
34
+ ((EntityPlayer ) (Object ) this ).addExhaustion ((float ) (i * UTConfigTweaks .ENTITIES .utRidingExhaustion ));
35
+ }
36
+ }
17
37
}
18
38
}
0 commit comments