From 8cbf2671c3c11b0b13ed093b94936796e4bcad0e Mon Sep 17 00:00:00 2001 From: Mixces Date: Tue, 26 Dec 2023 12:23:31 -0600 Subject: [PATCH] Fixed some issues that I created part 69 :D --- .../config/ItemPositionAdvancedSettings.java | 51 ------------ .../config/OldAnimationsSettings.java | 77 +++++++++++++++++-- .../hooks/AnimationExportUtils.java | 18 ++--- .../hooks/OverflowConfigData.java | 8 +- .../mixin/EntityLivingBaseMixin.java | 13 ++-- .../ItemRendererMixin_CustomPositions.java | 8 +- 6 files changed, 97 insertions(+), 78 deletions(-) diff --git a/src/main/java/org/polyfrost/overflowanimations/config/ItemPositionAdvancedSettings.java b/src/main/java/org/polyfrost/overflowanimations/config/ItemPositionAdvancedSettings.java index 4f2fab0..926e8af 100644 --- a/src/main/java/org/polyfrost/overflowanimations/config/ItemPositionAdvancedSettings.java +++ b/src/main/java/org/polyfrost/overflowanimations/config/ItemPositionAdvancedSettings.java @@ -33,44 +33,6 @@ public class ItemPositionAdvancedSettings { ) public float itemSwingPositionZ = 0.0F; - @Slider( - name = "Item Swing Speed", - min = -2.5F, max = 2.5F, - category = "Customize Item Positions", subcategory = "Item Swing Position", - instant = true - ) - public float itemSwingSpeed = 0.0F; - - @Slider( - name = "Haste Swing Speed", - min = -2.5F, max = 2.5F, - category = "Customize Item Positions", subcategory = "Item Swing Position", - instant = true - ) - public float itemSwingSpeedHaste = 0.0F; - - @Slider( - name = "Miner's Fatigue Swing Speed", - min = -2.5F, max = 2.5F, - category = "Customize Item Positions", subcategory = "Item Swing Position", - instant = true - ) - public float itemSwingSpeedFatigue = 0.0F; - - @Checkbox( - name = "Scale Item Swing Based on Item Scale", - description = "Scales the swing animation based on the scale of the item.", - category = "Customize Item Positions", subcategory = "Item Swing Position" - ) - public static boolean shouldScaleSwing = false; - - @Checkbox( - name = "Disable Swing Translation", - description = "Disables the swing translation.", - category = "Customize Item Positions", subcategory = "Item Swing Position" - ) - public static boolean disableSwing = false; - @Button( name = "Reset Item Swing Transformations", text = "Reset", @@ -81,23 +43,10 @@ public class ItemPositionAdvancedSettings { itemSwingPositionX = 0.0F; itemSwingPositionY = 0.0F; itemSwingPositionZ = 0.0F; - itemSwingSpeed = 0.0F; - itemSwingSpeedHaste = 0.0F; - itemSwingSpeedFatigue = 0.0F; - shouldScaleSwing = false; - disableSwing = false; - ignoreHaste = false; OldAnimationsSettings.INSTANCE.save(); OldAnimationsSettings.INSTANCE.openGui(); }); - @Checkbox( - name = "Ignore Haste Speed", - description = "Ignores the haste speed when setting a custom item swing speed.", - category = "Customize Item Positions", subcategory = "Item Swing Position" - ) - public static boolean ignoreHaste = false; - // Eating/Drinking Position @Slider( name = "Eating/Drinking X Position", diff --git a/src/main/java/org/polyfrost/overflowanimations/config/OldAnimationsSettings.java b/src/main/java/org/polyfrost/overflowanimations/config/OldAnimationsSettings.java index f0c7feb..103cfe0 100644 --- a/src/main/java/org/polyfrost/overflowanimations/config/OldAnimationsSettings.java +++ b/src/main/java/org/polyfrost/overflowanimations/config/OldAnimationsSettings.java @@ -358,12 +358,11 @@ public class OldAnimationsSettings extends Config { advancedSettings.itemSwingPositionX = 0.0F; advancedSettings.itemSwingPositionY = 0.0F; advancedSettings.itemSwingPositionZ = 0.0F; - advancedSettings.itemSwingSpeed = 0.0F; - advancedSettings.itemSwingSpeedHaste = 0.0F; - advancedSettings.itemSwingSpeedFatigue = 0.0F; - ItemPositionAdvancedSettings.shouldScaleSwing = false; - ItemPositionAdvancedSettings.disableSwing = false; - ItemPositionAdvancedSettings.ignoreHaste = false; + itemSwingSpeed = 0.0F; + itemSwingSpeedHaste = 0.0F; + itemSwingSpeedFatigue = 0.0F; + swingSetting = 0; + ignoreHaste = false; advancedSettings.consumePositionX = 0.0F; advancedSettings.consumePositionY = 0.0F; @@ -445,6 +444,7 @@ public void transferDulkirItemPositions() { openGui(); } + // Item Positions Customization @Slider( name = "Item X Position", @@ -502,6 +502,69 @@ public void transferDulkirItemPositions() { ) public float itemScale = 0.0F; + @Slider( + name = "Item Swing Speed", + min = -2.0F, max = 1.0F, + category = "Customize Item Positions", subcategory = "Item Swing", + instant = true + ) + public float itemSwingSpeed = 0.0F; + + @Slider( + name = "Haste Swing Speed", + min = -2.0F, max = 1.0F, + category = "Customize Item Positions", subcategory = "Item Swing", + instant = true + ) + public float itemSwingSpeedHaste = 0.0F; + + @Slider( + name = "Miner's Fatigue Swing Speed", + min = -2.0F, max = 1.0F, + category = "Customize Item Positions", subcategory = "Item Swing", + instant = true + ) + public float itemSwingSpeedFatigue = 0.0F; + + @Dropdown( + name = "Swing Behavior", + description = "Allows you to choose between the regular swing behavior, scaled swing behavior, and no swing translation!", + category = "Customize Item Positions", subcategory = "Item Swing", + options = {"Default", "Smart Item Swing Scaling", "Disable Swing Translation"} + ) + public int swingSetting = 0; + + @Button( + name = "Reset Item Swing Speed", + text = "Reset", + category = "Customize Item Positions", subcategory = "Item Swing" + ) + Runnable resetSpeed = (() -> { + Minecraft.getMinecraft().displayGuiScreen(null); + itemSwingSpeed = 0.0F; + itemSwingSpeedHaste = 0.0F; + itemSwingSpeedFatigue = 0.0F; + swingSetting = 0; + ignoreHaste = false; + ignoreFatigue = false; + OldAnimationsSettings.INSTANCE.save(); + OldAnimationsSettings.INSTANCE.openGui(); + }); + + @Checkbox( + name = "Ignore Haste Speed", + description = "Ignores the haste speed when setting a custom item swing speed.", + category = "Customize Item Positions", subcategory = "Item Swing" + ) + public static boolean ignoreHaste = false; + + @Checkbox( + name = "Ignore Mining Fatigue Speed", + description = "Ignores the mining fatigue speed when setting a custom item swing speed.", + category = "Customize Item Positions", subcategory = "Item Swing" + ) + public static boolean ignoreFatigue = false; + @Button( name = "Reset Item Transformations", text = "Reset", @@ -524,7 +587,7 @@ public void transferDulkirItemPositions() { name = "Advanced Item Customization Settings", description = "Customize all sorts of item positions!", location = PageLocation.BOTTOM, - category = "Customize Item Positions", subcategory = "Item Position" + category = "Customize Item Positions", subcategory = "Advanced Settings" ) public static ItemPositionAdvancedSettings advancedSettings = new ItemPositionAdvancedSettings(); diff --git a/src/main/java/org/polyfrost/overflowanimations/hooks/AnimationExportUtils.java b/src/main/java/org/polyfrost/overflowanimations/hooks/AnimationExportUtils.java index c50181e..84cf229 100644 --- a/src/main/java/org/polyfrost/overflowanimations/hooks/AnimationExportUtils.java +++ b/src/main/java/org/polyfrost/overflowanimations/hooks/AnimationExportUtils.java @@ -68,10 +68,10 @@ public static void importOverflow(OverflowConfigData importSettings) { advanced.itemSwingPositionX = importSettings.itemSwingPositionX; advanced.itemSwingPositionY = importSettings.itemSwingPositionY; advanced.itemSwingPositionZ = importSettings.itemSwingPositionZ; - advanced.itemSwingSpeed = importSettings.itemSwingSpeed; - advanced.itemSwingSpeedHaste = importSettings.itemSwingSpeedHaste; - advanced.itemSwingSpeedFatigue = importSettings.itemSwingSpeedFatigue; - ItemPositionAdvancedSettings.shouldScaleSwing = importSettings.shouldScaleSwing; + settings.itemSwingSpeed = importSettings.itemSwingSpeed; + settings.itemSwingSpeedHaste = importSettings.itemSwingSpeedHaste; + settings.itemSwingSpeedFatigue = importSettings.itemSwingSpeedFatigue; + settings.swingSetting = importSettings.shouldScaleSwing ? 1 : 0; advanced.consumePositionX = importSettings.consumePositionX; advanced.consumePositionY = importSettings.consumePositionY; advanced.consumePositionZ = importSettings.consumePositionZ; @@ -110,11 +110,11 @@ public static void importDulkir(DulkirConfigData importSettings) { settings.itemRotationPitch = importSettings.getPitch(); settings.itemRotationRoll = importSettings.getRoll(); settings.itemScale = importSettings.getSize(); - advanced.itemSwingSpeed = importSettings.getSpeed(); - advanced.itemSwingSpeedHaste = importSettings.getSpeed(); - advanced.itemSwingSpeedFatigue = importSettings.getSpeed(); - ItemPositionAdvancedSettings.ignoreHaste = importSettings.getIgnoreHaste(); - ItemPositionAdvancedSettings.shouldScaleSwing = importSettings.getScaleSwing(); + settings.itemSwingSpeed = importSettings.getSpeed(); + settings.itemSwingSpeedHaste = importSettings.getSpeed(); + settings.itemSwingSpeedFatigue = importSettings.getSpeed(); + OldAnimationsSettings.ignoreHaste = importSettings.getIgnoreHaste(); + settings.swingSetting = importSettings.getScaleSwing() ? 1 : 0; ItemPositionAdvancedSettings.shouldScaleEat = importSettings.getDrinkingFix() == 2; settings.save(); diff --git a/src/main/java/org/polyfrost/overflowanimations/hooks/OverflowConfigData.java b/src/main/java/org/polyfrost/overflowanimations/hooks/OverflowConfigData.java index e51afdf..dc694dd 100644 --- a/src/main/java/org/polyfrost/overflowanimations/hooks/OverflowConfigData.java +++ b/src/main/java/org/polyfrost/overflowanimations/hooks/OverflowConfigData.java @@ -98,10 +98,10 @@ public OverflowConfigData() { itemSwingPositionX = advanced.itemSwingPositionX; itemSwingPositionY = advanced.itemSwingPositionY; itemSwingPositionZ = advanced.itemSwingPositionZ; - itemSwingSpeed = advanced.itemSwingSpeed; - itemSwingSpeedHaste = advanced.itemSwingSpeedHaste; - itemSwingSpeedFatigue = advanced.itemSwingSpeedFatigue; - shouldScaleSwing = ItemPositionAdvancedSettings.shouldScaleSwing; + itemSwingSpeed = settings.itemSwingSpeed; + itemSwingSpeedHaste = settings.itemSwingSpeedHaste; + itemSwingSpeedFatigue = settings.itemSwingSpeedFatigue; + shouldScaleSwing = settings.swingSetting == 1; consumePositionX = advanced.consumePositionX; consumePositionY = advanced.consumePositionY; consumePositionZ = advanced.consumePositionZ; diff --git a/src/main/java/org/polyfrost/overflowanimations/mixin/EntityLivingBaseMixin.java b/src/main/java/org/polyfrost/overflowanimations/mixin/EntityLivingBaseMixin.java index 83ae53f..11313fc 100644 --- a/src/main/java/org/polyfrost/overflowanimations/mixin/EntityLivingBaseMixin.java +++ b/src/main/java/org/polyfrost/overflowanimations/mixin/EntityLivingBaseMixin.java @@ -34,12 +34,15 @@ public void modifySwingSpeed(CallbackInfoReturnable cir) { OldAnimationsSettings settings = OldAnimationsSettings.INSTANCE; ItemPositionAdvancedSettings advanced = OldAnimationsSettings.advancedSettings; if (OldAnimationsSettings.globalPositions && settings.enabled) { - if (isPotionActive(Potion.digSpeed) && !ItemPositionAdvancedSettings.ignoreHaste) { - cir.setReturnValue(Math.max((6 - (1 + getActivePotionEffect(Potion.digSpeed).getAmplifier())) * (int) Math.exp(-advanced.itemSwingSpeedHaste), 1)); - } else if (isPotionActive(Potion.digSlowdown)) { - cir.setReturnValue(Math.max((6 + (1 + getActivePotionEffect(Potion.digSlowdown).getAmplifier())) * 2 * (int) Math.exp(-advanced.itemSwingSpeedFatigue), 1)); + if (isPotionActive(Potion.digSpeed) && !OldAnimationsSettings.ignoreHaste) { + cir.setReturnValue( + (6 - (1 + getActivePotionEffect(Potion.digSpeed).getAmplifier())) * Math.max((int) Math.exp(-settings.itemSwingSpeedHaste), 1)); + } else if (isPotionActive(Potion.digSlowdown) && !OldAnimationsSettings.ignoreFatigue) { + cir.setReturnValue( + (6 + (1 + getActivePotionEffect(Potion.digSlowdown).getAmplifier())) * 2 * Math.max((int) Math.exp(-settings.itemSwingSpeedFatigue), 1)); } else { - cir.setReturnValue(Math.max((int) (6 * Math.exp(-advanced.itemSwingSpeed)), 1)); + cir.setReturnValue( + 6 * Math.max((int) Math.exp(-settings.itemSwingSpeed), 1)); } } } diff --git a/src/main/java/org/polyfrost/overflowanimations/mixin/ItemRendererMixin_CustomPositions.java b/src/main/java/org/polyfrost/overflowanimations/mixin/ItemRendererMixin_CustomPositions.java index 669046e..7805084 100644 --- a/src/main/java/org/polyfrost/overflowanimations/mixin/ItemRendererMixin_CustomPositions.java +++ b/src/main/java/org/polyfrost/overflowanimations/mixin/ItemRendererMixin_CustomPositions.java @@ -1,5 +1,6 @@ package org.polyfrost.overflowanimations.mixin; +import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.ItemRenderer; @@ -7,6 +8,7 @@ import net.minecraft.util.MathHelper; import org.polyfrost.overflowanimations.config.ItemPositionAdvancedSettings; import org.polyfrost.overflowanimations.config.OldAnimationsSettings; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -19,6 +21,8 @@ public class ItemRendererMixin_CustomPositions { @Shadow private ItemStack itemToRender; + @Shadow @Final private Minecraft mc; + @Inject(method = "transformFirstPersonItem(FF)V", at = @At("HEAD"), cancellable = true) public void itemTransform(float equipProgress, float swingProgress, CallbackInfo ci) { OldAnimationsSettings settings = OldAnimationsSettings.INSTANCE; @@ -49,10 +53,10 @@ public void swingTransformations(float swingProgress, CallbackInfo ci) { OldAnimationsSettings settings = OldAnimationsSettings.INSTANCE; ItemPositionAdvancedSettings advanced = OldAnimationsSettings.advancedSettings; if (OldAnimationsSettings.globalPositions && settings.enabled) { - if (ItemPositionAdvancedSettings.disableSwing) { + if (settings.swingSetting == 2) { ci.cancel(); } else { - float scale = (1.0F + (ItemPositionAdvancedSettings.shouldScaleSwing ? settings.itemScale : 0.0F)); + float scale = (1.0F + (settings.swingSetting == 1 ? settings.itemScale : 0.0F)); float f = (-0.4f * (1.0F + advanced.itemSwingPositionX)) * MathHelper.sin(MathHelper.sqrt_float(swingProgress) * (float) Math.PI) * scale; float f1 = 0.2f * (1.0F - advanced.itemSwingPositionY) * MathHelper.sin(MathHelper.sqrt_float(swingProgress) * (float) Math.PI * 2.0f) * scale; float f2 = -0.2f * (1.0F + advanced.itemSwingPositionZ) * MathHelper.sin(swingProgress * (float) Math.PI) * scale;