From 89b5c1f9a98e430a6749844a3bf7ffd580d01865 Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Tue, 6 Feb 2024 20:48:34 +0100 Subject: [PATCH] Implement riding exhaustion tweak --- README.md | 1 + .../universaltweaks/config/UTConfigTweaks.java | 15 ++++++++++----- .../universaltweaks/core/UTLoadingPlugin.java | 3 +++ .../mixin/UTRidingExhaustionMixin.java | 18 ++++++++++++++++++ .../mixins.tweaks.entities.saturation.json | 7 +++++++ 5 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/entities/saturation/mixin/UTRidingExhaustionMixin.java create mode 100644 src/main/resources/mixins.tweaks.entities.saturation.json diff --git a/README.md b/README.md index 91bd0b62..ca36899d 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,7 @@ All changes are toggleable via config files. * **Remove Realms Button:** Removes the redundant Minecraft Realms button from the main menu * **Remove Recipe Book:** Removes the recipe book button from GUIs * **Remove Snooper:** Forcefully turns off the snooper and hides the snooper settings button from the options menu +* **Riding Exhaustion:** Enables depleting saturation when riding mounts * **Sapling Behavior:** Allows customization of sapling behavior while utilizing an optimized method * **Sea Level:** Sets the default height of the overworld's sea level * **Selected Item Tooltip Height:** Sets the Y value of the selected item tooltip, displayed when held items are changed diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java index bba8a656..5795396d 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java @@ -476,6 +476,11 @@ public static class EntitiesCategory @Config.RangeDouble(min = 0.0D, max = 1.0D) public double utRabbitToastChance = 0.0D; + @Config.RequiresMcRestart + @Config.Name("Riding Exhaustion") + @Config.Comment("Enables depleting saturation when riding mounts") + public boolean utRidingExhaustionToggle = false; + @Config.RequiresMcRestart @Config.Name("Soulbound Vexes") @Config.Comment("Summoned vexes will also die when their summoner is killed") @@ -1163,7 +1168,7 @@ public static class MiscCategory @Config.Name("Default Difficulty") @Config.Comment("Sets the default difficulty for newly generated worlds") public EnumDifficulty utDefaultDifficulty = EnumDifficulty.NORMAL; - + @Config.RequiresMcRestart @Config.Name("Disable Advancements") @Config.Comment("Prevents the advancement system from loading entirely") @@ -1384,7 +1389,7 @@ public static class LightningCategory @Config.Name("No Lightning Flash") @Config.Comment("Disables the flashing of skybox and ground brightness on lightning bolt strikes") public boolean utLightningFlashToggle = false; - + @Config.RequiresMcRestart @Config.Name("No Lightning Item Destruction") @Config.Comment("Prevents lightning bolts from destroying items") @@ -1636,17 +1641,17 @@ public static class PerformanceCategory "May have side effects such as slower chunk generation" }) public boolean utWorldLoadingToggle = false; - + @Config.RequiresMcRestart @Config.Name("Mute Advancement Errors") @Config.Comment("Silences advancement errors") public boolean utAdvancementCheckToggle = false; - + @Config.RequiresMcRestart @Config.Name("Mute Ore Dictionary Errors") @Config.Comment("Silences ore dictionary errors") public boolean utOreDictionaryCheckToggle = false; - + @Config.RequiresMcRestart @Config.Name("Mute Texture Map Errors") @Config.Comment("Silences texture map errors") diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java index 5ce71635..3261bf24 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java @@ -204,6 +204,7 @@ public List getMixinConfigs() configs.add("mixins.tweaks.entities.damage.velocity.json"); configs.add("mixins.tweaks.entities.despawning.json"); configs.add("mixins.tweaks.entities.loot.json"); + configs.add("mixins.tweaks.entities.saturation.json"); configs.add("mixins.tweaks.entities.spawning.caps.json"); configs.add("mixins.tweaks.entities.spawning.creeper.confetti.json"); configs.add("mixins.tweaks.entities.spawning.golem.json"); @@ -444,6 +445,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig) return UTConfigTweaks.ENTITIES.utMobDespawnToggle; case "mixins.tweaks.entities.loot.json": return UTConfigTweaks.ENTITIES.utCreeperMusicDiscsToggle; + case "mixins.tweaks.entities.saturation.json": + return UTConfigTweaks.ENTITIES.utRidingExhaustionToggle; case "mixins.tweaks.entities.spawning.caps.json": return UTConfigTweaks.ENTITIES.SPAWN_CAPS.utSpawnCapsToggle; case "mixins.tweaks.entities.spawning.creeper.confetti.json": diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/saturation/mixin/UTRidingExhaustionMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/saturation/mixin/UTRidingExhaustionMixin.java new file mode 100644 index 00000000..aa62eecd --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/saturation/mixin/UTRidingExhaustionMixin.java @@ -0,0 +1,18 @@ +package mod.acgaming.universaltweaks.tweaks.entities.saturation.mixin; + +import net.minecraft.entity.player.EntityPlayer; + +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; + +@Mixin(EntityPlayer.class) +public class UTRidingExhaustionMixin +{ + @Redirect(method = "addMovementStat", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/EntityPlayer;isRiding()Z")) + public boolean utRidingExhaustion(EntityPlayer player) + { + return player.isRiding() || UTConfigTweaks.ENTITIES.utRidingExhaustionToggle; + } +} \ No newline at end of file diff --git a/src/main/resources/mixins.tweaks.entities.saturation.json b/src/main/resources/mixins.tweaks.entities.saturation.json new file mode 100644 index 00000000..04b1c09c --- /dev/null +++ b/src/main/resources/mixins.tweaks.entities.saturation.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.tweaks.entities.saturation.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": ["UTRidingExhaustionMixin"] +} \ No newline at end of file