From 89ed116fe0522003cf147ffc577f469a4cbcafa3 Mon Sep 17 00:00:00 2001 From: itsRevela Date: Tue, 28 Apr 2026 14:19:22 -0500 Subject: [PATCH] fix: beacon outer halo washed out behind water --- Minecraft.Client/BeaconRenderer.cpp | 37 ++++++++++++++--------------- Minecraft.Client/BeaconRenderer.h | 2 ++ Minecraft.Client/GameRenderer.cpp | 4 ++++ Minecraft.Client/LevelRenderer.cpp | 25 +++++++++++++++++++ Minecraft.Client/LevelRenderer.h | 1 + 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/Minecraft.Client/BeaconRenderer.cpp b/Minecraft.Client/BeaconRenderer.cpp index 9f6e9a26..23625442 100644 --- a/Minecraft.Client/BeaconRenderer.cpp +++ b/Minecraft.Client/BeaconRenderer.cpp @@ -6,6 +6,8 @@ ResourceLocation BeaconRenderer::BEAM_LOCATION = ResourceLocation(TN_MISC_BEACON_BEAM); +bool BeaconRenderer::s_renderOuterHalo = false; + void BeaconRenderer::render(shared_ptr _beacon, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled) { shared_ptr beacon = dynamic_pointer_cast(_beacon); @@ -18,21 +20,18 @@ void BeaconRenderer::render(shared_ptr _beacon, double x, double y, bindTexture(&BEAM_LOCATION); - // TODO: 4J: Put this back in - //assert(0); - //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glDisable(GL_LIGHTING); glDisable(GL_CULL_FACE); - glDisable(GL_BLEND); - glDepthMask(true); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); float tt = beacon->getLevel()->getGameTime() + a; float texVOff = -tt * .20f - floor(-tt * .10f); + if (!s_renderOuterHalo) { + glDisable(GL_BLEND); + glDepthMask(true); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + int r = 1; double rot = tt * .025 * (1 - (r & 1) * 2.5); @@ -73,20 +72,20 @@ void BeaconRenderer::render(shared_ptr _beacon, double x, double y, t->vertexUV(x + enx, y, z + enz, uu2, vv2); t->vertexUV(x + esx, y, z + esz, uu1, vv2); t->vertexUV(x + esx, y + top, z + esz, uu1, vv1); - + t->vertexUV(x + wsx, y + top, z + wsz, uu2, vv1); t->vertexUV(x + wsx, y, z + wsz, uu2, vv2); t->vertexUV(x + wnx, y, z + wnz, uu1, vv2); t->vertexUV(x + wnx, y + top, z + wnz, uu1, vv1); - + t->end(); } - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDepthMask(false); - + else { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDepthMask(false); + t->begin(); t->color(255, 255, 255, 32); @@ -111,22 +110,22 @@ void BeaconRenderer::render(shared_ptr _beacon, double x, double y, t->vertexUV(x + wnx, y, z + wnz, uu2, vv2); t->vertexUV(x + enx, y, z + enz, uu1, vv2); t->vertexUV(x + enx, y + top, z + enz, uu1, vv1); - + t->vertexUV(x + esx, y + top, z + esz, uu2, vv1); t->vertexUV(x + esx, y, z + esz, uu2, vv2); t->vertexUV(x + wsx, y, z + wsz, uu1, vv2); t->vertexUV(x + wsx, y + top, z + wsz, uu1, vv1); - + t->vertexUV(x + enx, y + top, z + enz, uu2, vv1); t->vertexUV(x + enx, y, z + enz, uu2, vv2); t->vertexUV(x + esx, y, z + esz, uu1, vv2); t->vertexUV(x + esx, y + top, z + esz, uu1, vv1); - + t->vertexUV(x + wsx, y + top, z + wsz, uu2, vv1); t->vertexUV(x + wsx, y, z + wsz, uu2, vv2); t->vertexUV(x + wnx, y, z + wnz, uu1, vv2); t->vertexUV(x + wnx, y + top, z + wnz, uu1, vv1); - + t->end(); } diff --git a/Minecraft.Client/BeaconRenderer.h b/Minecraft.Client/BeaconRenderer.h index 0626b374..31d629db 100644 --- a/Minecraft.Client/BeaconRenderer.h +++ b/Minecraft.Client/BeaconRenderer.h @@ -9,5 +9,7 @@ private: static ResourceLocation BEAM_LOCATION; public: + static bool s_renderOuterHalo; + virtual void render(shared_ptr _beacon, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled); }; diff --git a/Minecraft.Client/GameRenderer.cpp b/Minecraft.Client/GameRenderer.cpp index 9a36a703..8e4f8fda 100644 --- a/Minecraft.Client/GameRenderer.cpp +++ b/Minecraft.Client/GameRenderer.cpp @@ -1558,6 +1558,10 @@ void GameRenderer::renderLevel(float a, int64_t until) PIXEndNamedEvent(); } + PIXBeginNamedEvent(0,"Beacon beam halo (after water)"); + levelRenderer->renderBeaconBeams(a); + PIXEndNamedEvent(); + // 4J - added - have split out translucent particle rendering so that it happens after the water is rendered, primarily for fireworks PIXBeginNamedEvent(0,"Particle render (translucent)"); Lighting::turnOn(); diff --git a/Minecraft.Client/LevelRenderer.cpp b/Minecraft.Client/LevelRenderer.cpp index e1e89b58..37da2f94 100644 --- a/Minecraft.Client/LevelRenderer.cpp +++ b/Minecraft.Client/LevelRenderer.cpp @@ -6,6 +6,7 @@ #include "Chunk.h" #include "EntityRenderDispatcher.h" #include "TileEntityRenderDispatcher.h" +#include "BeaconRenderer.h" #include "DistanceChunkSorter.h" #include "DirtyChunkSorter.h" #include "MobSkinTextureProcessor.h" @@ -653,6 +654,30 @@ void LevelRenderer::renderEntities(Vec3 *cam, Culler *culler, float a) mc->gameRenderer->turnOffLightLayer(a); // 4J - brought forward from 1.8.2 } +void LevelRenderer::renderBeaconBeams(float a) +{ + if (mc == nullptr || mc->player == nullptr) return; + + int playerIndex = mc->player->GetXboxPad(); + if (level[playerIndex] == nullptr) return; + + BeaconRenderer::s_renderOuterHalo = true; + + EnterCriticalSection(&m_csRenderableTileEntities); + for (auto & it : renderableTileEntities) + { + if (!isGlobalIndexInSameDimension(it.first, level[playerIndex])) continue; + for (auto& te : it.second) + { + if (te->GetType() != eTYPE_BEACONTILEENTITY) continue; + TileEntityRenderDispatcher::instance->render(te, a); + } + } + LeaveCriticalSection(&m_csRenderableTileEntities); + + BeaconRenderer::s_renderOuterHalo = false; +} + wstring LevelRenderer::gatherStats1() { return L"C: " + std::to_wstring(renderedChunks) + L"/" + std::to_wstring(totalChunks) + L". F: " + std::to_wstring(offscreenChunks) + L", O: " + std::to_wstring(occludedChunks) + L", E: " + std::to_wstring(emptyChunks); diff --git a/Minecraft.Client/LevelRenderer.h b/Minecraft.Client/LevelRenderer.h index 30db8c4c..fb0949b5 100644 --- a/Minecraft.Client/LevelRenderer.h +++ b/Minecraft.Client/LevelRenderer.h @@ -77,6 +77,7 @@ public: void AddDLCSkinsToMemTextures(); public: void renderEntities(Vec3 *cam, Culler *culler, float a); + void renderBeaconBeams(float a); wstring gatherStats1(); wstring gatherStats2(); private: