Skip to content

Commit 9cac3e0

Browse files
rtm516codeHusky
andauthored
Change F3 rendering and add git version information (MCLCE#836)
* Change F3 rendering and add git version information * Change position, block, chunk and facing * Limit position decimal places * Move LCE unique to the bottom and add more java features * Fix chunk information disappearing after y256 * Add chunk count information * Move build number script to prebuild.ps1 * We dont need to specify vector and wstring are from std * Restore build number to fix multiplayer * Use short symbolic-ref * Restore original BuildVer.h --------- Co-authored-by: Loki <lokio.casebstv@gmail.com> Co-authored-by: Loki Rautio <lokirautio@gmail.com>
1 parent e5ad785 commit 9cac3e0

File tree

8 files changed

+208
-134
lines changed

8 files changed

+208
-134
lines changed

.github/workflows/nightly.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
- name: Setup msbuild
2323
uses: microsoft/setup-msbuild@v2
24-
24+
2525
- name: Build
2626
run: MSBuild.exe MinecraftConsoles.sln /p:Configuration=Release /p:Platform="Windows64"
2727

@@ -30,7 +30,6 @@ jobs:
3030

3131
- name: Update release
3232
uses: andelf/nightly-release@main
33-
3433
env:
3534
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3635
with:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#include "stdafx.h"
22
#include "ClientConstants.h"
33

4-
const wstring ClientConstants::VERSION_STRING = wstring(L"Minecraft Xbox ") + VER_FILEVERSION_STR_W;//+ SharedConstants::VERSION_STRING;
4+
const wstring ClientConstants::VERSION_STRING = wstring(L"Minecraft LCE ") + VER_FILEVERSION_STR_W;//+ SharedConstants::VERSION_STRING;

Minecraft.Client/Common/BuildVer.h

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,6 @@
1-
21
#pragma once
32

4-
5-
#define VER_PRODUCTMAJORVERSION 0
6-
#define VER_PRODUCTMINORVERSION 0
7-
8-
// This goes up with each build
9-
// 4J-JEV: This value is extracted with a regex so it can be placed as the version in the AppX manifest on Durango.
10-
#define VER_PRODUCTBUILD 560
11-
// This goes up if there is any change to network traffic or code in a build
12-
#define VER_NETWORK 560
13-
#define VER_PRODUCTBUILD_QFE 0
14-
15-
#define VER_FILEVERSION_STRING "1.6"
16-
#define VER_PRODUCTVERSION_STRING VER_FILEVERSION_STRING
17-
#define VER_FILEVERSION_STRING_W L"1.6"
18-
#define VER_PRODUCTVERSION_STRING_W VER_FILEVERSION_STRING_W
19-
#define VER_FILEBETA_STR ""
20-
#undef VER_FILEVERSION
21-
#define VER_FILEVERSION VER_PRODUCTMAJORVERSION, VER_PRODUCTMINORVERSION, VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE
22-
#define VER_PRODUCTVERSION VER_PRODUCTMAJORVERSION, VER_PRODUCTMINORVERSION, VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE
23-
24-
#if (VER_PRODUCTBUILD < 10)
25-
#define VER_FILEBPAD "000"
26-
#define VER_FILEBPAD_W L"000"
27-
#elif (VER_PRODUCTBUILD < 100)
28-
#define VER_FILEBPAD "00"
29-
#define VER_FILEBPAD_W L"00"
30-
#elif (VER_PRODUCTBUILD < 1000)
31-
#define VER_FILEBPAD "0"
32-
#define VER_FILEBPAD_W L"0"
33-
#else
34-
#define VER_FILEBPAD
35-
#define VER_FILEBPAD_W
36-
#endif
37-
38-
#define VER_WIDE_PREFIX(x) L##x
39-
40-
#define VER_FILEVERSION_STR2(x,y) VER_FILEVERSION_STRING "." VER_FILEBPAD #x "." #y
41-
#define VER_FILEVERSION_STR2_W(x,y) VER_FILEVERSION_STRING_W L"." VER_FILEBPAD_W VER_WIDE_PREFIX(#x) L"." VER_WIDE_PREFIX(#y)
42-
#define VER_FILEVERSION_STR1(x,y) VER_FILEVERSION_STR2(x, y)
43-
#define VER_FILEVERSION_STR1_W(x,y) VER_FILEVERSION_STR2_W(x, y)
44-
45-
#undef VER_FILEVERSION_STR
46-
#define VER_FILEVERSION_STR VER_FILEVERSION_STR1(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE)
47-
#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR1(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE)
48-
49-
#define VER_FILEVERSION_STR_W VER_FILEVERSION_STR1_W(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE)
50-
#define VER_PRODUCTVERSION_STR_W VER_FILEVERSION_STR1_W(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE)
51-
52-
#if (VER_PRODUCTBUILD_QFE >= 256)
53-
#error "QFE number cannot exceed 255"
54-
#endif
55-
56-
57-
3+
#define VER_PRODUCTBUILD 560
4+
#define VER_PRODUCTVERSION_STR_W L"DEV (unknown)"
5+
#define VER_FILEVERSION_STR_W VER_PRODUCTVERSION_STR_W
6+
#define VER_NETWORK VER_PRODUCTBUILD

Minecraft.Client/Gui.cpp

Lines changed: 162 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

Minecraft.Client/Minecraft.Client.vcxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,12 @@ if not exist "$(TargetDir)\savedata" mkdir "$(TargetDir)\savedata"</Command>
15961596
<PostBuildEvent>
15971597
<Message>Run post-build script</Message>
15981598
</PostBuildEvent>
1599+
<PreBuildEvent>
1600+
<Command>powershell -ExecutionPolicy Bypass -File "$(ProjectDir)prebuild.ps1"</Command>
1601+
</PreBuildEvent>
1602+
<PreBuildEvent>
1603+
<Message>Run pre-build script</Message>
1604+
</PreBuildEvent>
15991605
</ItemDefinitionGroup>
16001606
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64EC'">
16011607
<ClCompile>
@@ -1825,6 +1831,12 @@ xcopy /q /y /i /s /e $(ProjectDir)DurangoMedia\CU $(LayoutDir)Image\Loose\CU</C
18251831
<DeploymentType>CopyToHardDrive</DeploymentType>
18261832
<DeploymentFiles>$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\res=Xbox\res;$(RemoteRoot)=Xbox\AvatarAwards;$(RemoteRoot)\Tutorial=Xbox\Tutorial\Tutorial;$(RemoteRoot)=Xbox\584111F70AAAAAAA;$(RemoteRoot)=Xbox\kinect\speech;$(RemoteRoot)=Xbox\XZP\TMSFiles.xzp</DeploymentFiles>
18271833
</Deploy>
1834+
<PreBuildEvent>
1835+
<Command>powershell -ExecutionPolicy Bypass -File "$(ProjectDir)prebuild.ps1"</Command>
1836+
</PreBuildEvent>
1837+
<PreBuildEvent>
1838+
<Message>Run pre-build script</Message>
1839+
</PreBuildEvent>
18281840
</ItemDefinitionGroup>
18291841
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64EC'">
18301842
<ClCompile>

Minecraft.Client/Minecraft.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ void Minecraft::run()
742742

743743
while (System::currentTimeMillis() >= lastTime + 1000)
744744
{
745-
fpsString = std::to_wstring(frames) + L" fps, " + std::to_wstring(Chunk::updates) + L" chunk updates";
745+
fpsString = std::to_wstring(frames) + L" fps (" + std::to_wstring(Chunk::updates) + L" chunk updates)";
746746
Chunk::updates = 0;
747747
lastTime += 1000;
748748
frames = 0;
@@ -2066,7 +2066,7 @@ void Minecraft::run_middle()
20662066
while (System::nanoTime() >= lastTime + 1000000000)
20672067
{
20682068
MemSect(31);
2069-
fpsString = std::to_wstring(frames) + L" fps, " + std::to_wstring(Chunk::updates) + L" chunk updates";
2069+
fpsString = std::to_wstring(frames) + L" fps (" + std::to_wstring(Chunk::updates) + L" chunk updates)";
20702070
MemSect(0);
20712071
Chunk::updates = 0;
20722072
lastTime += 1000000000;

Minecraft.Client/postbuild.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ foreach ($copy in $copies) {
3939
xcopy /q /y /i /s /e /d "$src" "$dst" 2>$null
4040
}
4141
}
42+
43+
git restore "**/BuildVer.h"

0 commit comments

Comments
 (0)