Skip to content

Commit

Permalink
Overhaul riding exhaustion tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Feb 8, 2024
1 parent b4fe335 commit 08860c9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,9 @@ public static class EntitiesCategory

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

@Config.RequiresMcRestart
@Config.Name("Soulbound Vexes")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
case "mixins.tweaks.entities.loot.json":
return UTConfigTweaks.ENTITIES.utCreeperMusicDiscsToggle;
case "mixins.tweaks.entities.saturation.json":
return UTConfigTweaks.ENTITIES.utRidingExhaustionToggle;
return UTConfigTweaks.ENTITIES.utRidingExhaustion != 0.0D;
case "mixins.tweaks.entities.spawning.caps.json":
return UTConfigTweaks.ENTITIES.SPAWN_CAPS.utSpawnCapsToggle;
case "mixins.tweaks.entities.spawning.creeper.confetti.json":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
package mod.acgaming.universaltweaks.tweaks.entities.saturation.mixin;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(EntityPlayer.class)
public class UTRidingExhaustionMixin
public abstract class UTRidingExhaustionMixin extends EntityLivingBase
{
@Redirect(method = "addMovementStat", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/EntityPlayer;isRiding()Z"))
public boolean utRidingExhaustion(EntityPlayer player)
protected UTRidingExhaustionMixin(World worldIn)
{
return player.isRiding() || UTConfigTweaks.ENTITIES.utRidingExhaustionToggle;
super(worldIn);
}

@Inject(method = "addMountedMovementStat", at = @At(value = "TAIL"))
public void utRidingExhaustion(double speedX, double speedY, double speedZ, CallbackInfo ci)
{
if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTRidingExhaustion ::: Add exhaustion while riding");
if (this.isRiding())
{
int i = Math.round(MathHelper.sqrt(speedX * speedX + speedY * speedY + speedZ * speedZ));

if (i > 0)
{
((EntityPlayer) (Object) this).addExhaustion((float) (i * UTConfigTweaks.ENTITIES.utRidingExhaustion));
}
}
}
}

0 comments on commit 08860c9

Please sign in to comment.