1010#include " minecraft/src/common/world/item/Item.h"
1111#include " minecraft/src-client/common/client/renderer/screen/MinecraftUIRenderContext.h"
1212#include " minecraft/src-client/common/client/gui/ScreenView.h"
13+ #include " minecraft/src-client/common/client/renderer/TexturePtr.h"
14+ #include " minecraft/src-deps/core/string/StringHash.h"
1315
1416HookManager hookManager;
1517
@@ -35,27 +37,6 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
3537 return TRUE ;
3638}
3739
38- extern " C" __declspec(dllexport) void OnRenderUI (ScreenView* screenView, MinecraftUIRenderContext* ctx) {
39- Vec2 screenSize = ctx->mClient ->guiData ->clientUIScreenSize ;
40- int testBorder = 10 ;
41-
42- RectangleArea rect = { testBorder, screenSize.x - testBorder, testBorder, screenSize.y - testBorder };
43- mce::Color bgCol (0 .9f , 0 .9f , 0 .9f , 1 .0f );
44- mce::Color fgCol (0 .0f , 0 .0f , 0 .0f , 1 .0f );
45- std::string text = " Hello, World!" ;
46-
47- TextMeasureData textData;
48- memset (&textData, 0 , sizeof (TextMeasureData));
49- textData.fontSize = 1 .0f ;
50-
51- CaretMeasureData caretData;
52- memset (&caretData, 1 , sizeof (CaretMeasureData));
53-
54- ctx->drawRectangle (&rect, &bgCol, 1 .0f , 1 );
55- ctx->drawDebugText (&rect, &text, &fgCol, 1 .0f , ui::Left, &textData, &caretData);
56- ctx->flushText (0 .0f );
57- }
58-
5940extern " C" __declspec(dllexport) void Initialize () {
6041 MH_Initialize ();
6142
@@ -65,6 +46,29 @@ extern "C" __declspec(dllexport) void Initialize() {
6546 );
6647}
6748
49+ static bool hasLoadedTexture = false ;
50+ static HashedString flushString (0xA99285D21E94FC80 , " ui_flush" );
51+ static auto texture = std::make_unique<mce::TexturePtr>();
52+ static ResourceLocation resource (" textures/items/apple" );
53+
54+ extern " C" __declspec(dllexport) void OnRenderUI (ScreenView* screenView, MinecraftUIRenderContext* ctx) {
55+ if (!hasLoadedTexture) {
56+ ctx->getTexture (texture.get (), &resource, true );
57+ hasLoadedTexture = true ;
58+ }
59+
60+ mce::Color color (1 .0f , 1 .0f , 1 .0f , 1 .0f );
61+
62+ if (texture != nullptr ) {
63+ glm::tvec2<float > vec2zero (0 .0f , 0 .0f );
64+ glm::tvec2<float > vec2one (1 .0f , 1 .0f );
65+ glm::tvec2<float > size (100 .0f , 100 .0f );
66+
67+ ctx->drawImage (*texture, &vec2zero, &size, &vec2zero, &vec2one, 0 );
68+ ctx->flushImages (color, 1 .0f , flushString);
69+ }
70+ }
71+
6872extern " C" __declspec(dllexport) void Shutdown () {
6973 hookManager.Shutdown ();
7074}
0 commit comments