Skip to content

Arm/Item Tilt and Offset - #7

Merged
Flapjacck merged 3 commits into
mainfrom
xyz
Oct 16, 2026
Merged

Flapjacck merged 3 commits into
mainfrom
xyz

Conversation

@Flapjacck

Copy link
Copy Markdown
Owner

Add XYZ Offsets and Tilt Controls for Held Item & Bare Hand

Summary

Adds full positional offset (X, Y, Z) and tilt (Pitch, Roll) controls for both the held item model and the bare hand (empty-handed arm) in first-person view. Item and arm transforms are now independent of each other. Also fixes a slider display bug where negative values were clamped to 0.10 on the track label, and fixes edit box truncation for values longer than 4 characters.

Changes

ItemTweaksConfig.java

  • Added HELD_ITEM_OFFSET_X/Y/Z — positional offsets for the held item (range -1.0 to 1.0)
  • Added ITEM_TILT_PITCH / ITEM_TILT_ROLL — X and Z rotation for the held item (range -90 to 90°)
  • Added ARM_OFFSET_X/Y/Z — separate positional offsets for the bare arm (range -1.0 to 1.0)
  • Added ARM_TILT_PITCH / ARM_TILT_ROLL — X and Z rotation for the bare arm (range -90 to 90°)
  • Added TILT_MIN, TILT_MAX, DEFAULT_TILT constants and clampTilt() method
  • All new values persist to config/swing.json and reset via the Reset button

ItemInHandRendererMixin.java

  • Applies held item transform in order: translate (offset) → rotate (pitch, then roll) → scale
  • Rotations use Axis.XP and Axis.ZP from com.mojang.math.Axis

ItemInHandRendererArmMixin.java

  • Switched from shared HELD_ITEM_OFFSET_* to the new separate ARM_OFFSET_* fields
  • Added ARM_TILT_PITCH and ARM_TILT_ROLL rotations to both renderRightHand and renderLeftHand
  • All arm transforms remain gated behind APPLY_HAND_SCALE (no effect while holding an item)

SwingSettingsScreen.java

  • Bug fix: FloatSlider label rendering now uses Mth.clamp(toFloat(), min, max) instead of ItemTweaksConfig.clamp(), so negative offset and tilt values display correctly on the track
  • Bug fix: Edit box maxLength increased from 4 to 6 to accommodate values like -1.00 and -45.00
  • Six scrollable sections: Swing Speed, Held Item Scale, Item Offsets, Item Tilt, Arm Offsets, Arm Tilt
  • Each section has a slider + numeric input box per axis; scroll area expands to 292px of travel
  • FloatSlider now accepts explicit min/max so offset and tilt sliders use their own range

Testing

  • Verified ./gradlew build succeeds with no errors
  • Confirmed all new values persist across sessions via config/swing.json
  • Reset button correctly zeroes all offset and tilt fields

UI Changes

  • GUI panel size unchanged; new controls scroll into view below existing ones
  • New sections in scroll order: Item Offsets (X/Y/Z) → Item Tilt (Pitch/Roll) → Arm Offsets (X/Y/Z) → Arm Tilt (Pitch/Roll)
  • Arm offset and tilt controls only take effect when Apply Hand Scale is ON

@Flapjacck
Flapjacck merged commit 2763bf0 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.

1 participant