@@ -859,88 +859,176 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
859859 glTranslatef ((float )debugLeft, (float )debugTop, 0 .f );
860860 glScalef (scale, scale, 1 .f );
861861 glTranslatef ((float )-debugLeft, (float )-debugTop, 0 .f );
862- if (Minecraft::warezTime > 0 ) glTranslatef (0 , 32 , 0 );
863- font->drawShadow (ClientConstants::VERSION_STRING + L" (" + minecraft->fpsString + L" )" , debugLeft, debugTop, 0xffffff );
864- font->drawShadow (L" Seed: " + std::to_wstring (minecraft->level ->getLevelData ()->getSeed () ), debugLeft, debugTop + 12 , 0xffffff );
865- font->drawShadow (minecraft->gatherStats1 (), debugLeft, debugTop + 22 , 0xffffff );
866- font->drawShadow (minecraft->gatherStats2 (), debugLeft, debugTop + 32 , 0xffffff );
867- font->drawShadow (minecraft->gatherStats3 (), debugLeft, debugTop + 42 , 0xffffff );
868- font->drawShadow (minecraft->gatherStats4 (), debugLeft, debugTop + 52 , 0xffffff );
869-
870- // TERRAIN FEATURES
871- int iYPos = debugTop + 62 ;
872-
873- if (minecraft->level ->dimension ->id ==0 )
862+
863+ vector<wstring> lines;
864+
865+ lines.push_back (ClientConstants::VERSION_STRING);
866+ lines.push_back (minecraft->fpsString );
867+ lines.push_back (L" E: " + std::to_wstring (minecraft->level ->getAllEntities ().size ())); // Could maybe use entity::shouldRender to work out how many are rendered but thats like expensive
868+ // TODO Add server information with packet counts - once multiplayer is more stable
869+ int renderDistance = app.GetGameSettings (iPad, eGameSetting_RenderDistance);
870+ // Calculate the chunk sections using 16 * (2n + 1)^2
871+ lines.push_back (L" C: " + std::to_wstring (16 * (2 * renderDistance + 1 ) * (2 * renderDistance + 1 )) + L" D: " + std::to_wstring (renderDistance));
872+ lines.push_back (minecraft->gatherStats4 ()); // Chunk Cache
873+
874+ // Dimension
875+ wstring dimension = L" unknown" ;
876+ switch (minecraft->player ->dimension )
877+ {
878+ case -1 :
879+ dimension = L" minecraft:the_nether" ;
880+ break ;
881+ case 0 :
882+ dimension = L" minecraft:overworld" ;
883+ break ;
884+ case 1 :
885+ dimension = L" minecraft:the_end" ;
886+ break ;
887+ }
888+ lines.push_back (dimension);
889+
890+ lines.push_back (L" " ); // Spacer
891+
892+ // Players block pos
893+ int xBlockPos = Mth::floor (minecraft->player ->x );
894+ int yBlockPos = Mth::floor (minecraft->player ->y );
895+ int zBlockPos = Mth::floor (minecraft->player ->z );
896+
897+ // Chunk player is in
898+ int xChunkPos = minecraft->player ->xChunk ;
899+ int yChunkPos = minecraft->player ->yChunk ;
900+ int zChunkPos = minecraft->player ->zChunk ;
901+
902+ // Players offset within the chunk
903+ int xChunkOffset = xBlockPos - xChunkPos * 16 ;
904+ int yChunkOffset = yBlockPos - yChunkPos * 16 ;
905+ int zChunkOffset = zBlockPos - zChunkPos * 16 ;
906+
907+ // Format the position like java with limited decumal places
908+ WCHAR posString[44 ]; // Allows upto 7 digit positions (+-9_999_999)
909+ swprintf (posString, 44 , L" %.3f / %.5f / %.3f" , minecraft->player ->x , minecraft->player ->y , minecraft->player ->z );
910+
911+ lines.push_back (L" XYZ: " + std::wstring (posString));
912+ lines.push_back (L" Block: " + std::to_wstring (static_cast <int >(xBlockPos)) + L" " + std::to_wstring (static_cast <int >(yBlockPos)) + L" " + std::to_wstring (static_cast <int >(zBlockPos)));
913+ lines.push_back (L" Chunk: " + std::to_wstring (xChunkOffset) + L" " + std::to_wstring (yChunkOffset) + L" " + std::to_wstring (zChunkOffset) + L" in " + std::to_wstring (xChunkPos) + L" " + std::to_wstring (yChunkPos) + L" " + std::to_wstring (zChunkPos));
914+
915+ // Wrap the yRot to 360 then adjust to (-180 to 180) range to match java
916+ float yRotDisplay = fmod (minecraft->player ->yRot , 360 .0f );
917+ if (yRotDisplay > 180 .0f )
918+ {
919+ yRotDisplay -= 360 .0f ;
920+ }
921+ if (yRotDisplay < -180 .0f )
922+ {
923+ yRotDisplay += 360 .0f ;
924+ }
925+ // Generate the angle string in the format "yRot / xRot" with one decimal place, similar to java edition
926+ WCHAR angleString[16 ];
927+ swprintf (angleString, 16 , L" %.1f / %.1f" , yRotDisplay, minecraft->player ->xRot );
928+
929+ // Work out the named direction
930+ int direction = Mth::floor (minecraft->player ->yRot * 4 .0f / 360 .0f + 0.5 ) & 0x3 ;
931+ wstring cardinalDirection;
932+ switch (direction)
933+ {
934+ case 0 :
935+ cardinalDirection = L" south" ;
936+ break ;
937+ case 1 :
938+ cardinalDirection = L" west" ;
939+ break ;
940+ case 2 :
941+ cardinalDirection = L" north" ;
942+ break ;
943+ case 3 :
944+ cardinalDirection = L" east" ;
945+ break ;
946+ }
947+
948+ lines.push_back (L" Facing: " + cardinalDirection + L" (" + angleString + L" )" );
949+
950+ // We have to limit y to 256 as we don't get any information past that
951+ if (minecraft->level != NULL && minecraft->level ->hasChunkAt (xBlockPos, fmod (yBlockPos, 256 ), zBlockPos))
874952 {
875- wstring wfeature[eTerrainFeature_Count] ;
953+ LevelChunk *chunkAt = minecraft-> level -> getChunkAt (xBlockPos, zBlockPos) ;
876954
877- wfeature[eTerrainFeature_Stronghold] = L" Stronghold: " ;
878- wfeature[eTerrainFeature_Mineshaft] = L" Mineshaft: " ;
879- wfeature[eTerrainFeature_Village] = L" Village: " ;
880- wfeature[eTerrainFeature_Ravine] = L" Ravine : " ;
955+ int skyLight = chunkAt-> getBrightness (LightLayer::Sky, xChunkOffset, yChunkOffset, zChunkOffset) ;
956+ int blockLight = chunkAt-> getBrightness (LightLayer::Block, xChunkOffset, yChunkOffset, zChunkOffset) ;
957+ int maxLight = fmax (skyLight, blockLight) ;
958+ lines. push_back ( L" Light : " + std::to_wstring (maxLight) + L" ( " + std::to_wstring (skyLight) + L" sky, " + std::to_wstring (blockLight) + L" block) " ) ;
881959
882- float maxW = (float )(screenWidth - debugLeft - 8 ) / scale;
883- float maxWForContent = maxW - (float )font->width (L" ..." );
884- bool truncated[eTerrainFeature_Count] = {};
960+ lines.push_back (L" CH S: " + std::to_wstring (chunkAt->getHeightmap (xChunkOffset, zChunkOffset)));
885961
886- for (int i = 0 ; i < (int )app.m_vTerrainFeatures .size (); i++)
887- {
888- FEATURE_DATA *pFeatureData=app.m_vTerrainFeatures [i];
889- int type = pFeatureData->eTerrainFeature ;
890- if (type < eTerrainFeature_Stronghold || type > eTerrainFeature_Ravine) continue ;
891- if (truncated[type]) continue ;
892-
893- wstring itemInfo = L" [" + std::to_wstring ( pFeatureData->x *16 ) + L" , " + std::to_wstring ( pFeatureData->z *16 ) + L" ] " ;
894- if (font->width (wfeature[type] + itemInfo) <= maxWForContent)
895- wfeature[type] += itemInfo;
896- else
897- {
898- wfeature[type] += L" ..." ;
899- truncated[type] = true ;
900- }
901- }
962+ Biome *biome = chunkAt->getBiome (xChunkOffset, zChunkOffset, minecraft->level ->getBiomeSource ());
963+ lines.push_back (L" Biome: " + biome->m_name + L" (" + std::to_wstring (biome->id ) + L" )" );
902964
903- for ( int i = eTerrainFeature_Stronghold; i < (int ) eTerrainFeature_Count; i++ )
904- {
905- iYPos+=10 ;
906- font->drawShadow (wfeature[i], debugLeft, iYPos, 0xffffff );
907- }
965+ lines.push_back (L" Difficulty: " + std::to_wstring (minecraft->level ->difficulty ) + L" (Day " + std::to_wstring (minecraft->level ->getGameTime () / Level::TICKS_PER_DAY) + L" )" );
908966 }
909967
910- // font->drawShadow(minecraft->gatherStats5(), iSafezoneXHalf+2, 32 + 10, 0xffffff);
911- {
912- /* 4J - removed
913- long max = Runtime.getRuntime().maxMemory();
914- long total = Runtime.getRuntime().totalMemory();
915- long free = Runtime.getRuntime().freeMemory();
916- long used = total - free;
917- String msg = "Used memory: " + (used * 100 / max) + "% (" + (used / 1024 / 1024) + "MB) of " + (max / 1024 / 1024) + "MB";
918- drawString(font, msg, screenWidth - font.width(msg) - 2, 2, 0xe0e0e0);
919- msg = "Allocated memory: " + (total * 100 / max) + "% (" + (total / 1024 / 1024) + "MB)";
920- drawString(font, msg, screenWidth - font.width(msg) - 2, 12, 0xe0e0e0);
921- */
968+
969+ // This is all LCE only stuff, it was never on java
970+ lines.push_back (L" " ); // Spacer
971+ lines.push_back (L" Seed: " + std::to_wstring (minecraft->level ->getLevelData ()->getSeed ()));
972+ lines.push_back (minecraft->gatherStats1 ()); // Time to autosave
973+ lines.push_back (minecraft->gatherStats2 ()); // Empty currently - CPlatformNetworkManagerStub::GatherStats()
974+ lines.push_back (minecraft->gatherStats3 ()); // RTT
975+
976+ #ifdef _DEBUG // Only show terrain features in debug builds not release
977+ // TERRAIN FEATURES
978+ if (minecraft->level ->dimension ->id == 0 )
979+ {
980+ wstring wfeature[eTerrainFeature_Count];
981+
982+ wfeature[eTerrainFeature_Stronghold] = L" Stronghold: " ;
983+ wfeature[eTerrainFeature_Mineshaft] = L" Mineshaft: " ;
984+ wfeature[eTerrainFeature_Village] = L" Village: " ;
985+ wfeature[eTerrainFeature_Ravine] = L" Ravine: " ;
986+
987+ float maxW = (float )(screenWidth - debugLeft - 8 ) / scale;
988+ float maxWForContent = maxW - (float )font->width (L" ..." );
989+ bool truncated[eTerrainFeature_Count] = {};
990+
991+ for (int i = 0 ; i < (int )app.m_vTerrainFeatures .size (); i++)
992+ {
993+ FEATURE_DATA *pFeatureData = app.m_vTerrainFeatures [i];
994+ int type = pFeatureData->eTerrainFeature ;
995+ if (type < eTerrainFeature_Stronghold || type > eTerrainFeature_Ravine)
996+ {
997+ continue ;
998+ }
999+ if (truncated[type])
1000+ {
1001+ continue ;
1002+ }
1003+
1004+ wstring itemInfo = L" [" + std::to_wstring (pFeatureData->x * 16 ) + L" , " + std::to_wstring (pFeatureData->z * 16 ) + L" ] " ;
1005+ if (font->width (wfeature[type] + itemInfo) <= maxWForContent)
1006+ {
1007+ wfeature[type] += itemInfo;
1008+ }
1009+ else
1010+ {
1011+ wfeature[type] += L" ..." ;
1012+ truncated[type] = true ;
1013+ }
1014+ }
1015+
1016+ lines.push_back (L" " ); // Add a spacer line
1017+ for (int i = eTerrainFeature_Stronghold; i <= (int )eTerrainFeature_Ravine; i++)
1018+ {
1019+ lines.push_back (wfeature[i]);
1020+ }
1021+ lines.push_back (L" " );
1022+ }
1023+ #endif
1024+
1025+ // Loop through the lines and draw them all on screen
1026+ int yPos = debugTop;
1027+ for (const auto &line : lines)
1028+ {
1029+ drawString (font, line, debugLeft, yPos, 0xffffff );
1030+ yPos += 10 ;
9221031 }
923- // 4J Stu - Moved these so that they don't overlap
924- double xBlockPos = floor (minecraft->player ->x );
925- double yBlockPos = floor (minecraft->player ->y );
926- double zBlockPos = floor (minecraft->player ->z );
927- drawString (font, L" x: " + std::to_wstring (minecraft->player ->x ) + L" / Head: " + std::to_wstring (static_cast <int >(xBlockPos)) + L" / Chunk: " + std::to_wstring (minecraft->player ->xChunk ), debugLeft, iYPos + 8 * 0 , 0xe0e0e0 );
928- drawString (font, L" y: " + std::to_wstring (minecraft->player ->y ) + L" / Head: " + std::to_wstring (static_cast <int >(yBlockPos)), debugLeft, iYPos + 8 * 1 , 0xe0e0e0 );
929- drawString (font, L" z: " + std::to_wstring (minecraft->player ->z ) + L" / Head: " + std::to_wstring (static_cast <int >(zBlockPos)) + L" / Chunk: " + std::to_wstring (minecraft->player ->zChunk ), debugLeft, iYPos + 8 * 2 , 0xe0e0e0 );
930- drawString (font, L" f: " + std::to_wstring (Mth::floor (minecraft->player ->yRot * 4 .0f / 360 .0f + 0.5 ) & 0x3 ) + L" / yRot: " + std::to_wstring (minecraft->player ->yRot ), debugLeft, iYPos + 8 * 3 , 0xe0e0e0 );
931- iYPos += 8 *4 ;
932-
933- int px = Mth::floor (minecraft->player ->x );
934- int py = Mth::floor (minecraft->player ->y );
935- int pz = Mth::floor (minecraft->player ->z );
936- if (minecraft->level != NULL && minecraft->level ->hasChunkAt (px, py, pz))
937- {
938- LevelChunk *chunkAt = minecraft->level ->getChunkAt (px, pz);
939- Biome *biome = chunkAt->getBiome (px & 15 , pz & 15 , minecraft->level ->getBiomeSource ());
940- drawString (
941- font,
942- L" b: " + biome->m_name + L" (" + std::to_wstring (biome->id ) + L" )" , debugLeft, iYPos, 0xe0e0e0 );
943- }
9441032
9451033 glPopMatrix ();
9461034 }
0 commit comments