Skip to content

Commit 08860c9

Browse files
committed
Overhaul riding exhaustion tweak
1 parent b4fe335 commit 08860c9

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,9 @@ public static class EntitiesCategory
478478

479479
@Config.RequiresMcRestart
480480
@Config.Name("Riding Exhaustion")
481-
@Config.Comment("Enables depleting saturation when riding mounts")
482-
public boolean utRidingExhaustionToggle = false;
481+
@Config.Comment("Sets the exhaustion value per cm when riding mounts")
482+
@Config.RangeDouble(min = 0.0D, max = 1.0D)
483+
public double utRidingExhaustion = 0.0D;
483484

484485
@Config.RequiresMcRestart
485486
@Config.Name("Soulbound Vexes")

src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
452452
case "mixins.tweaks.entities.loot.json":
453453
return UTConfigTweaks.ENTITIES.utCreeperMusicDiscsToggle;
454454
case "mixins.tweaks.entities.saturation.json":
455-
return UTConfigTweaks.ENTITIES.utRidingExhaustionToggle;
455+
return UTConfigTweaks.ENTITIES.utRidingExhaustion != 0.0D;
456456
case "mixins.tweaks.entities.spawning.caps.json":
457457
return UTConfigTweaks.ENTITIES.SPAWN_CAPS.utSpawnCapsToggle;
458458
case "mixins.tweaks.entities.spawning.creeper.confetti.json":
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
11
package mod.acgaming.universaltweaks.tweaks.entities.saturation.mixin;
22

3+
import net.minecraft.entity.EntityLivingBase;
34
import net.minecraft.entity.player.EntityPlayer;
5+
import net.minecraft.util.math.MathHelper;
6+
import net.minecraft.world.World;
47

8+
import mod.acgaming.universaltweaks.UniversalTweaks;
9+
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
510
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
611
import org.spongepowered.asm.mixin.Mixin;
712
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;
915

1016
@Mixin(EntityPlayer.class)
11-
public class UTRidingExhaustionMixin
17+
public abstract class UTRidingExhaustionMixin extends EntityLivingBase
1218
{
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)
1520
{
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+
}
1737
}
1838
}

0 commit comments

Comments
 (0)