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 000000000..e7dc2031a Binary files /dev/null and b/Minecraft.Assets/Common/res/1_2_2/gui/brewing_stand.png differ 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