From 1c5311f05878c29da4e452a8fc5a1da83268b9d3 Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Sun, 22 Mar 2026 04:14:58 -0500 Subject: [PATCH] fixes to java UI and Minecraft.cpp --- Minecraft.Client/Minecraft.cpp | 14 ++--- Minecraft.Client/UI/Gui.cpp | 60 ++++++++++--------- Minecraft.Client/UI/Gui.h | 1 + .../UI/Screens/CreativeInventoryScreen.cpp | 8 +-- .../UI/Screens/TextEditScreen.cpp | 2 +- 5 files changed, 45 insertions(+), 40 deletions(-) diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 499766dfd..f4e577d90 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -1121,7 +1121,7 @@ std::shared_ptr Minecraft::createExtraLocalPlayer( localplayers[idx]->setOnlineXuid(playerXUIDOnline); localplayers[idx]->setIsGuest(ProfileManager.IsGuest(idx)); - localplayers[idx]->displayName = ProfileManager.GetDisplayName(idx); + localplayers[idx]->m_displayName = ProfileManager.GetDisplayName(idx); localplayers[idx]->m_iScreenSection = tempScreenSection; @@ -2025,7 +2025,7 @@ void Minecraft::run_middle() { PIXBeginNamedEvent(0, "Light update"); - if (level != NULL) level->updateLights(); + // if (level != NULL) level->updateLights(); glEnable(GL_TEXTURE_2D); PIXEndNamedEvent(); @@ -4529,7 +4529,7 @@ void Minecraft::setLevel(MultiPlayerLevel* level, int message /*=-1*/, player->setXuid(playerXUIDOffline); player->setOnlineXuid(playerXUIDOnline); - player->displayName = ProfileManager.GetDisplayName(iPrimaryPlayer); + player->m_displayName = ProfileManager.GetDisplayName(iPrimaryPlayer); player->resetPos(); gameMode->initPlayer(player); @@ -4638,9 +4638,9 @@ void Minecraft::prepareLevel(int title) { this->progressRenderer->progressStagePercentage((pp++) * 100 / max); level->getTile(spawnPos->x + x, 64, spawnPos->z + z); - if (!gameMode->isCutScene()) { - while (level->updateLights()); - } + // if (!gameMode->isCutScene()) { + // while (level->updateLights()); + // } } } delete spawnPos; @@ -4721,7 +4721,7 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) { player->setOnlineXuid(playerXUIDOnline); player->setIsGuest(ProfileManager.IsGuest(iTempPad)); - player->displayName = ProfileManager.GetDisplayName(iPad); + player->m_displayName = ProfileManager.GetDisplayName(iPad); player->SetXboxPad(iTempPad); diff --git a/Minecraft.Client/UI/Gui.cpp b/Minecraft.Client/UI/Gui.cpp index 67aadfed2..a07eca213 100644 --- a/Minecraft.Client/UI/Gui.cpp +++ b/Minecraft.Client/UI/Gui.cpp @@ -5,6 +5,7 @@ #include "../GameState/Options.h" #include "../Player/MultiPlayerLocalPlayer.h" #include "../Textures/Textures.h" +#include "../Textures/TextureAtlas.h" #include "../GameState/GameMode.h" #include "../Rendering/Lighting.h" #include "Screens/ChatScreen.h" @@ -28,6 +29,9 @@ #include "../../Minecraft.World/Level/LevelChunk.h" #include "../../Minecraft.World/WorldGen/Biomes/Biome.h" +ResourceLocation Gui::PUMPKIN_BLUR_LOCATION = + ResourceLocation(TN__BLUR__MISC_PUMPKINBLUR); + #ifdef ENABLE_JAVA_GUIS #define RENDER_HUD 1 #else @@ -636,7 +640,8 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { (displayCrouch || displaySprint || displayFlying)) { EntityRenderDispatcher::instance->prepare( minecraft->level, minecraft->textures, minecraft->font, - minecraft->cameraTargetPlayer, minecraft->options, a); + minecraft->cameraTargetPlayer, minecraft->crosshairPickMob, + minecraft->options, a); glEnable(GL_RESCALE_NORMAL); glEnable(GL_COLOR_MATERIAL); @@ -1116,38 +1121,38 @@ max) + "% (" + (total / 1024 / 1024) + "MB)"; drawString(font, msg, screenWidth // Moved to the xui base scene void Gui::renderBossHealth(void) { - if (EnderDragonRenderer::bossInstance == NULL) return; + // if (EnderDragonRenderer::bossInstance == NULL) return; - std::shared_ptr boss = EnderDragonRenderer::bossInstance; - EnderDragonRenderer::bossInstance = NULL; + // std::shared_ptr boss = EnderDragonRenderer::bossInstance; + // EnderDragonRenderer::bossInstance = NULL; - Minecraft* pMinecraft = Minecraft::GetInstance(); + // Minecraft* pMinecraft = Minecraft::GetInstance(); - Font* font = pMinecraft->font; + // Font* font = pMinecraft->font; - ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, - pMinecraft->height_phys); - int screenWidth = ssc.getWidth(); + // ScreenSizeCalculator ssc(pMinecraft->options, pMinecraft->width_phys, + // pMinecraft->height_phys); + // int screenWidth = ssc.getWidth(); - int w = 182; - int xLeft = screenWidth / 2 - w / 2; + // int w = 182; + // int xLeft = screenWidth / 2 - w / 2; - int progress = (int)(boss->getSynchedHealth() / - (float)boss->getMaxHealth() * (float)(w + 1)); + // int progress = (int)(boss->getSynchedHealth() / + // (float)boss->getMaxHealth() * (float)(w + 1)); - int yo = 12; - blit(xLeft, yo, 0, 74, w, 5); - blit(xLeft, yo, 0, 74, w, 5); - if (progress > 0) { - blit(xLeft, yo, 0, 79, progress, 5); - } + // int yo = 12; + // blit(xLeft, yo, 0, 74, w, 5); + // blit(xLeft, yo, 0, 74, w, 5); + // if (progress > 0) { + // blit(xLeft, yo, 0, 79, progress, 5); + // } - std::wstring msg = L"Boss health" /*L"Boss health - NON LOCALISED"*/; - font->drawShadow(msg, screenWidth / 2 - font->width(msg) / 2, yo - 10, - 0xff00ff); - glColor4f(1, 1, 1, 1); - glBindTexture(GL_TEXTURE_2D, pMinecraft->textures->loadTexture( - TN_GUI_ICONS)); //"/gui/icons.png")); + // std::wstring msg = L"Boss health" /*L"Boss health - NON LOCALISED"*/; + // font->drawShadow(msg, screenWidth / 2 - font->width(msg) / 2, yo - 10, + // 0xff00ff); + // glColor4f(1, 1, 1, 1); + // glBindTexture(GL_TEXTURE_2D, pMinecraft->textures->loadTexture( + // TN_GUI_ICONS)); //"/gui/icons.png")); } void Gui::renderPumpkin(int w, int h) { @@ -1158,8 +1163,7 @@ void Gui::renderPumpkin(int w, int h) { glDisable(GL_ALPHA_TEST); MemSect(31); - minecraft->textures->bindTexture( - TN__BLUR__MISC_PUMPKINBLUR); // L"%blur%/misc/pumpkinblur.png")); + minecraft->textures->bindTexture(&PUMPKIN_BLUR_LOCATION); MemSect(0); Tesselator* t = Tesselator::getInstance(); t->begin(); @@ -1217,7 +1221,7 @@ void Gui::renderTp(float br, int w, int h) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1, 1, 1, br); MemSect(31); - minecraft->textures->bindTexture(TN_TERRAIN); // L"/terrain.png")); + minecraft->textures->bindTexture(&TextureAtlas::LOCATION_BLOCKS); // L"/terrain.png")); MemSect(0); Icon* slot = Tile::portalTile->getTexture(Facing::UP); diff --git a/Minecraft.Client/UI/Gui.h b/Minecraft.Client/UI/Gui.h index 376d74afe..ebedb9bc8 100644 --- a/Minecraft.Client/UI/Gui.h +++ b/Minecraft.Client/UI/Gui.h @@ -8,6 +8,7 @@ class ItemRenderer; class Gui : public GuiComponent { private: + static ResourceLocation PUMPKIN_BLUR_LOCATION; // 4J-PB - this doesn't account for the safe zone, and the indent applied to // messages // static const int MAX_MESSAGE_WIDTH = 320; diff --git a/Minecraft.Client/UI/Screens/CreativeInventoryScreen.cpp b/Minecraft.Client/UI/Screens/CreativeInventoryScreen.cpp index 5e431ed2b..65c495851 100644 --- a/Minecraft.Client/UI/Screens/CreativeInventoryScreen.cpp +++ b/Minecraft.Client/UI/Screens/CreativeInventoryScreen.cpp @@ -78,12 +78,12 @@ std::shared_ptr CreativeInventoryScreen::ContainerCreative::clicke } // Validate slot index - if (slotIndex < 0 || slotIndex >= (int)slots->size()) + if (slotIndex < 0 || slotIndex >= (int)slots.size()) { return std::shared_ptr(); } - Slot* slot = slots->at(slotIndex); + Slot* slot = slots.at(slotIndex); // Handle creative inventory slots (0-44) if (slotIndex >= 0 && slotIndex < ITEMS_PER_PAGE) @@ -282,11 +282,11 @@ void CreativeInventoryScreen::mouseClicked(int x, int y, int buttonNum) int slotId = -1; if (slot != NULL) slotId = slot->index; - if (clickedOutside) slotId = AbstractContainerMenu::CLICKED_OUTSIDE; + if (clickedOutside) slotId = AbstractContainerMenu::SLOT_CLICKED_OUTSIDE; if (slotId == -1) return; - bool quickKey = slotId != AbstractContainerMenu::CLICKED_OUTSIDE && + bool quickKey = slotId != AbstractContainerMenu::SLOT_CLICKED_OUTSIDE && (Keyboard::isKeyDown(Keyboard::KEY_LSHIFT) || Keyboard::isKeyDown(Keyboard::KEY_RSHIFT)); int clickType = quickKey ? AbstractContainerMenu::CLICK_QUICK_MOVE : AbstractContainerMenu::CLICK_PICKUP; diff --git a/Minecraft.Client/UI/Screens/TextEditScreen.cpp b/Minecraft.Client/UI/Screens/TextEditScreen.cpp index 2e8fe4580..0b9d3f637 100644 --- a/Minecraft.Client/UI/Screens/TextEditScreen.cpp +++ b/Minecraft.Client/UI/Screens/TextEditScreen.cpp @@ -11,7 +11,7 @@ #include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.h" const std::wstring TextEditScreen::allowedChars = - SharedConstants::readAcceptableChars(); + SharedConstants::acceptableLetters; TextEditScreen::TextEditScreen(std::shared_ptr sign) { // 4J - added initialisers