diff options
author | ingle <inglettronald@gmail.com> | 2022-09-24 14:57:07 -0500 |
---|---|---|
committer | ingle <inglettronald@gmail.com> | 2022-09-24 14:57:07 -0500 |
commit | cce0c0c05e1f73902e474d9a63f6b1f302cd5176 (patch) | |
tree | 2a46288933f3a8c2a181d97e4ca157e1d04ece21 /src/main/kotlin/dulkirmod | |
parent | 442926d9bcea191ac4f852d3d0770288c2a5bca7 (diff) | |
download | DulkirMod-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')
-rw-r--r-- | src/main/kotlin/dulkirmod/DulkirMod.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/config/Config.kt | 142 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/events/ChatEvent.kt | 4 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/ItemAnimations.kt | 60 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/NametagCleaner.kt | 29 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/utils/Utils.kt | 7 |
6 files changed, 241 insertions, 3 deletions
diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt index e05a06a..192a582 100644 --- a/src/main/kotlin/dulkirmod/DulkirMod.kt +++ b/src/main/kotlin/dulkirmod/DulkirMod.kt @@ -6,6 +6,7 @@ import dulkirmod.command.HelpCommand import dulkirmod.command.SettingsCommand import dulkirmod.config.Config import dulkirmod.events.ChatEvent +import dulkirmod.features.NametagCleaner import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -57,6 +58,7 @@ class DulkirMod { // REGISTER EVENTS HERE MinecraftForge.EVENT_BUS.register(this) MinecraftForge.EVENT_BUS.register(ChatEvent()) + MinecraftForge.EVENT_BUS.register(NametagCleaner) keyBinds.forEach(ClientRegistry::registerKeyBinding) } diff --git a/src/main/kotlin/dulkirmod/config/Config.kt b/src/main/kotlin/dulkirmod/config/Config.kt index b8dc20a..17baee9 100644 --- a/src/main/kotlin/dulkirmod/config/Config.kt +++ b/src/main/kotlin/dulkirmod/config/Config.kt @@ -53,6 +53,148 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod") { protectedText = false ) var customMessage: String = "i am being throttled zzz" + + @Property( + type = PropertyType.SWITCH, + name = "Hide Extra Nametags", + description = "Prevents some nametags not covered by skytils \"Hide non-starred nametags\" from rendering.", + category = "General" + ) + var hideTags = false + + // CUSTOM ANIMATIONS + @Property( + type = PropertyType.SWITCH, + name = "Custom Animations", + description = "Change the look of your held item", + category = "Animations" + ) + var customAnimations = false + + @Property( + type = PropertyType.DECIMAL_SLIDER, + name = "Size", + description = "Scales the size of your currently held item. Default: 0", + category = "Animations", + minF = -1.5f, + maxF = 1.5f, + decimalPlaces = 2 + ) + var customSize = 0f + + @Property( + type = PropertyType.CHECKBOX, + name = "Scale Swing", + description = "Also scale the size of the swing animation.", + category = "Animations" + ) + var doesScaleSwing = true + + @Property( + type = PropertyType.DECIMAL_SLIDER, + name = "X", + description = "Moves the held item. Default: 0", + category = "Animations", + minF = -1.5f, + maxF = 1.5f, + decimalPlaces = 2 + ) + var customX = 0f + + @Property( + type = PropertyType.DECIMAL_SLIDER, + name = "Y", + description = "Moves the held item. Default: 0", + category = "Animations", + minF = -1.5f, + maxF = 1.5f, + decimalPlaces = 2 + ) + var customY = 0f + + @Property( + type = PropertyType.DECIMAL_SLIDER, + name = "Z", + description = "Moves the held item. Default: 0", + category = "Animations", + minF = -1.5f, + maxF = 1.5f, + decimalPlaces = 2 + ) + var customZ = 0f + + @Property( + type = PropertyType.DECIMAL_SLIDER, + name = "Yaw", + description = "Rotates your held item. Default: 0", + category = "Animations", + minF = -180f, + maxF = 180f, + decimalPlaces = 0 + ) + var customYaw = 0f + + @Property( + type = PropertyType.DECIMAL_SLIDER, + name = "Pitch", + description = "Rotates your held item. Default: 0", + category = "Animations", + minF = -180f, + maxF = 180f, + decimalPlaces = 0 + ) + var customPitch = 0f + + @Property( + type = PropertyType.DECIMAL_SLIDER, + name = "Roll", + description = "Rotates your held item. Default: 0", + category = "Animations", + minF = -180f, + maxF = 180f, + decimalPlaces = 0 + ) + var customRoll = 0f + + @Property( + type = PropertyType.DECIMAL_SLIDER, + name = "Speed", + description = "Speed of the swing animation.", + category = "Animations", + minF = -2f, + maxF = 1f, + decimalPlaces = 2 + ) + var customSpeed = 0f + + @Property( + type = PropertyType.CHECKBOX, + name = "Ignore Haste", + description = "Makes the chosen speed override haste modifiers.", + category = "Animations" + ) + var ignoreHaste = true + + @Property( + type = PropertyType.BUTTON, + name = "Reset Item Values", + description = "Will not visually update gui, but reopening settings menu will show default values", + category = "Animations" + ) + fun demoButton() { + customSize = 0f + customX = 0f + customY = 0f + customZ = 0f + customRoll = 0f + customPitch = 0f + customYaw = 0f + doesScaleSwing = true + ignoreHaste = true + customSpeed = 0f + } + + fun init() { initialize() addDependency("customMessage", "throttleNotifier") diff --git a/src/main/kotlin/dulkirmod/events/ChatEvent.kt b/src/main/kotlin/dulkirmod/events/ChatEvent.kt index 03f8dd8..de180fa 100644 --- a/src/main/kotlin/dulkirmod/events/ChatEvent.kt +++ b/src/main/kotlin/dulkirmod/events/ChatEvent.kt @@ -1,6 +1,7 @@ package dulkirmod.events import dulkirmod.DulkirMod +import dulkirmod.utils.Utils.stripColorCodes import net.minecraftforge.client.event.ClientChatReceivedEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -17,7 +18,4 @@ class ChatEvent { DulkirMod.mc.thePlayer.sendChatMessage("/pc " + DulkirMod.config.customMessage) } } - private fun stripColorCodes(string: String): String { - return string.replace("§.".toRegex(), "") - } }
\ No newline at end of file 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) + } + } + } + } +} diff --git a/src/main/kotlin/dulkirmod/utils/Utils.kt b/src/main/kotlin/dulkirmod/utils/Utils.kt new file mode 100644 index 0000000..766a78b --- /dev/null +++ b/src/main/kotlin/dulkirmod/utils/Utils.kt @@ -0,0 +1,7 @@ +package dulkirmod.utils + +object Utils { + fun stripColorCodes(string: String): String { + return string.replace("§.".toRegex(), "") + } +}
\ No newline at end of file |