From 5ac7f23577e43bdf652e303f3a324c72a0e0e2bd Mon Sep 17 00:00:00 2001 From: Sally Knight Date: Thu, 26 Mar 2026 19:37:28 +0300 Subject: [PATCH] feat(jui): add hopper screen --- .../Common/res/1_2_2/gui/hopper.png | Bin 0 -> 1202 bytes Minecraft.Client/Player/LocalPlayer.cpp | 7 +++- Minecraft.Client/Textures/Textures.cpp | 1 + Minecraft.Client/Textures/Textures.h | 1 + .../UI/Screens/CreateWorldScreen.cpp | 4 +- Minecraft.Client/UI/Screens/HopperScreen.cpp | 37 ++++++++++++++++++ Minecraft.Client/UI/Screens/HopperScreen.h | 21 ++++++++++ 7 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 Minecraft.Assets/Common/res/1_2_2/gui/hopper.png create mode 100644 Minecraft.Client/UI/Screens/HopperScreen.cpp create mode 100644 Minecraft.Client/UI/Screens/HopperScreen.h diff --git a/Minecraft.Assets/Common/res/1_2_2/gui/hopper.png b/Minecraft.Assets/Common/res/1_2_2/gui/hopper.png new file mode 100644 index 0000000000000000000000000000000000000000..3d0054790f574bb8ffcd90fe2069edc2375c0420 GIT binary patch literal 1202 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911MRQ8&P5C#Tjh5(-sS0EP%%+1Y1Lqof} zyN?|^_W%EXh~OwW8Un*U1d^tF&INjsu_VYZn8D%MjWiG^$=lt9p@UV{1IXbl@Q5sC zVBk9l!i+m6X1@h0u=8|r45_&F_O>BkvjLAo;BJ*W|4-zGuhN^U>rt71reTV{Vk5KQ z#Md2sJJ&1c@B3ey=HIZhEBACCLofp)i+}?P@#9&c$*Qn0P6NJgt3)wm1s<$oJa$}M zI#k;&iHSp@fdN50XL(`$Yn_eLd!7s5*2P;IqnQihYB7J2tqqr3IGbZ9E4sZvd0|Ci z#qG#OLJdz)`jX7>pO;Ia!QS1s)s`LAUXY@d8&+ container) { } bool LocalPlayer::openHopper(std::shared_ptr container) { - // minecraft->setScreen(new HopperScreen(inventory, container)); +#ifdef ENABLE_JAVA_GUIS + minecraft->setScreen(new HopperScreen(inventory, container)); + bool success = true; +#else bool success = app.LoadHopperMenu(GetXboxPad(), inventory, container); if (success) ui.PlayUISFX(eSFX_Press); +#endif return success; } diff --git a/Minecraft.Client/Textures/Textures.cpp b/Minecraft.Client/Textures/Textures.cpp index 2afdd477a..50f92da4f 100644 --- a/Minecraft.Client/Textures/Textures.cpp +++ b/Minecraft.Client/Textures/Textures.cpp @@ -180,6 +180,7 @@ const wchar_t* Textures::preLoaded[TN_COUNT] = { L"gui/horse", L"gui/anvil", L"gui/trap", + L"gui/hopper", L"title/bg/panorama", L"title/bg/panorama0", L"title/bg/panorama1", diff --git a/Minecraft.Client/Textures/Textures.h b/Minecraft.Client/Textures/Textures.h index c2ccaa936..8b80be1ba 100644 --- a/Minecraft.Client/Textures/Textures.h +++ b/Minecraft.Client/Textures/Textures.h @@ -162,6 +162,7 @@ typedef enum _TEXTURE_NAME { TN_GUI_HORSE, TN_GUI_ANVIL, TN_GUI_TRAP, + TN_GUI_HOPPER, TN_TITLE_BG_PANORAMA, TN_TITLE_BG_PANORAMA0, TN_TITLE_BG_PANORAMA1, diff --git a/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp b/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp index 8ca1690e9..593f8416a 100644 --- a/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp +++ b/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp @@ -155,7 +155,9 @@ void CreateWorldScreen::buttonClicked(Button* button) { app.DebugPrintf("CreateWorldScreen::buttonClicked START\n"); if (!button->active) return; if (button->id == 1) { - app.DebugPrintf("CreateWorldScreen::buttonClicked 'Cancel' minecraft->setScreen(lastScreen)\n"); + app.DebugPrintf( + "CreateWorldScreen::buttonClicked 'Cancel' " + "minecraft->setScreen(lastScreen)\n"); minecraft->setScreen(lastScreen); } else if (button->id == 0) { minecraft->setScreen( diff --git a/Minecraft.Client/UI/Screens/HopperScreen.cpp b/Minecraft.Client/UI/Screens/HopperScreen.cpp new file mode 100644 index 000000000..2bab4945e --- /dev/null +++ b/Minecraft.Client/UI/Screens/HopperScreen.cpp @@ -0,0 +1,37 @@ +#include "../../Platform/stdafx.h" +#include "HopperScreen.h" +#include "../../Textures/Textures.h" +#include "../../Player/LocalPlayer.h" +#include "../Font.h" +#include "../../../Minecraft.World/Headers/net.minecraft.world.inventory.h" +#include "../../../Minecraft.World/Containers/HopperMenu.h" + +// 4jcraft: referenced from MCP 8.11 (JE 1.6.4) and the existing +// container classes +#ifdef ENABLE_JAVA_GUIS +ResourceLocation GUI_HOPPER_LOCATION = ResourceLocation(TN_GUI_HOPPER); +#endif + +HopperScreen::HopperScreen(std::shared_ptr inventory, + std::shared_ptr hopper) + : AbstractContainerScreen(new HopperMenu(inventory, hopper)) { + this->hopper = hopper; + this->inventory = inventory; + imageHeight = 133; +} + +void HopperScreen::renderLabels() { + font->draw(hopper->getName(), 8, 6, 0x404040); + font->draw(inventory->getName(), 8, imageHeight - 96 + 2, 0x404040); +} + +void HopperScreen::renderBg(float a) { + // 4J Unused +#ifdef ENABLE_JAVA_GUIS + glColor4f(1, 1, 1, 1); + minecraft->textures->bindTexture(&GUI_HOPPER_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/HopperScreen.h b/Minecraft.Client/UI/Screens/HopperScreen.h new file mode 100644 index 000000000..eb1bb752f --- /dev/null +++ b/Minecraft.Client/UI/Screens/HopperScreen.h @@ -0,0 +1,21 @@ +#pragma once +#include +#include "AbstractContainerScreen.h" + +class HopperTileEntity; +class MinecartHopper; +class Inventory; + +class HopperScreen : public AbstractContainerScreen { +public: + HopperScreen(std::shared_ptr inventory, + std::shared_ptr hopper); + +protected: + virtual void renderLabels(); + virtual void renderBg(float a); + +private: + std::shared_ptr inventory; + std::shared_ptr hopper; +}; \ No newline at end of file