Skip to content

add changes to make compilable for hk 1.5.12331#164

Open
SFGrenade wants to merge 13 commits intohk-modding:masterfrom
SFGrenade:hk-beta-branch-unity-6-update
Open

add changes to make compilable for hk 1.5.12331#164
SFGrenade wants to merge 13 commits intohk-modding:masterfrom
SFGrenade:hk-beta-branch-unity-6-update

Conversation

@SFGrenade
Copy link
Member

some todos left

@SFGrenade
Copy link
Member Author

will note some changes i saw in more comments

@SFGrenade
Copy link
Member Author

for the MAPI itself: currently the language get isn't hooked

@SFGrenade
Copy link
Member Author

SFGrenade commented Dec 16, 2025

  • ShowFPS worked flawlessly, it's also a really simple mod, practically not interacting with MAPI aside from being loaded
  • SFCore needed changes
    • using TMPro; -> using TMProOld;
    • On.UIManager.RefreshAchievementsList -> On.MenuAchievementsList.PreInit
    • AchievementsList.achievements is private now
    • DesktopPlatform.EncryptedSharedData -> DesktopPlatform.RoamingSharedData
      • this is for achievements, menu styles and some shit like that
  • HollowKnightAchievementManager needed changes
    • Language -> TeamCherry.Localization edit: fixed with type "forwarding"

@SFGrenade
Copy link
Member Author

SFGrenade commented Dec 16, 2025

for HollowKnightAchievementManager: Satchel seems to work fine, BUT trying to create a menu errors with

