From 71a57e6635a4fe8e09e2af06cab7f9f8ce2f69f3 Mon Sep 17 00:00:00 2001 From: ingle Date: Sat, 24 Sep 2022 21:09:29 -0500 Subject: Added rotationless drink --- src/main/java/dulkirmod/mixins/ItemRendererMixin.java | 6 ++++++ src/main/kotlin/dulkirmod/config/Config.kt | 8 ++++++++ src/main/kotlin/dulkirmod/features/ItemAnimations.kt | 15 +++++++++++++++ 3 files changed, 29 insertions(+) (limited to 'src/main') diff --git a/src/main/java/dulkirmod/mixins/ItemRendererMixin.java b/src/main/java/dulkirmod/mixins/ItemRendererMixin.java index 9db5c9d..54b4d45 100644 --- a/src/main/java/dulkirmod/mixins/ItemRendererMixin.java +++ b/src/main/java/dulkirmod/mixins/ItemRendererMixin.java @@ -1,6 +1,7 @@ package dulkirmod.mixins; import dulkirmod.features.ItemAnimations; +import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.ItemRenderer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -19,4 +20,9 @@ public class ItemRendererMixin { public void useTransform(float swingProgress, CallbackInfo ci){ if (ItemAnimations.INSTANCE.scaledSwing(swingProgress)) ci.cancel(); } + + @Inject(method ={"performDrinking"}, at = @At("HEAD"), cancellable = true) + public void drinkTransform(AbstractClientPlayer clientPlayer, float partialTicks, CallbackInfo ci) { + if (ItemAnimations.INSTANCE.rotationlessDrink(clientPlayer, partialTicks)) ci.cancel(); + } } diff --git a/src/main/kotlin/dulkirmod/config/Config.kt b/src/main/kotlin/dulkirmod/config/Config.kt index 17baee9..71f7fe0 100644 --- a/src/main/kotlin/dulkirmod/config/Config.kt +++ b/src/main/kotlin/dulkirmod/config/Config.kt @@ -175,6 +175,14 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod") { ) var ignoreHaste = true + @Property( + type = PropertyType.CHECKBOX, + name = "Rotationless Drink", + description = "Stops you from breaking your arm every time you get thirsty", + category = "Animations" + ) + var rotationlessdrink = true + @Property( type = PropertyType.BUTTON, name = "Reset Item Values", diff --git a/src/main/kotlin/dulkirmod/features/ItemAnimations.kt b/src/main/kotlin/dulkirmod/features/ItemAnimations.kt index c685f16..f143289 100644 --- a/src/main/kotlin/dulkirmod/features/ItemAnimations.kt +++ b/src/main/kotlin/dulkirmod/features/ItemAnimations.kt @@ -1,9 +1,12 @@ package dulkirmod.features import dulkirmod.DulkirMod.Companion.config +import dulkirmod.DulkirMod.Companion.mc +import net.minecraft.client.entity.AbstractClientPlayer import net.minecraft.client.renderer.GlStateManager import net.minecraft.util.MathHelper import kotlin.math.exp +import kotlin.math.pow /** * Module to change the appearance of held items. @@ -57,4 +60,16 @@ object ItemAnimations { GlStateManager.translate(f, f1, f2) return true } + + fun rotationlessDrink(clientPlayer : AbstractClientPlayer, partialTicks : Float): Boolean { + if (!config.rotationlessdrink) return false + val f: Float = clientPlayer.itemInUseCount.toFloat() - partialTicks + 1.0f + val f1: Float = f / mc.thePlayer.heldItem.maxItemUseDuration.toFloat() + var f2 = MathHelper.abs(MathHelper.cos(f / 4.0f * 3.1415927f) * 0.1f) + if (f1 >= 0.8f) { + f2 = 0.0f + } + GlStateManager.translate(0.0f, f2, 0.0f) + return true + } } \ No newline at end of file -- cgit