From 3dcc985cd4086c068639e2442bebc231f7336f59 Mon Sep 17 00:00:00 2001 From: Sally Knight Date: Fri, 27 Mar 2026 23:14:30 +0300 Subject: [PATCH] feat(jui): add brewing stand screen (+ fix enchantment screen not being used) --- .../Common/res/1_2_2/gui/brewing_stand.png | Bin 0 -> 1650 bytes Minecraft.Client/Player/LocalPlayer.cpp | 14 ++- Minecraft.Client/Textures/Textures.cpp | 1 + Minecraft.Client/Textures/Textures.h | 1 + .../UI/Screens/BrewingStandScreen.cpp | 99 ++++++++++++++++++ .../UI/Screens/BrewingStandScreen.h | 23 ++++ 6 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 Minecraft.Assets/Common/res/1_2_2/gui/brewing_stand.png create mode 100644 Minecraft.Client/UI/Screens/BrewingStandScreen.cpp create mode 100644 Minecraft.Client/UI/Screens/BrewingStandScreen.h diff --git a/Minecraft.Assets/Common/res/1_2_2/gui/brewing_stand.png b/Minecraft.Assets/Common/res/1_2_2/gui/brewing_stand.png new file mode 100644 index 0000000000000000000000000000000000000000..e7dc2031ac1614c34be70770119ce2ccb1eb0918 GIT binary patch literal 1650 zcmcIkX;70_6n*(fFvw~|4NGD`bcigXphbuh0w@#k{6#xW$MF6xs9DJfng5e+^E%lR!a!P|VJgd}(EoPUP*pxQ77CNU37CHCNn;eff8W?4O5@P2guNl7L zBHqrWV1*O(5S`k7#^6iKxLRyop(R42eRHlzVxev~-c93Tm}jM8C-NK$yn(yH$WXKFiU>!%jFfNTFC$Yg&|?sEQqBoWc;b~4vMHuGbJr&IDyZlojV zK8z$ci`FXfWK-;G{E$()V3JP;nI!FxO;_GuFxOVO%VJeeP~P$lje6yf#R?)+h0qh^0UYxqMLKHn=iZM5Yx#)<^EqT zdTyG$u(}ya-;S83uy;3-coJ=z=68_7b|eT;Ffnyoft>wG=>XfYqmlb6Y6rkn4TbjL z-#zhK(X>J{Zt`^Thwx~I0WPP#nxEHsUw8!kUgT#U_S+VIpH0HY1zed(E3EQhxEi3V zznr1TBs^mqvsVIn-2``!fhWgmCu^+%$^Nb5`Fzbp;{hGuSDTl8=XOovt@)5iU#V%0 z4@*l>t0T>ip5gO(-E`_O+;ba!_F7C=tJ#3C4MTXYapYPE{5w1P3_I>xS?707@Oam= zwGdojr>W?6O$A}{g&21-raS811`}Z^-D|J1M~RI;>tY+MRaWPB$2#n7oI5*8W9T*g;`ObaqZdUxNngB${XSmVI$P*$R@XGteBIs zaY>n`(x^}9xgrg6yxix&b}iwsC5+DfTjW1=BN=Y6diyJXrPB&BETJas(58;B`og2D z6wY`B2r~lqa%-k4Bjl8zI)M_;2(3@6x_WSuiu2b{%ATFc$R~`RC;A z!=*fvQ3^VvH7M$}c)`h7&qB_-+|%Inug`md_K{iS?E=g$DRmq8zgF;=RdAsQx%KHK Qv-K7Zc22gHlz`+v074gx(*OVf literal 0 HcmV?d00001 diff --git a/Minecraft.Client/Player/LocalPlayer.cpp b/Minecraft.Client/Player/LocalPlayer.cpp index c9cd930df..a74161798 100644 --- a/Minecraft.Client/Player/LocalPlayer.cpp +++ b/Minecraft.Client/Player/LocalPlayer.cpp @@ -1,5 +1,7 @@ #include "../Platform/stdafx.h" #include "LocalPlayer.h" +#include "UI/Screens/BrewingStandScreen.h" +#include "UI/Screens/EnchantmentScreen.h" #include "UI/Screens/HopperScreen.h" #include "UI/Screens/HorseInventoryScreen.h" #include "UI/Screens/RepairScreen.h" @@ -645,10 +647,14 @@ bool LocalPlayer::openFireworks(int x, int y, int z) { bool LocalPlayer::startEnchanting(int x, int y, int z, const std::wstring& name) { +#ifdef ENABLE_JAVA_GUIS + minecraft->setScreen(new EnchantmentScreen(inventory, level, x, y, z)); + bool success = true; +#else bool success = app.LoadEnchantingMenu(GetXboxPad(), inventory, x, y, z, level, name); if (success) ui.PlayUISFX(eSFX_Press); - // minecraft.setScreen(new EnchantmentScreen(inventory, level, x, y, z)); +#endif return success; } @@ -677,10 +683,14 @@ bool LocalPlayer::openFurnace(std::shared_ptr furnace) { bool LocalPlayer::openBrewingStand( std::shared_ptr brewingStand) { +#ifdef ENABLE_JAVA_GUIS + minecraft->setScreen(new BrewingStandScreen(inventory, brewingStand)); + bool success = true; +#else bool success = app.LoadBrewingStandMenu(GetXboxPad(), inventory, brewingStand); if (success) ui.PlayUISFX(eSFX_Press); - // minecraft.setScreen(new BrewingStandScreen(inventory, brewingStand)); +#endif return success; } diff --git a/Minecraft.Client/Textures/Textures.cpp b/Minecraft.Client/Textures/Textures.cpp index 20b952c59..deef91211 100644 --- a/Minecraft.Client/Textures/Textures.cpp +++ b/Minecraft.Client/Textures/Textures.cpp @@ -182,6 +182,7 @@ const wchar_t* Textures::preLoaded[TN_COUNT] = { L"gui/trap", L"gui/hopper", L"gui/enchant", + L"gui/brewing_stand", 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 2a6ad074a..b073a77de 100644 --- a/Minecraft.Client/Textures/Textures.h +++ b/Minecraft.Client/Textures/Textures.h @@ -164,6 +164,7 @@ typedef enum _TEXTURE_NAME { TN_GUI_TRAP, TN_GUI_HOPPER, TN_GUI_ENCHANT, + TN_GUI_BREWING_STAND, TN_TITLE_BG_PANORAMA, TN_TITLE_BG_PANORAMA0, TN_TITLE_BG_PANORAMA1, diff --git a/Minecraft.Client/UI/Screens/BrewingStandScreen.cpp b/Minecraft.Client/UI/Screens/BrewingStandScreen.cpp new file mode 100644 index 000000000..1d1239c2a --- /dev/null +++ b/Minecraft.Client/UI/Screens/BrewingStandScreen.cpp @@ -0,0 +1,99 @@ +#include "../../Platform/stdafx.h" +#include "BrewingStandScreen.h" +#include +#include +#include +#include "../../Player/MultiPlayerLocalPlayer.h" +#include "../../Rendering/Lighting.h" +#include "../../Textures/Textures.h" +#include "../../../Minecraft.World/Headers/net.minecraft.locale.h" +#include "../../../Minecraft.World/Containers/BrewingStandMenu.h" +#include "../../../Minecraft.World/Containers/Slot.h" +#include "../../../Minecraft.Client/Minecraft.h" + +// 4jcraft: referenced from MCP 8.11 (JE 1.6.4) and the existing +// container classes +#ifdef ENABLE_JAVA_GUIS +ResourceLocation GUI_BREWING_STAND_LOCATION = + ResourceLocation(TN_GUI_BREWING_STAND); +#endif + +BrewingStandScreen::BrewingStandScreen( + std::shared_ptr inventory, + std::shared_ptr brewingStand) + : AbstractContainerScreen(new BrewingStandMenu(inventory, brewingStand)) { + this->inventory = inventory; + this->brewingStand = brewingStand; + this->brewMenu = static_cast(menu); +} + +BrewingStandScreen::~BrewingStandScreen() = default; + +void BrewingStandScreen::init() { AbstractContainerScreen::init(); } + +void BrewingStandScreen::removed() { AbstractContainerScreen::removed(); } + +void BrewingStandScreen::renderLabels() { + font->draw(brewingStand->getName(), + (imageWidth / 2) - (font->width(brewingStand->getName()) / 2), 6, + 0x404040); + font->draw(inventory->getName(), 8, imageHeight - 96 + 2, 0x404040); +} + +void BrewingStandScreen::renderBg(float a) { +#ifdef ENABLE_JAVA_GUIS + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + Minecraft::GetInstance()->textures->bindTexture( + &GUI_BREWING_STAND_LOCATION); + int xo = (width - imageWidth) / 2; + int yo = (height - imageHeight) / 2; + blit(xo, yo, 0, 0, imageWidth, imageHeight); + + int brewTime = brewingStand->getBrewTime(); + + if (brewTime > 0) { + int arrowHeight = (int)(28.0f * (1.0f - (float)brewTime / 400.0f)); + + if (arrowHeight > 0) { + blit(xo + 97, yo + 16 + (28 - arrowHeight), 176, 28 - arrowHeight, + 9, arrowHeight); + } + + int bubbleStep = (brewTime / 2) % 7; + int bubbleHeight = 0; + + switch (bubbleStep) { + case 0: + bubbleHeight = 29; + break; + case 1: + bubbleHeight = 24; + break; + case 2: + bubbleHeight = 20; + break; + case 3: + bubbleHeight = 16; + break; + case 4: + bubbleHeight = 11; + break; + case 5: + bubbleHeight = 6; + break; + case 6: + bubbleHeight = 0; + break; + } + + if (bubbleHeight > 0) { + blit(xo + 65, yo + 14 + (29 - bubbleHeight), 185, 29 - bubbleHeight, + 12, bubbleHeight); + } + } +#endif +} + +void BrewingStandScreen::render(int xm, int ym, float a) { + AbstractContainerScreen::render(xm, ym, a); +} \ No newline at end of file diff --git a/Minecraft.Client/UI/Screens/BrewingStandScreen.h b/Minecraft.Client/UI/Screens/BrewingStandScreen.h new file mode 100644 index 000000000..12f834ed7 --- /dev/null +++ b/Minecraft.Client/UI/Screens/BrewingStandScreen.h @@ -0,0 +1,23 @@ +#pragma once + +#include "AbstractContainerScreen.h" +#include "../../../Minecraft.World/Containers/BrewingStandMenu.h" +#include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h" + +class BrewingStandScreen : public AbstractContainerScreen { +public: + BrewingStandScreen(std::shared_ptr inventory, + std::shared_ptr brewingStand); + virtual ~BrewingStandScreen(); + + void init() override; + void removed() override; + void renderLabels() override; + void renderBg(float a) override; + void render(int xm, int ym, float a) override; + +private: + std::shared_ptr inventory; + std::shared_ptr brewingStand; + BrewingStandMenu* brewMenu; +}; \ No newline at end of file