Skip to content

Issue 2 | Constant Haste - #5

Merged
Flapjacck merged 3 commits into
mainfrom
issue-2
Oct 16, 2026
Merged

Flapjacck merged 3 commits into
mainfrom
issue-2

Conversation

@Flapjacck

Copy link
Copy Markdown
Owner

Fix: Make Swing Speed Constant by Adding Ignore Haste Toggle

Problem

The swing animation speed was not constant throughout different islands or when using different gear sets. This was because Minecraft's haste and mining fatigue potion effects directly affect the LivingEntity#getCurrentSwingDuration() return value, causing the visual swing animation to vary even when the player had the same swing speed multiplier configured.

Example:

  • No haste: base duration = 6 ticks → animation plays at original speed
  • Haste I: base duration = 5 ticks → animation plays faster (shorter duration)

This meant a player with the same swing speed multiplier would see different animation speeds depending on their active potion effects.

Solution

Added an IGNORE_HASTE toggle feature that:

  1. Config option — New boolean flag IGNORE_HASTE (default: false) persisted to config/swing.json
  2. Mixin logic — When enabled, the swing duration mixin uses the constant vanilla base of 6 ticks instead of the haste-affected value, then applies the multiplier on top
  3. UI toggle — Full-width button in the settings panel (/swing) to toggle "Ignore Haste: ON / OFF" with live updates
  4. Persistence — Setting automatically saves to config on Close and loads on restart

Changes

  • ItemTweaksConfig.java

    • Added DEFAULT_IGNORE_HASTE = false constant
    • Added IGNORE_HASTE static field with documentation
    • Updated resetToVanilla(), load(), save(), and FileData to handle the new field
  • LivingEntitySwingMixin.java

    • Added VANILLA_BASE_DURATION = 6 constant
    • Modified swing duration logic: when IGNORE_HASTE is true, always start from 6 ticks instead of the haste-modified value
    • Ensures animation speed is identical across all gear sets and islands
  • SwingSettingsScreen.java

    • Expanded panel height (178 → 214 px) to accommodate new toggle
    • Added hasteToggleBtn button between swing speed and held item scale rows
    • Added toggleIgnoreHaste() and hasteToggleLabel() helper methods
    • Updated Reset button to also reset the toggle state
    • Adjusted layout constants proportionally

Testing

✅ Gradle build passes successfully
✅ All three files compile without errors
✅ Config persistence working (JSON serialization/deserialization)

Closes #2

@Flapjacck
Flapjacck merged commit c1d64ad into main Oct 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

swing speed not constant

1 participant