66
77#include < amethyst/Log.h>
88#include < amethyst/HookManager.h>
9+ #include < amethyst/InputManager.h>
910
1011#include < minecraft/src/common/world/item/Item.h>
1112#include < minecraft/src-client/common/client/renderer/screen/MinecraftUIRenderContext.h>
1920#include " F3Screen.h"
2021
2122HookManager hookManager;
22-
2323Item::_appendFormattedHovertext _Item_appendFormattedHovertext;
2424
2525static void Item_appendFormattedHovertext (Item* self, const ItemStackBase& itemStack, Level& level, std::string& text, uint8_t a5) {
@@ -49,60 +49,23 @@ extern "C" __declspec(dllexport) void OnRenderUI(ScreenView * screenView, Minecr
4949 if (shouldRenderF3) f3Screen.Render (ctx);
5050}
5151
52- extern " C" __declspec(dllexport) void Shutdown () {
53- hookManager.Shutdown ();
54- }
55-
56- VanillaClientInputMappingFactory::__createBaseNormalGamePlayKeyboardAndMouseMapping __createBaseNormalGamePlayKeyboardAndMouseMapping;
57-
58- std::string testButtonId = " button.test" ;
59- int32_t keyNum = 0x72 ;
60- bool addedAlready = false ;
61-
62- static void * _createBaseNormalGamePlayKeyboardAndMouseMapping (VanillaClientInputMappingFactory* self, KeyboardInputMapping* keyboardMap, MouseInputMapping* mouseMap) {
63- void * ret = __createBaseNormalGamePlayKeyboardAndMouseMapping (self, keyboardMap, mouseMap);
64- // self->_bindActionToKeyboardAndMouseInput(keyboardMap, mouseMap, &testButtonId, (Remapping::ActionEnum)100, FocusImpact::Neutral);
65-
66- // Log::Info("\n_createBaseNormalGamePlayKeyboardAndMouseMapping");
67-
68- // Keymapping newKeymapping = { "key.test", { keyNum }, true };
69-
70- // if (!addedAlready) {
71- // self->mLayout->mDefaultMappings.push_back(newKeymapping); // key...
72- // self->mLayout->mKeymappings.push_back(newKeymapping);
73- // addedAlready = true;
74- // }
75-
76- /* for (auto it = self->mActiveInputMappings.begin(); it != self->mActiveInputMappings.end(); ++it) {
77- const std::string mappingName = it->first;
78- KeyboardKeyBinding key = { testButtonId, keyNum, FocusImpact::Neutral };
79-
80- InputMapping inputMapping = it->second;
81- inputMapping.keyboardMapping.keyBindings.push_back(key);
82- }*/
83-
84- return ret;
52+ extern " C" __declspec(dllexport) void RegisterInputs (InputManager * inputManager) {
53+ inputManager->RegisterInput (" f3" , 0x72 , false );
8554}
8655
87- extern " C" __declspec(dllexport) void OnStartJoinGame (ClientInstance * clientInstance ) {
88- /* InputHandler* handler = clientInstance->inputHandler->mInputHandler ;
56+ extern " C" __declspec(dllexport) void Initialize ( const char * gameVersion, InputManager * inputManager ) {
57+ MH_Initialize () ;
8958
90- handler->registerButtonDownHandler(testButtonId, [](FocusImpact impact, IClientInstance& instance) {
91- Log::Info("{} pressed!!", testButtonId);
59+ inputManager->AddButtonDownHandler (" f3" , [](FocusImpact focus, IClientInstance client) {
9260 shouldRenderF3 = !shouldRenderF3;
93- }, false);*/
94- }
95-
96- extern " C" __declspec(dllexport) void Initialize (const char * gameVersion) {
97- MH_Initialize ();
61+ });
9862
9963 hookManager.CreateHook (
10064 SigScan (" 40 55 53 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 ? 49 8B F1 4C 89 44 24 ? 4C 8B F2 48 8B D9" ),
10165 &Item_appendFormattedHovertext, reinterpret_cast <void **>(&_Item_appendFormattedHovertext)
10266 );
67+ }
10368
104- /* hookManager.CreateHook(
105- SigScan("48 89 5C 24 ? 55 56 57 48 8B EC 48 83 EC ? 49 8B F0 48 8B DA 48 8B F9 E8"),
106- &_createBaseNormalGamePlayKeyboardAndMouseMapping, reinterpret_cast<void**>(&__createBaseNormalGamePlayKeyboardAndMouseMapping)
107- );*/
69+ extern " C" __declspec(dllexport) void Shutdown () {
70+ hookManager.Shutdown ();
10871}
0 commit comments