aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoringle <inglettronald@gmail.com>2022-09-24 21:09:29 -0500
committeringle <inglettronald@gmail.com>2022-09-24 21:09:29 -0500
commit71a57e6635a4fe8e09e2af06cab7f9f8ce2f69f3 (patch)
tree063cde1960f1b10e664dbdb9e8f66952e4d242e2 /src
parentca61e7812d1153eaefff289815df66be75ba1b80 (diff)
downloadDulkirMod-71a57e6635a4fe8e09e2af06cab7f9f8ce2f69f3.tar.gz
DulkirMod-71a57e6635a4fe8e09e2af06cab7f9f8ce2f69f3.tar.bz2
DulkirMod-71a57e6635a4fe8e09e2af06cab7f9f8ce2f69f3.zip
Added rotationless drink
Diffstat (limited to 'src')
-rw-r--r--src/main/java/dulkirmod/mixins/ItemRendererMixin.java6
-rw-r--r--src/main/kotlin/dulkirmod/config/Config.kt8
-rw-r--r--src/main/kotlin/dulkirmod/features/ItemAnimations.kt15
3 files changed, 29 insertions, 0 deletions
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
@@ -176,6 +176,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",
description = "Will not visually update gui, but reopening settings menu will show default 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