From 4b69a1240a90a5282f545271866818d6cc3357c3 Mon Sep 17 00:00:00 2001 From: Shredder Date: Tue, 12 May 2026 02:25:04 +0500 Subject: [PATCH] Some fixes Fixed Missing Lighting calls and GL states which was causing stars to render too early Split Controls should hopefully work on phones now Chickens should hopefully lay eggs now --- src/client/renderer/GameRenderer.cpp | 28 +++++++++++++++++++-------- src/client/renderer/LevelRenderer.cpp | 15 +++++++------- src/world/entity/animal/Chicken.cpp | 14 +++++++------- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/client/renderer/GameRenderer.cpp b/src/client/renderer/GameRenderer.cpp index 7acd4d41..e104e269 100755 --- a/src/client/renderer/GameRenderer.cpp +++ b/src/client/renderer/GameRenderer.cpp @@ -101,12 +101,22 @@ void GameRenderer::setupCamera(float a, int eye) { float stereoScale = 0.07f; if (mc->options.getBooleanValue(OPTIONS_ANAGLYPH_3D)) glTranslatef2(-(eye * 2 - 1) * stereoScale, 0, 0); - if (zoom != 1) { - glTranslatef2((float) zoom_x, (float) -zoom_y, 0); - glScalef2(zoom, zoom, 1); - gluPerspective(_setupCameraFov = getFov(a, true), mc->width / (float) mc->height, 0.05f, renderDistance); + if (mc->options.getBooleanValue(OPTIONS_BETA_SKY)){ + if (zoom != 1) { + glTranslatef2((float) zoom_x, (float) -zoom_y, 0); + glScalef2(zoom, zoom, 1); + gluPerspective(_setupCameraFov = getFov(a, true), mc->width / (float) mc->height, 0.05f, renderDistance * 2.0f); + } else { + gluPerspective(_setupCameraFov = getFov(a, true), mc->width / (float) mc->height, 0.05f, renderDistance * 2.0f); + } } else { - gluPerspective(_setupCameraFov = getFov(a, true), mc->width / (float) mc->height, 0.05f, renderDistance); + if (zoom != 1) { + glTranslatef2((float) zoom_x, (float) -zoom_y, 0); + glScalef2(zoom, zoom, 1); + gluPerspective(_setupCameraFov = getFov(a, true), mc->width / (float) mc->height, 0.05f, renderDistance); + } else { + gluPerspective(_setupCameraFov = getFov(a, true), mc->width / (float) mc->height, 0.05f, renderDistance); + } } glMatrixMode(GL_MODELVIEW); @@ -340,10 +350,12 @@ void GameRenderer::renderLevel(float a) { setupFog(0); glEnable2(GL_BLEND); glDisable2(GL_CULL_FACE); - glDepthMask(GL_FALSE); + glDepthMask(GL_FALSE); // @TODO commenting this out fixes Ice transparency and clouds are no longer visilbe underwater like normal beta - shredder glDisable2(GL_ALPHA_TEST); mc->textures->loadAndBindTexture("terrain.png"); - //if (mc->options.fancyGraphics) { + // @TODO - below is a commented out double render system that fixes ice transparency, but probs harm performance, add it as an option - shredder + + //if (mc->options.fancyGraphics) { // glColorMask(false, false, false, false); // int visibleWaterChunks = levelRenderer->render(cameraEntity, 1, a); // glColorMask(true, true, true, true); @@ -677,7 +689,7 @@ void GameRenderer::pick(float a) { float range = mc->gameMode->getPickRange(); bool isPicking = true; - bool freeform = mc->useTouchscreen(); //&& !mc->options.getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA); + bool freeform = mc->useTouchscreen() && !mc->options.getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA); if (freeform) { isPicking = updateFreeformPickDirection(a, pickDirection); diff --git a/src/client/renderer/LevelRenderer.cpp b/src/client/renderer/LevelRenderer.cpp index efccf215..2630d634 100755 --- a/src/client/renderer/LevelRenderer.cpp +++ b/src/client/renderer/LevelRenderer.cpp @@ -26,6 +26,7 @@ #include "../../client/player/LocalPlayer.h" #include "../../world/level/GrassColor.h" +#include "Lighting.h" #ifdef GFX_SMALLER_CHUNKS /* static */ const int LevelRenderer::CHUNK_SIZE = 8; @@ -1157,23 +1158,22 @@ void LevelRenderer::renderSky(float alpha) { glDisable(GL_FOG); glDisable(GL_ALPHA_TEST); - // thanks to the mcpe 0.1 decomp project a bit for this part, was not getting the gl states correctly, gles is painful - shredder + // re ported this again from beta 1.6.6, thanks to the mcpe 0.1 decomp team's code for some bit of help about the void layer - shredder // Sunrise if (mc->options.getBooleanValue(OPTIONS_BEAUTIFUL_SKY)) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - + Lighting::turnOff(); float* c = level->dimension->getSunriseColor(level->getTimeOfDay(alpha), alpha); if (c != nullptr) { glDisable(GL_TEXTURE_2D); - +// glShadeModel(GL_SMOOTH); // glPushMatrix(); glRotatef(90.0f, 1.0f, 0.0f, 0.0f); glRotatef(level->getTimeOfDay(alpha) > 0.5f ? 180 : 0, 0.0f, 0.0f, 1.0f); - t.begin(GL_TRIANGLE_FAN); t.color(c[0], c[1], c[2], c[3]); t.vertex(0.0f, 100.0f, 0.0f); @@ -1190,11 +1190,12 @@ void LevelRenderer::renderSky(float alpha) { t.draw(); glPopMatrix(); +// glShadeModel(GL_FLAT); // } // gets the time of day and rotates the sun and moon png based on the time glEnable(GL_TEXTURE_2D); - glBlendFunc(GL_ONE, GL_ONE); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); glPushMatrix(); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); @@ -1326,8 +1327,8 @@ void LevelRenderer::renderAdvancedClouds(float alpha) { float cloudTime = (float)ticks + alpha; - double xo = (px + cloudTime * 0.03f) / ss; - double zo = pz / ss + 0.33f; + float xo = (px + cloudTime * 0.03f) / ss; + float zo = pz / ss + 0.33f; float yy = 108.0f - py + 0.33f; diff --git a/src/world/entity/animal/Chicken.cpp b/src/world/entity/animal/Chicken.cpp index ca08fa1f..cc25555e 100755 --- a/src/world/entity/animal/Chicken.cpp +++ b/src/world/entity/animal/Chicken.cpp @@ -51,13 +51,13 @@ void Chicken::aiStep() flap += flapping * 2; //@todo - //if (!isBaby()) { - // if (!level->isClientSide && --eggTime <= 0) { - // level->playSound(this, "mob.chickenplop", 1.0f, (random.nextFloat() - random.nextFloat()) * 0.2f + 1.0f); - // spawnAtLocation(Item::egg->id, 1); - // eggTime = random.nextInt(SharedConstants::TicksPerSecond * 60 * 5) + SharedConstants::TicksPerSecond * 60 * 5; - // } - //} + if (!isBaby()) { + if (!level->isClientSide && --eggTime <= 0) { + level->playSound(this, "mob.chickenplop", 1.0f, (random.nextFloat() - random.nextFloat()) * 0.2f + 1.0f); + spawnAtLocation(Item::egg->id, 1); + eggTime = random.nextInt(SharedConstants::TicksPerSecond * 60 * 5) + SharedConstants::TicksPerSecond * 60 * 5; + } + } } void Chicken::addAdditonalSaveData( CompoundTag* tag )