@@ -4,16 +4,22 @@ static HashedString flushString(0xA99285D21E94FC80, "ui_flush");
44
55// Texture loading
66static auto itemSlotTexture = std::make_unique<mce::TexturePtr>();
7- static ResourceLocation itemSlotLocation (" textures/ui/hotbar_0 " );
7+ static ResourceLocation itemSlotLocation (" textures/gui/gui " );
88bool hasLoadedTexture = false ;
99
1010// Slot sizing
1111float slotSize = 20 .f;
1212float borderSize = (slotSize - 16 .f) / 2 ;
1313
14+ // Uv positions
15+ glm::tvec2<float > itemSlotUvPos (188 .0f / 256 .0f , 184 .0f / 256 .0f );
16+ glm::tvec2<float > itemSlotUvSize (22 .0f / 256 .0f , 22 .0f / 256 .0f );
17+
1418extern ItemStack shulkerInventory[27 ];
1519
16- void ShulkerRenderer::Render (UIRenderContext* ctx) {
20+ mce::Color panelBackground (27 .0f / 255 .0f , 12 .0f / 255 .0f , 27 .0f / 255 .0f , 1 .0f );
21+
22+ void ShulkerRenderer::Render (UIRenderContext* ctx, std::string& hoverText) {
1723 if (ctx == nullptr || ctx->mClient ->getLocalPlayer () == nullptr ) return ;
1824
1925 // Only load inventory resources once
@@ -22,18 +28,24 @@ void ShulkerRenderer::Render(UIRenderContext* ctx) {
2228 hasLoadedTexture = true ;
2329 }
2430
31+ float textHeight = 20 .0f ;
32+ float panelWidth = slotSize * 9 ;
33+ float panelHeight = slotSize * 3 + textHeight;
34+
35+ RectangleArea background = {0 .0f , panelWidth, 0 .0f , panelHeight};
36+ ctx->drawRectangle (&background, &panelBackground, 1 .0f , 1 );
37+
2538 // Draw the item slots
2639 for (int x = 0 ; x < 9 ; x++) {
2740 for (int y = 0 ; y < 3 ; y++) {
28- glm::tvec2<float > vec2zero (0 .0f , 0 .0f );
29- glm::tvec2<float > vec2one (1 .0f , 1 .0f );
3041 glm::tvec2<float > size (slotSize, slotSize);
31- glm::tvec2<float > position (slotSize * x, slotSize * y);
42+ glm::tvec2<float > position (slotSize * x, slotSize * y + textHeight );
3243
33- ctx->drawImage (*itemSlotTexture, &position, &size, &vec2zero , &vec2one , 0 );
44+ ctx->drawImage (*itemSlotTexture, &position, &size, &itemSlotUvPos , &itemSlotUvSize , 0 );
3445 }
3546 }
3647
48+ // It's possible to tint the background here
3749 ctx->flushImages (mce::Color::WHITE, 1 .0f , flushString);
3850
3951 // Draw the item icons
@@ -47,7 +59,7 @@ void ShulkerRenderer::Render(UIRenderContext* ctx) {
4759 float xPos = (x * slotSize) + borderSize;
4860 float yPos = (y * slotSize) + borderSize;
4961
50- renderCtxPtr.itemRenderer ->renderGuiItemNew (&renderCtxPtr, itemStack, 0 , xPos, yPos, false , 1 .f , 1 .f , 1 .f );
62+ renderCtxPtr.itemRenderer ->renderGuiItemNew (&renderCtxPtr, itemStack, 0 , xPos, yPos + textHeight , false , 1 .f , 1 .f , 1 .f );
5163 }
5264 }
5365
@@ -68,7 +80,7 @@ void ShulkerRenderer::Render(UIRenderContext* ctx) {
6880 if (itemStack->mItem == nullptr ) continue ;
6981 if (itemStack->count == 1 ) continue ;
7082
71- float top = (y * slotSize) + borderSize;
83+ float top = (y * slotSize) + borderSize + textHeight ;
7284 float bottom = top + 16 .f ;
7385
7486 float left = (x * slotSize) + borderSize;
@@ -82,4 +94,8 @@ void ShulkerRenderer::Render(UIRenderContext* ctx) {
8294 }
8395
8496 ctx->flushText (0 .0f );
97+
98+ RectangleArea rect = { 0 .0f , 0 .0f , 0 .0f , 0 .0f };
99+ ctx->drawDebugText (&rect, &hoverText, &mce::Color::WHITE, 1 .0f , ui::Left, &textData, &caretData);
100+ ctx->flushText (0 .0f );
85101}
0 commit comments