aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod
diff options
context:
space:
mode:
authoringle <inglettronald@gmail.com>2022-09-26 00:51:45 -0500
committeringle <inglettronald@gmail.com>2022-09-26 00:51:45 -0500
commite60fbdd688ff5257c7720c94945e38f1fce5810e (patch)
tree34bd54107a5089b0b4b36183e90a2e16b4c1a7bb /src/main/kotlin/dulkirmod
parentb8bcc4ad43589bf76f57e3af75907eb66e81ffb8 (diff)
downloadDulkirMod-e60fbdd688ff5257c7720c94945e38f1fce5810e.tar.gz
DulkirMod-e60fbdd688ff5257c7720c94945e38f1fce5810e.tar.bz2
DulkirMod-e60fbdd688ff5257c7720c94945e38f1fce5810e.zip
More adjustments to drinking animations
Diffstat (limited to 'src/main/kotlin/dulkirmod')
-rw-r--r--src/main/kotlin/dulkirmod/DulkirMod.kt4
-rw-r--r--src/main/kotlin/dulkirmod/config/Config.kt16
-rw-r--r--src/main/kotlin/dulkirmod/features/ItemAnimations.kt41
3 files changed, 53 insertions, 8 deletions
diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt
index 4817b20..c6e765b 100644
--- a/src/main/kotlin/dulkirmod/DulkirMod.kt
+++ b/src/main/kotlin/dulkirmod/DulkirMod.kt
@@ -83,8 +83,8 @@ class DulkirMod {
companion object {
const val MOD_ID = "dulkirmod"
const val MOD_NAME = "Dulkir Mod"
- const val MOD_VERSION = "1.0.2"
- const val CHAT_PREFIX = "§b§l<§fDulkirMod§b§l>§r"
+ const val MOD_VERSION = "1.0.3"
+ const val CHAT_PREFIX = "<DulkirMod>"
val mc: Minecraft = Minecraft.getMinecraft()
var config = Config
diff --git a/src/main/kotlin/dulkirmod/config/Config.kt b/src/main/kotlin/dulkirmod/config/Config.kt
index 71f7fe0..a409d91 100644
--- a/src/main/kotlin/dulkirmod/config/Config.kt
+++ b/src/main/kotlin/dulkirmod/config/Config.kt
@@ -176,12 +176,13 @@ 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"
+ type = PropertyType.SELECTOR,
+ name = "Drinking Fix",
+ description = "Pick how to handle drinking animations.",
+ category = "Animations",
+ options = ["No fix", "Rotationless", "Fixed"]
)
- var rotationlessdrink = true
+ var drinkingSelector = 2
@Property(
type = PropertyType.BUTTON,
@@ -206,6 +207,11 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod") {
fun init() {
initialize()
addDependency("customMessage", "throttleNotifier")
+
+ setCategoryDescription(
+ "Custom Animations",
+ "All settings that are related to custom animations. Mostly help from Aton."
+ )
}
}
diff --git a/src/main/kotlin/dulkirmod/features/ItemAnimations.kt b/src/main/kotlin/dulkirmod/features/ItemAnimations.kt
index f143289..a86e947 100644
--- a/src/main/kotlin/dulkirmod/features/ItemAnimations.kt
+++ b/src/main/kotlin/dulkirmod/features/ItemAnimations.kt
@@ -4,6 +4,7 @@ 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.item.ItemStack
import net.minecraft.util.MathHelper
import kotlin.math.exp
import kotlin.math.pow
@@ -61,8 +62,12 @@ object ItemAnimations {
return true
}
+ /**
+ * Directly referenced by the ItemRendereMixin. If enabled will scale the potion drink animation.
+ * Returns whether custom animation was performed.
+ */
fun rotationlessDrink(clientPlayer : AbstractClientPlayer, partialTicks : Float): Boolean {
- if (!config.rotationlessdrink) return false
+ if (!config.customAnimations || config.drinkingSelector != 1) 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)
@@ -72,4 +77,38 @@ object ItemAnimations {
GlStateManager.translate(0.0f, f2, 0.0f)
return true
}
+
+ /**
+ * Directly referenced by the ItemRendereMixin. If enabled will scale the potion drink animation.
+ * Returns whether custom animation was performed.
+ */
+ fun scaledDrinking(clientPlayer: AbstractClientPlayer, partialTicks: Float, itemToRender: ItemStack): Boolean {
+ if (!config.customAnimations || config.drinkingSelector != 2) return false
+ val f: Float = clientPlayer.itemInUseCount.toFloat() - partialTicks + 1.0f
+ val f1: Float = f / itemToRender.maxItemUseDuration.toFloat()
+ var f2 = MathHelper.abs(MathHelper.cos(f / 4.0f * Math.PI.toFloat()) * 0.1f)
+
+ if (f1 >= 0.8f) {
+ f2 = 0.0f
+ }
+
+ // Transform to correct rotation center
+ val newX = (0.56f * (1 + config.customX)).toFloat()
+ val newY = (-0.52f * (1 - config.customY)).toFloat()
+ val newZ = (-0.71999997f * (1 + config.customZ)).toFloat()
+ GlStateManager.translate(-0.56f, 0.52f, 0.71999997f)
+ GlStateManager.translate(newX, newY, newZ)
+
+ GlStateManager.translate(0.0f, f2, 0.0f)
+ val f3 = 1.0f - f1.toDouble().pow(27.0).toFloat()
+ GlStateManager.translate(f3 * 0.6f, f3 * -0.5f, f3 * 0.0f)
+ GlStateManager.rotate(f3 * 90.0f, 0.0f, 1.0f, 0.0f)
+ GlStateManager.rotate(f3 * 10.0f, 1.0f, 0.0f, 0.0f)
+ GlStateManager.rotate(f3 * 30.0f, 0.0f, 0.0f, 1.0f)
+
+ // Transform back
+ GlStateManager.translate(0.56f, -0.52f, -0.71999997f)
+ GlStateManager.translate(-newX, -newY, -newZ)
+ return true
+ }
} \ No newline at end of file