From 65ff6a97f0427c0d5aba6aa471635fd51b0166b7 Mon Sep 17 00:00:00 2001 From: Sally Knight Date: Wed, 25 Mar 2026 20:01:59 +0300 Subject: [PATCH] feat(jui): add horse inventory screen --- .../Common/res/1_2_2/gui/horse.png | Bin 0 -> 5654 bytes Minecraft.Client/Player/LocalPlayer.cpp | 9 +- Minecraft.Client/Textures/Textures.cpp | 1 + Minecraft.Client/Textures/Textures.h | 1 + .../UI/Screens/HorseInventoryScreen.cpp | 100 ++++++++++++++++++ .../UI/Screens/HorseInventoryScreen.h | 22 ++++ 6 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 Minecraft.Assets/Common/res/1_2_2/gui/horse.png create mode 100644 Minecraft.Client/UI/Screens/HorseInventoryScreen.cpp create mode 100644 Minecraft.Client/UI/Screens/HorseInventoryScreen.h diff --git a/Minecraft.Assets/Common/res/1_2_2/gui/horse.png b/Minecraft.Assets/Common/res/1_2_2/gui/horse.png new file mode 100644 index 0000000000000000000000000000000000000000..194cc6bf6fcc7baee87038d57cb51f2254c640a8 GIT binary patch literal 5654 zcmb7IXHZk^w%!RKh*AU*r5O06h!iQ(k>H1b5doztD4ylj(ggMOwSmwM##Nk`g!RgY=?wAqzf2`(ER)=7~lJ>Qg98SG5o$J~{39KyYjI z&86d!^frUdOw|;Q2>S@f7!>MYU|`@|Gc&!tyA*d2 zvcE-Id5+@%7@)-$&z^w=1O(i7SI2y-X096>TUlD3+;h9o9p~Pcw;^L?3Iev40Us@l zpB852mRPze=z;rFSUJ%%f^l$><@wABWHZrA&F&hnA|EiV0UY9KldgzAf#(zpAuyjdYgh&Q2{AP+sE&dNq{smS4@$x@tR&0^5e=gkK(_`cA?mkLxWMVK$Rf{z` z!GUzkGs`GJp-{CWAshQoBK{2&z2;Nf6@c-3InoB#?7{-Jpy0VyKPd=9>dWsd3_StR zS$g@|*w`*yxbT5Hu>M{Q&s|^6f9CmLg9o)J{8k3b&Him*lR~k&d9!y$IEy>57n&k* zCi?z0g66S{pZ?$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`>94_Z9^!!>a&t@Q3l1sh1Dy{k}R2c~&i1Vl24i container) { bool LocalPlayer::openHorseInventory(std::shared_ptr horse, std::shared_ptr container) { - // minecraft->setScreen(new HorseInventoryScreen(inventory, container, - // horse)); +#ifdef ENABLE_JAVA_GUIS + minecraft->setScreen(new HorseInventoryScreen(inventory, container, + horse)); + bool success = true; +#else bool success = app.LoadHorseMenu(GetXboxPad(), inventory, container, horse); if (success) ui.PlayUISFX(eSFX_Press); +#endif return success; } diff --git a/Minecraft.Client/Textures/Textures.cpp b/Minecraft.Client/Textures/Textures.cpp index 6314e33ff..8d879aac8 100644 --- a/Minecraft.Client/Textures/Textures.cpp +++ b/Minecraft.Client/Textures/Textures.cpp @@ -177,6 +177,7 @@ const wchar_t* Textures::preLoaded[TN_COUNT] = { // 4jcraft: 1.6.4 java UI #ifdef ENABLE_JAVA_GUIS + L"gui/horse", L"title/bg/panorama", #endif // L"item/christmas", diff --git a/Minecraft.Client/Textures/Textures.h b/Minecraft.Client/Textures/Textures.h index 0ef8f6729..0bf5e42d5 100644 --- a/Minecraft.Client/Textures/Textures.h +++ b/Minecraft.Client/Textures/Textures.h @@ -159,6 +159,7 @@ typedef enum _TEXTURE_NAME { // 4jcraft: 1.6.4 java UI #ifdef ENABLE_JAVA_GUIS + TN_GUI_HORSE, TN_TITLE_BG_PANORAMA, #endif // TN_TILE_XMAS_CHEST, diff --git a/Minecraft.Client/UI/Screens/HorseInventoryScreen.cpp b/Minecraft.Client/UI/Screens/HorseInventoryScreen.cpp new file mode 100644 index 000000000..ffdfaaeb9 --- /dev/null +++ b/Minecraft.Client/UI/Screens/HorseInventoryScreen.cpp @@ -0,0 +1,100 @@ +#include "../../Platform/stdafx.h" +#include "HorseInventoryScreen.h" +#include "../../Player/MultiPlayerLocalPlayer.h" +#include "../../Rendering/EntityRenderers/EntityRenderDispatcher.h" +#include "../../Rendering/Lighting.h" +#include "../../Textures/Textures.h" +#include "../../../Minecraft.World/Headers/net.minecraft.locale.h" +#include "../../../Minecraft.World/Containers/HorseInventoryMenu.h" + +// 4jcraft: referenced from MCP 8.11 (JE 1.6.4) and the existing InventoryScreen + +ResourceLocation GUI_HORSE_LOCATION = ResourceLocation(TN_GUI_HORSE); + +HorseInventoryScreen::HorseInventoryScreen( + std::shared_ptr inventory, + std::shared_ptr horseContainer, + std::shared_ptr horse) + : AbstractContainerScreen( + new HorseInventoryMenu(inventory, horseContainer, horse)) { + xMouse = yMouse = 0.0f; // 4J added + + this->inventory = inventory; + this->horseContainer = horseContainer; + this->horse = horse; + this->passEvents = false; +} + +void HorseInventoryScreen::init() { AbstractContainerScreen::init(); } + +void HorseInventoryScreen::renderLabels() { + font->draw(horseContainer->getName(), 8, 6, 0x404040); + font->draw(inventory->getName(), 8, imageHeight - 96 + 2, 0x404040); +} + +void HorseInventoryScreen::render(int xm, int ym, float a) { + AbstractContainerScreen::render(xm, ym, a); + this->xMouse = (float)xm; + this->yMouse = (float)ym; +} + +void HorseInventoryScreen::renderBg(float a) { + // 4J Unused +#ifdef ENABLE_JAVA_GUIS + glColor4f(1, 1, 1, 1); + minecraft->textures->bindTexture(&GUI_HORSE_LOCATION); + + int xo = (width - imageWidth) / 2; + int yo = (height - imageHeight) / 2; + blit(xo, yo, 0, 0, imageWidth, imageHeight); + + if (horse->isChestedHorse()) { + blit(xo + 79, yo + 17, 0, imageHeight, 90, 54); + } + + if (horse->canWearArmor()) { + blit(xo + 7, yo + 35, 0, imageHeight + 54, 18, 18); + } + + glEnable(GL_RESCALE_NORMAL); + glEnable(GL_COLOR_MATERIAL); + + glPushMatrix(); + glTranslatef((float)xo + 51, (float)yo + 60, 50); + float ss = 30; + glScalef(-ss, ss, ss); + glRotatef(180, 0, 0, 1); + + float oybr = horse->yBodyRot; + float oyr = horse->yRot; + float oxr = horse->xRot; + float oyh = horse->yHeadRot; + float oyhp = horse->yHeadRotO; + + float xd = (xo + 51) - xMouse; + float yd = (yo + 75 - 50) - yMouse; + + glRotatef(45 + 90, 0, 1, 0); + Lighting::turnOn(); + glRotatef(-45 - 90, 0, 1, 0); + + glRotatef(-(float)atan(yd / 40.0f) * 20, 1, 0, 0); + + horse->yBodyRot = (float)atan(xd / 40.0f) * 20; + horse->yRot = (float)atan(xd / 40.0f) * 40; + horse->xRot = -(float)atan(yd / 40.0f) * 20; + horse->yHeadRot = (float)atan(xd / 40.0f) * 40; + horse->yHeadRotO = (float)atan(xd / 40.0f) * 40; + glTranslatef(0, horse->heightOffset, 0); + EntityRenderDispatcher::instance->playerRotY = 180; + EntityRenderDispatcher::instance->render(horse, 0, 0, 0, 0, 1); + horse->yBodyRot = oybr; + horse->yRot = oyr; + horse->xRot = oxr; + horse->yHeadRot = oyh; + horse->yHeadRotO = oyhp; + glPopMatrix(); + Lighting::turnOff(); + glDisable(GL_RESCALE_NORMAL); +#endif +} \ No newline at end of file diff --git a/Minecraft.Client/UI/Screens/HorseInventoryScreen.h b/Minecraft.Client/UI/Screens/HorseInventoryScreen.h new file mode 100644 index 000000000..12b0e68a2 --- /dev/null +++ b/Minecraft.Client/UI/Screens/HorseInventoryScreen.h @@ -0,0 +1,22 @@ +#pragma once +#include +#include "AbstractContainerScreen.h" +#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.animal.h" + +class HorseInventoryScreen : public AbstractContainerScreen { +public: + HorseInventoryScreen(std::shared_ptr inventory, + std::shared_ptr horseContainer, + std::shared_ptr horse); + + virtual void init() override; + virtual void renderLabels() override; + virtual void renderBg(float a) override; + virtual void render(int xm, int ym, float a) override; + +private: + std::shared_ptr inventory; + std::shared_ptr horseContainer; + std::shared_ptr horse; + float xMouse, yMouse; +}; \ No newline at end of file