Improvements

* Use new ZYX Loops order in LevelRenderer::allChanged
* Revert xt, yt, zt change in PathFinder
* Fix return in PathFinder
This commit is contained in:
GabsPuNs
2026-05-17 14:48:58 -04:00
parent 83c7d9dfd9
commit 5696074313
2 changed files with 28 additions and 31 deletions

View File

@@ -424,9 +424,7 @@ void LevelRenderer::allChanged(int playerIndex)
// deadlock when starting a game in splitscreen.
//EnterCriticalSection(&m_csDirtyChunks);
if( level == nullptr )
{
return;
}
Minecraft::GetInstance()->gameRenderer->DisableUpdateThread();
@@ -458,12 +456,11 @@ void LevelRenderer::allChanged(int playerIndex)
delete chunks[playerIndex][i].chunk;
}
delete[] chunks[playerIndex].data;
// delete sortedChunks[playerIndex]; // 4J - removed - not sorting our chunks anymore
//delete sortedChunks[playerIndex]; // 4J - removed - not sorting our chunks anymore
}
chunks[playerIndex] = ClipChunkArray(xChunks * yChunks * zChunks);
// sortedChunks[playerIndex] = new vector<Chunk *>(xChunks * yChunks * zChunks); // 4J - removed - not sorting our chunks anymore
int id = 0;
//sortedChunks[playerIndex] = new vector<Chunk *>(xChunks * yChunks * zChunks); // 4J - removed - not sorting our chunks anymore
int count = 0;
xMinChunk = 0;
@@ -476,31 +473,31 @@ void LevelRenderer::allChanged(int playerIndex)
// 4J removed - we now only fully clear this on exiting the game (setting level to nullptr). Apart from that, the chunk rebuilding is responsible for maintaining this
// renderableTileEntities.clear();
for (int x = 0; x < xChunks; x++)
// Use new ZYX Loops order instead of Mojang XYZ Loops orders
for (int z = 0; z < zChunks; z++)
{
for (int y = 0; y < yChunks; y++)
{
for (int z = 0; z < zChunks; z++)
{
chunks[playerIndex][(z * yChunks + y) * xChunks + x].chunk = new Chunk(level[playerIndex], renderableTileEntities, m_csRenderableTileEntities, x * CHUNK_XZSIZE, y * CHUNK_SIZE, z * CHUNK_XZSIZE, &chunks[playerIndex][(z * yChunks + y) * xChunks + x]);
chunks[playerIndex][(z * yChunks + y) * xChunks + x].visible = true;
chunks[playerIndex][(z * yChunks + y) * xChunks + x].chunk->id = count++;
// sortedChunks[playerIndex]->at((z * yChunks + y) * xChunks + x) = chunks[playerIndex]->at((z * yChunks + y) * xChunks + x); // 4J - removed - not sorting our chunks anymore
id += 3;
}
}
for (int y = 0; y < yChunks; y++)
{
for (int x = 0; x < xChunks; x++)
{
int idx = (z * yChunks + y) * xChunks + x;
chunks[playerIndex][idx].chunk = new Chunk(level[playerIndex], renderableTileEntities, m_csRenderableTileEntities, x * CHUNK_XZSIZE, y * CHUNK_SIZE, z * CHUNK_XZSIZE, &chunks[playerIndex][idx]);
chunks[playerIndex][idx].visible = true;
chunks[playerIndex][idx].chunk->id = count++;
//sortedChunks[playerIndex]->at((z * yChunks + y) * xChunks + x) = chunks[playerIndex]->at((z * yChunks + y) * xChunks + x); // 4J - removed - not sorting our chunks anymore
}
}
}
nonStackDirtyChunksAdded();
if (level != nullptr)
shared_ptr<Entity> player = mc->cameraTargetPlayer;
if (player != nullptr)
{
shared_ptr<Entity> player = mc->cameraTargetPlayer;
if (player != nullptr)
{
this->resortChunks(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
// sort(sortedChunks[playerIndex]->begin(),sortedChunks[playerIndex]->end(), DistanceChunkSorter(player)); // 4J - removed - not sorting our chunks anymore
}
this->resortChunks(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
//sort(sortedChunks[playerIndex]->begin(),sortedChunks[playerIndex]->end(), DistanceChunkSorter(player)); // 4J - removed - not sorting our chunks anymore
}
noEntityRenderFrames = 2;