From 975f716f9c8f9e04e0faab260d7a7c83797e749e Mon Sep 17 00:00:00 2001 From: Sally Knight Date: Thu, 26 Mar 2026 17:28:29 +0300 Subject: [PATCH] feat(jui): re-enable and update TrapScreen (Dispenser and Dropper GUI) --- Minecraft.Client/Player/LocalPlayer.cpp | 6 ++++- Minecraft.Client/Textures/Textures.cpp | 1 + Minecraft.Client/Textures/Textures.h | 1 + Minecraft.Client/UI/Screens/TrapScreen.cpp | 26 +++++++++++++--------- Minecraft.Client/UI/Screens/TrapScreen.h | 5 +++++ 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Minecraft.Client/Player/LocalPlayer.cpp b/Minecraft.Client/Player/LocalPlayer.cpp index d04c5f1f5..18f22d8dc 100644 --- a/Minecraft.Client/Player/LocalPlayer.cpp +++ b/Minecraft.Client/Player/LocalPlayer.cpp @@ -683,9 +683,13 @@ bool LocalPlayer::openBeacon(std::shared_ptr beacon) { } bool LocalPlayer::openTrap(std::shared_ptr trap) { +#ifdef ENABLE_JAVA_GUIS + minecraft->setScreen(new TrapScreen(inventory, trap)); + bool success = true; +#else bool success = app.LoadTrapMenu(GetXboxPad(), inventory, trap); if (success) ui.PlayUISFX(eSFX_Press); - // minecraft->setScreen(new TrapScreen(inventory, trap)); +#endif return success; } diff --git a/Minecraft.Client/Textures/Textures.cpp b/Minecraft.Client/Textures/Textures.cpp index 39e8cb4c7..25a502dcb 100644 --- a/Minecraft.Client/Textures/Textures.cpp +++ b/Minecraft.Client/Textures/Textures.cpp @@ -179,6 +179,7 @@ const wchar_t* Textures::preLoaded[TN_COUNT] = { L"title/mclogo", L"gui/horse", L"gui/anvil", + L"gui/trap", L"title/bg/panorama", #endif // L"item/christmas", diff --git a/Minecraft.Client/Textures/Textures.h b/Minecraft.Client/Textures/Textures.h index 48a392444..6c083cf70 100644 --- a/Minecraft.Client/Textures/Textures.h +++ b/Minecraft.Client/Textures/Textures.h @@ -161,6 +161,7 @@ typedef enum _TEXTURE_NAME { TN_TITLE_MCLOGO, TN_GUI_HORSE, TN_GUI_ANVIL, + TN_GUI_TRAP, TN_TITLE_BG_PANORAMA, #endif // TN_TILE_XMAS_CHEST, diff --git a/Minecraft.Client/UI/Screens/TrapScreen.cpp b/Minecraft.Client/UI/Screens/TrapScreen.cpp index 80de6d7e9..7a1afb6bd 100644 --- a/Minecraft.Client/UI/Screens/TrapScreen.cpp +++ b/Minecraft.Client/UI/Screens/TrapScreen.cpp @@ -6,23 +6,29 @@ #include "../../../Minecraft.World/Blocks/TileEntities/DispenserTileEntity.h" #include "../../../Minecraft.World/Headers/net.minecraft.world.h" +#ifdef ENABLE_JAVA_GUIS +ResourceLocation GUI_TRAP_LOCATION = ResourceLocation(TN_GUI_TRAP); +#endif + TrapScreen::TrapScreen(std::shared_ptr inventory, std::shared_ptr trap) - : AbstractContainerScreen(new TrapMenu(inventory, trap)) {} + : AbstractContainerScreen(new TrapMenu(inventory, trap)) { + this->trap = trap; + this->inventory = inventory; +} void TrapScreen::renderLabels() { - font->draw(L"Dispenser", 16 + 4 + 40, 2 + 2 + 2, 0x404040); - font->draw(L"Inventory", 8, imageHeight - 96 + 2, 0x404040); + font->draw(trap->getName(), 16 + 4 + 40, 2 + 2 + 2, 0x404040); + font->draw(inventory->getName(), 8, imageHeight - 96 + 2, 0x404040); } void TrapScreen::renderBg(float a) { // 4J Unused -#if 0 - int tex = minecraft->textures->loadTexture(L"/gui/trap.png"); - glColor4f(1, 1, 1, 1); - minecraft->textures->bind(tex); - int xo = (width - imageWidth) / 2; - int yo = (height - imageHeight) / 2; - this->blit(xo, yo, 0, 0, imageWidth, imageHeight); +#ifdef ENABLE_JAVA_GUIS + glColor4f(1, 1, 1, 1); + minecraft->textures->bindTexture(&GUI_TRAP_LOCATION); + int xo = (width - imageWidth) / 2; + int yo = (height - imageHeight) / 2; + this->blit(xo, yo, 0, 0, imageWidth, imageHeight); #endif } \ No newline at end of file diff --git a/Minecraft.Client/UI/Screens/TrapScreen.h b/Minecraft.Client/UI/Screens/TrapScreen.h index fcf8a33fa..ae2b02c89 100644 --- a/Minecraft.Client/UI/Screens/TrapScreen.h +++ b/Minecraft.Client/UI/Screens/TrapScreen.h @@ -1,4 +1,5 @@ #pragma once +#include #include "AbstractContainerScreen.h" class DispenserTileEntity; class Inventory; @@ -11,4 +12,8 @@ public: protected: virtual void renderLabels(); virtual void renderBg(float a); + +private: + std::shared_ptr inventory; + std::shared_ptr trap; }; \ No newline at end of file