Another Huge Commit my bad - shredder

Restored Java's Debug Screen using partial unused code and ported code, avaliable in options menu as a style

Slight Water texture is now overlayed when in water

Vignette function has been fixed and can now be toggled in options

World Generation now includes Tall Grass and Ferns both

Broken Frame Chart Graph found in the source has now been fixed and enabled when debug screen is turned on

Pie Chart works now and will appear when debug screen is opened

Most changes have not been tested on anything besides windows, will test it
This commit is contained in:
Shredder
2026-05-04 01:28:27 +05:00
parent 31d80aedf8
commit e346df682c
22 changed files with 247 additions and 76 deletions

View File

@@ -8,6 +8,7 @@
#include <string>
#include <cstdlib>
#if defined(APPLE_DEMO_PROMOTION)
#define NO_NETWORK
#endif
@@ -475,19 +476,20 @@ void Minecraft::update() {
#ifndef STANDALONE_SERVER
Multitouch::resetThisUpdate();
#endif
TIMER_POP();
#ifndef STANDALONE_SERVER
TIMER_POP();
checkGlError("Update finished");
if (options.getBooleanValue(OPTIONS_RENDER_DEBUG)) {
#ifndef PLATFORM_DESKTOP
//#ifndef PLATFORM_DESKTOP
if (!PerfTimer::enabled) {
PerfTimer::reset();
PerfTimer::enabled = true;
}
_perfRenderer->renderFpsMeter(1);
checkGlError("render debug");
#endif
//#endif
} else {
PerfTimer::enabled = false;
}
@@ -829,6 +831,12 @@ void Minecraft::tickInput() {
}
#endif
if (options.getBooleanValue(OPTIONS_RENDER_DEBUG)) {
if (key >= '0' && key <= '9') {
_perfRenderer->debugFpsMeterKeyPress(key - '0');
}
}
if (key == Keyboard::KEY_ESCAPE)
pauseGame(false);
@@ -840,6 +848,12 @@ void Minecraft::tickInput() {
//glPolygonMode(GL_BACK, isWireFrame? GL_LINE : GL_FILL);
}
#endif
if (key == Keyboard::KEY_P) {
static bool isWireFrame = false;
isWireFrame = !isWireFrame;
glPolygonMode(GL_FRONT, isWireFrame? GL_LINE : GL_FILL);
//glPolygonMode(GL_BACK, isWireFrame? GL_LINE : GL_FILL);
}
}
#ifdef WIN32
if (key == Keyboard::KEY_M) {
@@ -1410,10 +1424,10 @@ void Minecraft::_levelGenerated()
player->resetPos(false);
}
if (level && level->dimension) {
// For example, if you want FogType or any other option
level->dimension->FogType = options.getIntValue(OPTIONS_FOG_TYPE);
}
if (level && level->dimension) {
level->dimension->FogType = options.getIntValue(OPTIONS_FOG_TYPE);
}
this->cameraTargetPlayer = player;
@@ -1441,6 +1455,25 @@ void Minecraft::_levelGenerated()
_hasSignaledGeneratingLevelFinished = true;
}
std::string Minecraft::gatherStats1() {
return levelRenderer->gatherStats1();
}
std::string Minecraft::gatherStats2() {
return levelRenderer->gatherStats2();
}
std::string Minecraft::gatherStats3() {
return ("P: " + particleEngine->countParticles() + ". T: " + (level->gatherStats()));
}
std::string Minecraft::gatherStats4() {
return level->gatherChunkSourceStats();
}
Player* Minecraft::respawnPlayer(int playerId) {
for (unsigned int i = 0; i < level->players.size(); ++i) {
if (level->players[i]->entityId == playerId) {

View File

@@ -87,6 +87,14 @@ public:
void update();
std::string gatherStats1();
std::string gatherStats2();
std::string gatherStats4();
std::string gatherStats3();
void tick(int nTick, int maxTick);
void tickInput();

View File

@@ -58,6 +58,10 @@ OptionBool ambientOcclusion("ao", true);
OptionBool useNormalLighting("normalLighting", true);
OptionBool beautifulSky("beautifulSky", true);
OptionBool useVignette("useVignette", true);
OptionBool useTouchscreen("useTouchscreen", true);
OptionBool serverVisible("servervisible", true);
@@ -76,6 +80,8 @@ OptionBool blockOutline("blockOutline", false);
OptionBool restoredAnims("restoredAnims", true);
OptionInt debugStyle("debugStyle", 0, 0, 1);
OptionInt keyForward("key.forward", Keyboard::KEY_W);
OptionInt keyLeft("key.left", Keyboard::KEY_A);
OptionInt keyBack("key.back", Keyboard::KEY_S);
@@ -154,6 +160,10 @@ void Options::initTable() {
m_options[OPTIONS_BLOCK_OUTLINE] = &blockOutline;
m_options[OPTIONS_VIGNETTE] = &useVignette;
m_options[OPTIONS_BEAUTIFUL_SKY] = &beautifulSky;
m_options[OPTIONS_NORMAL_LIGHTING] = &useNormalLighting;
m_options[OPTIONS_RESTORED_ANIMS] = &restoredAnims;
@@ -187,6 +197,8 @@ void Options::initTable() {
// more options yay
m_options[OPTIONS_FOG_TYPE] = &fogType;
m_options[OPTIONS_DEBUG_STYLE] = &debugStyle;
m_options[OPTIONS_BETA_SKY] = &betaSky;
m_options[OPTIONS_TINTED_SIDE] = &tintedSide;

View File

@@ -92,6 +92,9 @@ enum OptionId {
OPTIONS_RESTORED_ANIMS,
OPTIONS_TINTED_SIDE,
OPTIONS_BETA_SKY,
OPTIONS_BEAUTIFUL_SKY,
OPTIONS_VIGNETTE,
OPTIONS_DEBUG_STYLE,
// Should be last!
OPTIONS_COUNT
};

View File

@@ -7,6 +7,7 @@
#include "screens/ConsoleScreen.h"
#include "../Minecraft.h"
#include "../player/LocalPlayer.h"
#include "../renderer/Chunk.h"
#include "../renderer/Tesselator.h"
#include "../renderer/TileRenderer.h"
#include "../renderer/LevelRenderer.h"
@@ -103,10 +104,10 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
}
}
// @todo - Shredder: I added this here but currently viginette is broken so i cant do much about it.
// if (minecraft->options.getBooleanValue(OPTIONS_FANCY_GRAPHICS)){
// this->renderVignette(this->minecraft->player->getBrightness(a), screenWidth, screenHeight);
// }
// viginette has been fixed, was due to gl_blend not being enabled, my bad
if (minecraft->options.getBooleanValue(OPTIONS_FANCY_GRAPHICS) && minecraft->options.getBooleanValue(OPTIONS_VIGNETTE)){
renderVignette(this->minecraft->player->getBrightness(a), screenWidth, screenHeight);
}
// shredder end
if(minecraft->player->getSleepTimer() > 0) {
@@ -121,7 +122,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
if (!minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) {
renderToolBar(a, ySlot, screenWidth);
font->drawShadow("Minecraft - Pocket Edition ", 2, 2, 0xffffffff);
// font->drawShadow("Minecraft - Pocket Edition ", 2, 2, 0xffffffff);
// font->drawShadow("This is a demo, not the finished product", 2, 10 + 2, 0xffffffff);
glEnable(GL_BLEND);
@@ -363,6 +364,7 @@ void Gui::renderVignette(float br, int w, int h) {
glDisable(GL_DEPTH_TEST);
glDepthMask(false);
glEnable(GL_BLEND);
glBlendFunc2(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
glColor4f2(tbr, tbr, tbr, 1);
@@ -379,6 +381,7 @@ void Gui::renderVignette(float br, int w, int h) {
t.draw();
glDepthMask(true);
glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
glColor4f2(1, 1, 1, 1);
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
@@ -729,13 +732,20 @@ void Gui::onLevelGenerated() {
void Gui::renderDebugInfo() {
// FPS counter (updates once per second)
static float fps = 0.0f;
static float fpsLastTime = 0.0f;
static int fps = 0;
static int fpsLastTime = 0;
static int fpsFrames = 0;
static int displayChunkUpdates = 0;
float now = getTimeS();
fpsFrames++;
if (now - fpsLastTime >= 1.0f) {
if (now - fpsLastTime >= 1) {
fps = fpsFrames / (now - fpsLastTime);
displayChunkUpdates = Chunk::updates;
// 3. RESET the actual game counter to 0 for the next second
Chunk::updates = 0;
fpsFrames = 0;
fpsLastTime = now;
}
@@ -773,6 +783,31 @@ void Gui::renderDebugInfo() {
long seed = lvl ? lvl->getSeed() : 0;
// Build lines (NULL entry = blank gap)
Font* font = minecraft->font;
// @todo - add our own debug screen as an option alongside the restored java one, why does renderdebug have to be so jank - shredder
// if java beta's restored debug menu is enabled
if (minecraft->options.getIntValue(OPTIONS_DEBUG_STYLE) == 0){
font->drawShadow("Minecraft - Pocket Edition ("
+ std::to_string((int)fps) + " fps, "
+ std::to_string(displayChunkUpdates) + " chunk updates)", 2, 2, 0xffffff);
font->drawShadow(minecraft->gatherStats1(), 2, 12, 0xFFFFFF);
font->drawShadow(minecraft->gatherStats2(), 2, 22, 0xFFFFFF);
font->drawShadow(minecraft->gatherStats3(), 2, 32, 0xFFFFFF);
font->drawShadow(minecraft->gatherStats4(), 2, 42, 0xFFFFFF);
drawString(font, "x: " + std::to_string(minecraft->player->x), 2, 64, 0xE0E0E0);
drawString(font, "y: " + std::to_string(minecraft->player->y), 2, 72, 0xE0E0E0);
drawString(font, "z: " + std::to_string(minecraft->player->z), 2, 80, 0xE0E0E0);
drawString(font, "f: " + std::to_string(Mth::floor(minecraft->player->yRot * 4.0f / 360.0f + 0.5) & 0x3), 2, 88, 0xE0E0E0);
drawString(font, "Seed: " + std::to_string(lvl->getSeed()), 2, 104, 0xE0E0E0);
drawString(font, "Dimension: " + std::to_string(lvl->dimension->id) + " (" + lvl->dimension->getDimension() + ")", 2, 114, 0xE0E0E0);
drawString(font, "Biome: " + std::string(biomeName), 2, 124, 0xE0E0E0);
}
else if (minecraft->options.getIntValue(OPTIONS_DEBUG_STYLE) == 1){
static char ln[8][96];
sprintf(ln[0], "Minecraft PE 0.6.1 alpha (mcpe64)");
sprintf(ln[1], "%.1f fps", fps);
@@ -787,8 +822,8 @@ void Gui::renderDebugInfo() {
const float LH = (float)Font::DefaultLineHeight; // 10 font-pixels
const float MGN = 2.0f; // left/top margin in font-pixels
const float PAD = 2.0f; // horizontal padding for background
Font* font = minecraft->font;
// Font* font = minecraft->font;
// 1) Draw semi-transparent background boxes behind each line
for (int i = 0; i < N; i++) {
if (ln[i][0] == '\0') continue;
@@ -810,6 +845,7 @@ void Gui::renderDebugInfo() {
font->draw(ln[i], MGN, y, col);
}
t.endOverrideAndDraw();
}
}
void Gui::renderPlayerList(Font* font, int screenWidth, int screenHeight) {

View File

@@ -36,7 +36,7 @@ void OptionsItem::render( Minecraft* minecraft, int xm, int ym ) {
}
text += ": " + scaleText;
}
if (m_optionId == OPTIONS_FOG_TYPE) {
if (m_optionId == OPTIONS_FOG_TYPE) {
int value = minecraft->options.getIntValue(OPTIONS_FOG_TYPE);
std::string scaleText;
switch (value) {
@@ -46,6 +46,16 @@ void OptionsItem::render( Minecraft* minecraft, int xm, int ym ) {
}
text += ": " + scaleText;
}
if (m_optionId == OPTIONS_DEBUG_STYLE) {
int value = minecraft->options.getIntValue(OPTIONS_DEBUG_STYLE);
std::string scaleText;
switch (value) {
case 0: scaleText = I18n::get("options.debugStyle.javaBeta"); break;
case 1: scaleText = I18n::get("options.debugStyle.custom"); break;
case 2: scaleText = I18n::get("options.fogType.unused"); break;
}
text += ": " + scaleText;
}
minecraft->font->draw(text, (float)x, (float)y + yOffset, 0x909090, false);
super::render(minecraft, xm, ym);

View File

@@ -227,7 +227,9 @@ void OptionsScreen::generateOptionScreens() {
.addOptionItem(OPTIONS_ANAGLYPH_3D, minecraft)
.addOptionItem(OPTIONS_VIEW_BOBBING, minecraft)
.addOptionItem(OPTIONS_AMBIENT_OCCLUSION, minecraft)
.addOptionItem(OPTIONS_NORMAL_LIGHTING, minecraft);
.addOptionItem(OPTIONS_NORMAL_LIGHTING, minecraft)
.addOptionItem(OPTIONS_BEAUTIFUL_SKY, minecraft)
.addOptionItem(OPTIONS_VIGNETTE, minecraft);
optionPanes[4]->addOptionItem(OPTIONS_ALLOW_SPRINT, minecraft)
.addOptionItem(OPTIONS_BAR_ON_TOP, minecraft)
@@ -237,7 +239,8 @@ void OptionsScreen::generateOptionScreens() {
.addOptionItem(OPTIONS_JAVA_HUD, minecraft)
.addOptionItem(OPTIONS_FOG_TYPE, minecraft)
.addOptionItem(OPTIONS_BETA_SKY, minecraft)
.addOptionItem(OPTIONS_RESTORED_ANIMS, minecraft);
.addOptionItem(OPTIONS_RESTORED_ANIMS, minecraft)
.addOptionItem(OPTIONS_DEBUG_STYLE, minecraft);
}

View File

@@ -285,7 +285,7 @@ void GameRenderer::renderLevel(float a) {
mc->levelRenderer->cull(&frustum, a);
mc->levelRenderer->updateDirtyChunks(cameraEntity, false);
// this sky rendering code below was originally before the frustrum and culling stuff but sunset color breaks for some reason in that place, so i moved i after those two - shredder
if(mc->options.getBooleanValue(OPTIONS_FANCY_GRAPHICS)) {
// if(mc->options.getBooleanValue(OPTIONS_FANCY_GRAPHICS)) {
setupFog(-1);
TIMER_POP_PUSH("sky");
// @TODO - EXTREME JANK BELOW, it works but i have to do heavy cleanup here, also to test if the glfogf commands even affect fog in anyway.
@@ -298,7 +298,7 @@ void GameRenderer::renderLevel(float a) {
glFogf(GL_FOG_START, renderDistance * 0.6f);
glFogf(GL_FOG_END, renderDistance);
}
}
// }
glEnable2(GL_FOG);
setupFog(1);
// MCPE renders clouds using this, but this method breaks 3d clouds and also breaks 2d clouds transparency viewed from above, add as a Legacy Sky or Fast Sky option. - shredder

View File

@@ -443,10 +443,10 @@ void ItemInHandRenderer::renderScreenEffect( float a )
}
}
// if (mc->player->isUnderLiquid(Material::water)) {
//mc->textures->loadAndBindTexture("misc/water.png");
// renderWater(a);
// }
if (mc->player->isUnderLiquid(Material::water)) {
mc->textures->loadAndBindTexture("misc/water.png");
renderWater(a);
}
glEnable2(GL_ALPHA_TEST);
}

View File

@@ -1063,9 +1063,9 @@ std::string LevelRenderer::gatherStats1() {
}
//
// /*public*/ std::string gatherStats2() {
// return "E: " + renderedEntities + "/" + totalEntities + ". B: " + culledEntities + ", I: " + ((totalEntities - culledEntities) - renderedEntities);
// }
std::string LevelRenderer::gatherStats2() {
return "E: " + std::to_string(renderedEntities) + "/" + std::to_string(totalEntities) + ". B: " + std::to_string(culledEntities) + ", I: " + std::to_string(((totalEntities - culledEntities) - renderedEntities));
}
//
// int[] toRender = new int[50000];
// IntBuffer resultBuffer = MemoryTracker.createIntBuffer(64);
@@ -1158,6 +1158,7 @@ void LevelRenderer::renderSky(float alpha) {
// thanks to the mcpe 0.1 decomp project a bit for this part, was not getting the gl states correctly, gles is painful - shredder
// Sunrise
if (mc->options.getBooleanValue(OPTIONS_BEAUTIFUL_SKY)) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -1228,6 +1229,7 @@ void LevelRenderer::renderSky(float alpha) {
glColor4f(a, a, a, a);
drawArrayVT(starBuffer, starVertexCount);
}
}
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
@@ -1240,7 +1242,9 @@ void LevelRenderer::renderSky(float alpha) {
glColor3f(sc.x * 0.2f + 0.04f, sc.y * 0.2f + 0.04f, sc.z * 0.6f + 0.1f);
glDisable(GL_TEXTURE_2D);
drawArrayVT(voidBuffer, voidVertexCount);
if(mc->options.getBooleanValue(OPTIONS_BETA_SKY)){
drawArrayVT(voidBuffer, voidVertexCount);
}
glEnable(GL_TEXTURE_2D);
// @TODO shredder - should not enable or disable depth mask if using legacy sky because mcpe sky rendering is awful and will render clouds above terrain
@@ -1251,7 +1255,7 @@ void LevelRenderer::renderSky(float alpha) {
void LevelRenderer::renderClouds( float alpha ) {
//if (!mc->level->dimension->isNaturalDimension()) return;
if (mc->options.getBooleanValue(OPTIONS_FANCY_GRAPHICS)){
if (mc->options.getBooleanValue(OPTIONS_FANCY_GRAPHICS) && mc->options.getBooleanValue(OPTIONS_BETA_SKY)){
renderAdvancedClouds(alpha);
return;
}

View File

@@ -69,6 +69,7 @@ public:
void levelEvent(Player* source, int type, int x, int y, int z, int data);
std::string gatherStats1();
std::string gatherStats2();
void render(const AABB& b) const;
void onGraphicsReset();