|
2 | 2 | #include <stdint.h> |
3 | 3 | #include <iostream> |
4 | 4 | #include <fstream> |
| 5 | +#include <chrono> |
5 | 6 |
|
6 | 7 | #include "amethyst/Log.h" |
7 | 8 | #include "amethyst/HookManager.h" |
@@ -46,27 +47,37 @@ extern "C" __declspec(dllexport) void Initialize() { |
46 | 47 | ); |
47 | 48 | } |
48 | 49 |
|
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"); |
| 50 | +static ClientInstance* g_client = nullptr; |
| 51 | + |
| 52 | +extern "C" __declspec(dllexport) void OnStartJoinGame(ClientInstance* ci) { |
| 53 | + g_client = ci; |
| 54 | +} |
53 | 55 |
|
54 | 56 | extern "C" __declspec(dllexport) void OnRenderUI(ScreenView* screenView, MinecraftUIRenderContext* ctx) { |
55 | | - if (!hasLoadedTexture) { |
56 | | - ctx->getTexture(texture.get(), &resource, true); |
57 | | - hasLoadedTexture = true; |
58 | | - } |
| 57 | + if (g_client == nullptr) return; |
| 58 | + |
| 59 | + LocalPlayer* player = g_client->getLocalPlayer(); |
| 60 | + if (player == nullptr) return; |
59 | 61 |
|
60 | | - mce::Color color(1.0f, 1.0f, 1.0f, 1.0f); |
| 62 | + std::string text = "Minecraft 1.20.30.02 (AmethystAPI)"; |
61 | 63 |
|
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); |
| 64 | + Vec3* pos = player->getPosition(); |
| 65 | + Vec3* rot = player->getHeadLookVector(1.0f); |
| 66 | + text.append(fmt::format("\n\nXYZ: {:.3f} / {:.3f} / {:.3f}", pos->x, pos->y, pos->z)); |
| 67 | + text.append(fmt::format("\nRot: {} {} {}", rot->x, rot->y, rot->z)); |
66 | 68 |
|
67 | | - ctx->drawImage(*texture, &vec2zero, &size, &vec2zero, &vec2one, 0); |
68 | | - ctx->flushImages(color, 1.0f, flushString); |
69 | | - } |
| 69 | + // Render text on screen |
| 70 | + RectangleArea rect = { 0.0f, 0.0f, 0.0f, 0.0f }; |
| 71 | + mce::Color white(1.0f, 1.0f, 1.0f, 1.0f); |
| 72 | + |
| 73 | + TextMeasureData textData; |
| 74 | + memset(&textData, 0, sizeof(TextMeasureData)); |
| 75 | + textData.fontSize = 1.0f; |
| 76 | + |
| 77 | + CaretMeasureData caretData; |
| 78 | + memset(&caretData, 1, sizeof(CaretMeasureData)); |
| 79 | + |
| 80 | + ctx->drawDebugText(&rect, &text, &white, 1.0f, ui::Left, &textData, &caretData); |
70 | 81 | } |
71 | 82 |
|
72 | 83 | extern "C" __declspec(dllexport) void Shutdown() { |
|
0 commit comments