Skip to content

Commit 2ffb608

Browse files
committed
Start F3 Screen
1 parent 9523e77 commit 2ffb608

1 file changed

Lines changed: 27 additions & 16 deletions

File tree

src/dllmain.cpp

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <stdint.h>
33
#include <iostream>
44
#include <fstream>
5+
#include <chrono>
56

67
#include "amethyst/Log.h"
78
#include "amethyst/HookManager.h"
@@ -46,27 +47,37 @@ extern "C" __declspec(dllexport) void Initialize() {
4647
);
4748
}
4849

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+
}
5355

5456
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;
5961

60-
mce::Color color(1.0f, 1.0f, 1.0f, 1.0f);
62+
std::string text = "Minecraft 1.20.30.02 (AmethystAPI)";
6163

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));
6668

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);
7081
}
7182

7283
extern "C" __declspec(dllexport) void Shutdown() {

0 commit comments

Comments
 (0)