[ERROR]:[API] - Error creating menu for ICustomMenuMod Hollow Knight Achievement Manager
[ERROR]:[API] - System.TypeLoadException: Could not resolve type with token 01000102 from typeref (expected class 'Language.Language' in assembly 'Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null')
[ERROR]:[API] -   at Modding.Menu.MenuBuilder.AddControls (Modding.Menu.IContentLayout layout, Modding.Menu.INavigationGraph navgraph, System.Action`1[T] action) [0x00033] in <60d0b6c1d8f94e9285cfca026540e40c>:0 
[ERROR]:[API] -   at Modding.Menu.MenuBuilder.AddControls (Modding.Menu.IContentLayout layout, System.Action`1[T] action) [0x00008] in <60d0b6c1d8f94e9285cfca026540e40c>:0 
[ERROR]:[API] -   at Satchel.BetterMenus.Utils.AddBackButton (Modding.Menu.MenuBuilder builder, Satchel.BetterMenus.Menu menuRef, UnityEngine.UI.MenuButton& backButton) [0x00014] in D:\Coding\serverknights\Satchel\BetterMenus\Utils.cs:82 
[ERROR]:[API] -   at Satchel.BetterMenus.Menu.GetMenuScreen (MenuScreen _returnScreen) [0x00060] in D:\Coding\serverknights\Satchel\BetterMenus\Menu.cs:145 
[ERROR]:[API] -   at HollowKnightAchievementManager.HollowKnightAchievementManager.GetMenuScreen (MenuScreen modListMenu, System.Nullable`1[T] toggleDelegates) [0x00015] in source\src\HollowKnightAchievementManager.cs:104 
[ERROR]:[API] -   at Modding.ModListMenu.<InitMenuCreation>b__3_4 (Modding.Menu.ContentArea c) [0x00413] in <60d0b6c1d8f94e9285cfca026540e40c>:0 

will probably need a fix (and another commit) here in MAPI thanks to Language.Language
nvm, it's on Satchel, but it is thanks to Language.Language

… place, so it can just be created

- no clue what to do with `Language.Language.Get(key)` though
- but that requires all `TeamCherry.Localization.Language` to be done dynamically, via strings, as *all* references to it are replaced, even ones manually written here
@SFGrenade SFGrenade changed the title add changes to make compilable for hk 1.5.12301 add changes to make compilable for hk 1.5.12331 Dec 26, 2025
KunalGehlot added a commit to KunalGehlot/api that referenced this pull request Feb 11, 2026
Hollow Knight received a major update on Feb 5, 2026 (build 12459) which
upgraded the engine to Unity 6 (6000.0.61f1) and introduced significant
changes to controller input handling, localization, and scene management.
This commit updates the Modding API to compile against and work correctly
with the new game binaries.

Build system changes (Assembly-CSharp.csproj):
- Use FrameworkPathOverride to resolve assemblies from Vanilla/ directory
  instead of individual HintPath references (required for Unity 6 which
  ships additional TeamCherry.* and System.* assemblies)
- Add System.Memory NuGet package (Unity 6 uses ReadOnlySpan<byte> in
  Texture2D.LoadImage)
- Remove Newtonsoft.Json from dependencies (now shipped with the game)
- Remove mscorlib override (no longer needed with Unity 6 runtime)

Localization system rewrite:
- Delete Patches/Language.cs: The Language class moved from the global
  namespace to TeamCherry.Localization in HK 1.5. The old MonoMod patch
  targeting "global::Language.Language" no longer resolves.
- Add Language/Language.cs: A backwards-compatible shim in the
  Language.Language namespace that delegates to TeamCherry.Localization
  via reflection, with MonoModLinkFrom to redirect existing mod references.
  This allows mods using Language.Language.Get() to continue working without
  recompilation.
- Update ModHooks.cs LanguageGet to call Language.Language.GetInternal
  instead of the removed Patches.Language.GetInternal.

Mod loading initialization (StartManager.cs):
- Move mod loading bootstrap from OnScreenDebugInfo.Awake to
  StartManager.Awake. The OnScreenDebugInfo component was removed in
  HK 1.5, so it can no longer serve as the mod loading entry point.
- Delete Patches/OnScreenDebugInfo.cs (component no longer exists in game).
- Rewrite StartManager.Start to match the new HK 1.5 startup sequence:
  language verification, PlayerPrefs loading, and scene load state
  management.
- Add deferred Menu_Title scene loading: when mod preloading is active,
  wait for mods to finish loading before transitioning to Menu_Title
  instead of using the allowSceneActivation pattern.

HeroController patches updated for HK 1.5 game logic:
- rb2d.velocity → rb2d.linearVelocity (Unity 6 Rigidbody2D API change)
- wallSlideVibrationPlayer.Stop() → vibrationCtrl.StopWallSlide()
  (HK 1.5 replaced individual vibration players with HeroVibrationController)
- Attack(): Add grubberfly beam (charm_35) support for wall slashes,
  change health check from == to >= for grubberfly beam activation on
  normal/up/down attacks (matches upstream game logic)
- SoulGain(): String literals to nameof() for PlayerData fields
- LookForQueueInput(): Remove duplicate CanDash() call
- TakeDamage(): Rename flag → carefreeShouldStopDamage for clarity,
  string literals to nameof(), add explicit returns after death/hazard
  coroutine starts to match upstream flow control, fix ternary null check
  on damage angle
- OrigDashVector(): Simplify ternary for bump velocity readability

InputHandler.OnGUI rewrite:
- Replace direct Cursor.visible/Cursor.lockState manipulation with calls
  to the game's SetCursorVisible() method. This preserves the
  OnCursorVisibilityChange event and proper cursor lock management through
  SetCursorEnabled(), fixing controller detection and connection mode
  switching that was broken by the old approach.

GameManager patches:
- Import TeamCherry.SharedUtils.Encryption (class moved in HK 1.5)
- Add SetPausedState() MonoModIgnore declaration
- Rewrite PauseToggleDynamicMenu to match HK 1.5 pause/unpause flow
  (SetPausedState calls, reordered input prevention, reduced wait times)
- SceneManager.UnloadSceneAsync → SceneManager.UnloadScene (API change)

SceneManager patches:
- Replace DrawBlackBorders() full replacement with OnCameraAspectChanged()
  hook. HK 1.5 refactored border drawing into the camera aspect change
  handler with persistent border transforms (borderLeft/Right/Up/Down)
  instead of instantiating new GameObjects each time.
- The ModHooks.OnDrawBlackBorders hook is preserved by collecting the
  border transforms after orig_OnCameraAspectChanged runs.

Other patch updates:
- MenuSetting.cs: Add new HK 1.5 settings enum values (SwitchFrameCap,
  Dithering, Noise, ControllerRumble, HudVisibility, CameraShake,
  NativeInput, XInput, MFi)
- MenuButtonList.cs: Null-conditional on menuButtonLists to prevent
  NullReferenceException during early UIManager initialization
- UIManager.cs: Add ADVANCED_GAMEPAD_MENU and ADVANCED_VIDEO_MENU to
  MainMenuState enum
- TakeDamage.cs: Fix Multiplier ternary to match HK 1.5 operand order
- PlayMakerUnity2DProxy.cs: Add explicit this. qualifier
- ModHooks.cs: Add bounds checking on version string split to handle
  version formats with fewer than 4 segments

Version: hollowknight.version updated to 1.5.12459

Tested on macOS (Apple M2 Pro) with Unity 6000.0.61f1:
- Game launches and reaches title screen
- Mod menu appears in Options with working mod list
- CompassAlwaysOn and GatheringSwarmAlwaysOn load and function correctly
- Controller support works (USB/Bluetooth, vibration, mode switching)
- Scene transitions, pause menu, and settings menus all functional
- No errors in Player.log or ModLog.txt

Builds on work started in PR hk-modding#164 by SFGrenade.
Closes hk-modding#169.
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