@@ -5,13 +5,30 @@ ClientInstance* client;
55
66ShulkerBoxBlockItem::_appendFormattedHovertext _Shulker_appendFormattedHoverText;
77Item::_appendFormattedHovertext _Item_appendFormattedHovertext;
8+ HoverRenderer::__renderHoverBox __renderHoverBox;
89
10+ ShulkerRenderer shulkerRenderer;
911ItemStack shulkerInventory[27 ];
10- bool isHoveringShulkerbox = false ;
12+
13+ static void Item_appendFormattedHovertext (Item* self, const ItemStackBase& itemStack, Level& level, std::string& text, uint8_t a5) {
14+ _Item_appendFormattedHovertext (self, itemStack, level, text, a5);
15+ Item* item = itemStack.mItem ;
16+
17+ uint64_t max = item->getMaxDamage ();
18+
19+ if (max != 0 ) {
20+ uint64_t current = max - item->getDamageValue (itemStack.mUserData );
21+ text.append (fmt::format (" \n {}7Durability: {} / {}{}r" , " \xc2\xa7 " , current, max, " \xc2\xa7 " ));
22+ }
23+
24+ std::string rawNameId;
25+ itemStack.getRawNameId (rawNameId);
26+ text.append (fmt::format (" \n {}8{}:{} ({}){}r" , " \xc2\xa7 " , item->mNamespace , rawNameId, item->mId , " \xc2\xa7 " ));
27+ }
1128
1229static void Shulker_appendFormattedHovertext (ShulkerBoxBlockItem* self, const ItemStackBase& itemStack, Level& level, std::string& text, uint8_t someBool) {
13- _Shulker_appendFormattedHoverText (self, itemStack, level, text, someBool);
14- isHoveringShulkerbox = true ;
30+ // Use the appendFormattedHovertext for regular items, we don't want the list of items
31+ Item_appendFormattedHovertext (self, itemStack, level, text, someBool) ;
1532
1633 // Reset all the currrent item stacks
1734 for (auto & itemStack : shulkerInventory) {
@@ -32,21 +49,15 @@ static void Shulker_appendFormattedHovertext(ShulkerBoxBlockItem* self, const It
3249 }
3350}
3451
35- static void Item_appendFormattedHovertext (Item* self, const ItemStackBase& itemStack, Level& level, std::string& text, uint8_t a5) {
36- _Item_appendFormattedHovertext (self, itemStack, level, text, a5);
37- isHoveringShulkerbox = false ;
38- Item* item = itemStack.mItem ;
39-
40- uint64_t max = item->getMaxDamage ();
41-
42- if (max != 0 ) {
43- uint64_t current = max - item->getDamageValue (itemStack.mUserData );
44- text.append (fmt::format (" \n {}7Durability: {} / {}{}r" , " \xc2\xa7 " , current, max, " \xc2\xa7 " ));
52+ static void _renderHoverBox (HoverRenderer* self, MinecraftUIRenderContext* ctx, IClientInstance* client, RectangleArea* aabb, float someFloat) {
53+ // This is really bad code, it is relying on the fact that I have also hooked appendFormattedHovertext for items to append the item identifier
54+ // I have no idea where the currently hovered item is stored in the game! I can't find any references to it, so it might be set in some weird place?
55+ if (self->mText .find (" shulker_box" ) != std::string::npos) {
56+ shulkerRenderer.Render (ctx);
57+ return ;
4558 }
4659
47- std::string rawNameId;
48- itemStack.getRawNameId (rawNameId);
49- text.append (fmt::format (" \n {}8{}:{} ({}){}r" , " \xc2\xa7 " , item->mNamespace , rawNameId, item->mId , " \xc2\xa7 " ));
60+ __renderHoverBox (self, ctx, client, aabb, someFloat);
5061}
5162
5263ModFunction void Initialize (const char * gameVersion, InputManager * inputManager) {
@@ -61,12 +72,11 @@ ModFunction void Initialize(const char* gameVersion, InputManager * inputManager
6172 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" ),
6273 &Item_appendFormattedHovertext, reinterpret_cast <void **>(&_Item_appendFormattedHovertext)
6374 );
64- }
6575
66- ShulkerRenderer shulkerRenderer;
67-
68- ModFunction void OnRenderUI (ScreenView* screenView, UIRenderContext* ctx) {
69- shulkerRenderer. Render (ctx );
76+ hookManager. CreateHook (
77+ SigScan ( " 48 8B C4 48 89 58 ? 48 89 70 ? 48 89 78 ? 4C 89 70 ? 55 48 8D 68 ? 48 81 EC ? ? ? ? 0F 29 70 ? 0F 29 78 ? 44 0F 29 40 ? 49 8B D9 " ),
78+ &_renderHoverBox, reinterpret_cast < void **>(&__renderHoverBox)
79+ );
7080}
7181
7282ModFunction void Shutdown () {
0 commit comments