aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--src/main/java/dulkirmod/mixins/ItemRendererMixin.java22
-rw-r--r--src/main/java/dulkirmod/mixins/MixinEntity.java11
-rw-r--r--src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java31
-rw-r--r--src/main/java/dulkirmod/mixins/MixinRendererManager.java6
-rw-r--r--src/main/kotlin/dulkirmod/DulkirMod.kt2
-rw-r--r--src/main/kotlin/dulkirmod/config/Config.kt142
-rw-r--r--src/main/kotlin/dulkirmod/events/ChatEvent.kt4
-rw-r--r--src/main/kotlin/dulkirmod/features/ItemAnimations.kt60
-rw-r--r--src/main/kotlin/dulkirmod/features/NametagCleaner.kt29
-rw-r--r--src/main/kotlin/dulkirmod/utils/Utils.kt7
-rw-r--r--src/main/resources/mixins.dulkirmod.json3
12 files changed, 313 insertions, 7 deletions
diff --git a/README.md b/README.md
index 8aea3b0..b0b359a 100644
--- a/README.md
+++ b/README.md
@@ -7,6 +7,7 @@ Features:
- Hide Healer Fairy.
- Throttle Notifier
- custom message
-- FULLY FEATURED SETTINGS MENU.
+- Custom Animations (courtesy of Aton)
+- Nametag cleaner for misc. dungeon stuff that is non-starred.
This is epic.
diff --git a/src/main/java/dulkirmod/mixins/ItemRendererMixin.java b/src/main/java/dulkirmod/mixins/ItemRendererMixin.java
new file mode 100644
index 0000000..9db5c9d
--- /dev/null
+++ b/src/main/java/dulkirmod/mixins/ItemRendererMixin.java
@@ -0,0 +1,22 @@
+package dulkirmod.mixins;
+
+import dulkirmod.features.ItemAnimations;
+import net.minecraft.client.renderer.ItemRenderer;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+@Mixin(value = {ItemRenderer.class})
+public class ItemRendererMixin {
+
+ @Inject(method = {"transformFirstPersonItem(FF)V"}, at = @At("HEAD"), cancellable = true)
+ public void itemTransform(float equipProgress, float swingProgress, CallbackInfo ci) {
+ if (ItemAnimations.INSTANCE.itemTransforHook(equipProgress, swingProgress)) ci.cancel();
+ }
+
+ @Inject(method = {"doItemUsedTransformations"}, at = @At("HEAD"), cancellable = true)
+ public void useTransform(float swingProgress, CallbackInfo ci){
+ if (ItemAnimations.INSTANCE.scaledSwing(swingProgress)) ci.cancel();
+ }
+}
diff --git a/src/main/java/dulkirmod/mixins/MixinEntity.java b/src/main/java/dulkirmod/mixins/MixinEntity.java
new file mode 100644
index 0000000..4116661
--- /dev/null
+++ b/src/main/java/dulkirmod/mixins/MixinEntity.java
@@ -0,0 +1,11 @@
+package dulkirmod.mixins;
+
+import net.minecraft.entity.Entity;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+
+@Mixin(value = {Entity.class}, priority = 800)
+public abstract class MixinEntity {
+ @Shadow
+ public abstract boolean equals(Object paramObject);
+}
diff --git a/src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java b/src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java
new file mode 100644
index 0000000..43a6c27
--- /dev/null
+++ b/src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java
@@ -0,0 +1,31 @@
+package dulkirmod.mixins;
+
+
+import dulkirmod.DulkirMod;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+@Mixin({EntityLivingBase.class})
+public abstract class MixinEntityLivingBase extends MixinEntity {
+
+ @Shadow public abstract boolean isPotionActive(Potion potionIn);
+
+ @Shadow public abstract PotionEffect getActivePotionEffect(Potion potionIn);
+
+ @Inject(method = {"getArmSwingAnimationEnd()I"}, at = @At("HEAD"), cancellable = true)
+ public void adjustSwingLength(CallbackInfoReturnable<Integer> cir) {
+ if (!DulkirMod.Companion.getConfig().getCustomAnimations()) return;
+ int length = DulkirMod.Companion.getConfig().getIgnoreHaste() ? 6 : this.isPotionActive(Potion.digSpeed) ?
+ 6 - (1 + this.getActivePotionEffect(Potion.digSpeed).getAmplifier()) :
+ (this.isPotionActive(Potion.digSlowdown) ?
+ 6 + (1 + this.getActivePotionEffect(Potion.digSlowdown).getAmplifier()) * 2 :
+ 6);
+ cir.setReturnValue(Math.max((int)(length* Math.exp(-DulkirMod.Companion.getConfig().getCustomSpeed())), 1));
+ }
+}
diff --git a/src/main/java/dulkirmod/mixins/MixinRendererManager.java b/src/main/java/dulkirmod/mixins/MixinRendererManager.java
index b545107..c695ed2 100644
--- a/src/main/java/dulkirmod/mixins/MixinRendererManager.java
+++ b/src/main/java/dulkirmod/mixins/MixinRendererManager.java
@@ -36,9 +36,9 @@ public class MixinRendererManager {
NBTTagCompound properties = skullOwner.getCompoundTag("Properties");
if (properties.hasKey("textures")) {
//if (properties.getTagList("textures", 10).tagCount() >= 1) {
- if ("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTZjM2UzMWNmYzY2NzMzMjc1YzQyZmNmYjVkOWE0NDM0MmQ2NDNiNTVjZDE0YzljNzdkMjczYTIzNTIifX19"
- .equals(properties.getTagList("textures", 10).getCompoundTagAt(0).getString("Value")))
- cir.cancel();
+ if ("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTZjM2UzMWNmYzY2NzMzMjc1YzQyZmNmYjVkOWE0NDM0MmQ2NDNiNTVjZDE0YzljNzdkMjczYTIzNTIifX19"
+ .equals(properties.getTagList("textures", 10).getCompoundTagAt(0).getString("Value")))
+ cir.cancel();
//}
}
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
diff --git a/src/main/resources/mixins.dulkirmod.json b/src/main/resources/mixins.dulkirmod.json
index ee75ec9..4921d12 100644
--- a/src/main/resources/mixins.dulkirmod.json
+++ b/src/main/resources/mixins.dulkirmod.json
@@ -4,9 +4,12 @@
"package": "dulkirmod.mixins",
"refmap": "mixins.dulkirmod.refmap.json",
"client": [
+ "ItemRendererMixin",
"MixinRendererManager"
],
"mixins": [
+ "MixinEntity",
+ "MixinEntityLivingBase",
"MixinWorld"
]
}