aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/features
diff options
context:
space:
mode:
authoringle <inglettronald@gmail.com>2022-09-24 14:57:07 -0500
committeringle <inglettronald@gmail.com>2022-09-24 14:57:07 -0500
commitcce0c0c05e1f73902e474d9a63f6b1f302cd5176 (patch)
tree2a46288933f3a8c2a181d97e4ca157e1d04ece21 /src/main/kotlin/dulkirmod/features
parent442926d9bcea191ac4f852d3d0770288c2a5bca7 (diff)
downloadDulkirMod-cce0c0c05e1f73902e474d9a63f6b1f302cd5176.tar.gz
DulkirMod-cce0c0c05e1f73902e474d9a63f6b1f302cd5176.tar.bz2
DulkirMod-cce0c0c05e1f73902e474d9a63f6b1f302cd5176.zip
Imported customAnimations courtesy of Aton.
Also add Nametag Cleaner.
Diffstat (limited to 'src/main/kotlin/dulkirmod/features')
-rw-r--r--src/main/kotlin/dulkirmod/features/ItemAnimations.kt60
-rw-r--r--src/main/kotlin/dulkirmod/features/NametagCleaner.kt29
2 files changed, 89 insertions, 0 deletions
diff --git a/src/main/kotlin/dulkirmod/features/ItemAnimations.kt b/src/main/kotlin/dulkirmod/features/ItemAnimations.kt
new file mode 100644
index 0000000..c685f16
--- /dev/null
+++ b/src/main/kotlin/dulkirmod/features/ItemAnimations.kt
@@ -0,0 +1,60 @@
+package dulkirmod.features
+
+import dulkirmod.DulkirMod.Companion.config
+import net.minecraft.client.renderer.GlStateManager
+import net.minecraft.util.MathHelper
+import kotlin.math.exp
+
+/**
+ * Module to change the appearance of held items.
+ *
+ * This module uses the EntityLivingBase and ItemRenderer Mixins to function.
+ * Because only this module and no others are supposed to modify their behavior direct references are used instead of
+ * forge events.
+ *
+ * @author Aton - THANK YOU
+ */
+object ItemAnimations {
+ /**
+ * Directly referenced hook for the itemTransform Inject in the ItemRenderer Mixin.
+ * Takes care of scaling and positioning the held item.
+ */
+ fun itemTransforHook(equipProgress: Float, swingProgress: Float): Boolean {
+ if (!config.customAnimations) return false
+ val newSize = (0.4f * exp(config.customSize))
+ val newX = (0.56f * (1 + config.customX))
+ val newY = (-0.52f * (1 - config.customY))
+ val newZ = (-0.71999997f * (1 + config.customZ))
+ GlStateManager.translate(newX, newY, newZ)
+ GlStateManager.translate(0.0f, equipProgress * -0.6f, 0.0f)
+
+ //Rotation
+ GlStateManager.rotate(config.customPitch, 1.0f, 0.0f, 0.0f)
+ GlStateManager.rotate(config.customYaw, 0.0f, 1f, 0f)
+ GlStateManager.rotate(config.customRoll, 0f, 0f, 1f)
+
+ GlStateManager.rotate(45f, 0.0f, 1f, 0f)
+
+ val f = MathHelper.sin(swingProgress * swingProgress * Math.PI.toFloat())
+ val f1 = MathHelper.sin(MathHelper.sqrt_float(swingProgress) * Math.PI.toFloat())
+ GlStateManager.rotate(f * -20.0f, 0.0f, 1.0f, 0.0f)
+ GlStateManager.rotate(f1 * -20.0f, 0.0f, 0.0f, 1.0f)
+ GlStateManager.rotate(f1 * -80.0f, 1.0f, 0.0f, 0.0f)
+ GlStateManager.scale(newSize, newSize, newSize)
+ return true
+ }
+
+ /**
+ * Directly referenced by the ItemRendereMixin. If enabled will scale the item swing animation.
+ * Returns whether custom animation was performed.
+ */
+ fun scaledSwing(swingProgress: Float): Boolean {
+ if (!config.customAnimations || !config.doesScaleSwing) return false
+ val scale = exp(config.customSize)
+ val f = -0.4f * MathHelper.sin(MathHelper.sqrt_float(swingProgress) * Math.PI.toFloat()) * scale
+ val f1 = 0.2f * MathHelper.sin(MathHelper.sqrt_float(swingProgress) * Math.PI.toFloat() * 2.0f) * scale
+ val f2 = -0.2f * MathHelper.sin(swingProgress * Math.PI.toFloat()) * scale
+ GlStateManager.translate(f, f1, f2)
+ return true
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/features/NametagCleaner.kt b/src/main/kotlin/dulkirmod/features/NametagCleaner.kt
new file mode 100644
index 0000000..e1202b9
--- /dev/null
+++ b/src/main/kotlin/dulkirmod/features/NametagCleaner.kt
@@ -0,0 +1,29 @@
+package dulkirmod.features
+
+import dulkirmod.DulkirMod.Companion.config
+import dulkirmod.DulkirMod.Companion.mc
+import dulkirmod.utils.Utils.stripColorCodes
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraftforge.client.event.RenderLivingEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+/**
+ * Code inspired heavily by Skytils.
+ *
+ * TODO: fix
+ */
+object NametagCleaner {
+ @SubscribeEvent
+ fun onRenderLivingPre(event: RenderLivingEvent.Pre<*>) {
+ if (event.entity is EntityArmorStand && event.entity.hasCustomName()) {
+ if (config.hideTags) {
+ val name = stripColorCodes(event.entity.customNameTag)
+ println(name)
+ if (name.contains("ABILITY DAMAGE") || name.contains("DEFENSE") || name.contains("DAMAGE")
+ || name.contains("Superboom TNT") || name.contains ("Blessing")) {
+ mc.theWorld.removeEntity(event.entity)
+ }
+ }
+ }
+ }
+}