chore: format Minecraft.World

This commit is contained in:
Tropical
2026-03-13 17:06:56 -05:00
parent bd6284025d
commit 33d0737d1d
1511 changed files with 108661 additions and 115521 deletions

View File

@@ -5,39 +5,31 @@
#include "../../Headers/net.minecraft.world.level.biome.h"
#include "../../Headers/net.minecraft.world.level.dimension.h"
std::vector<Biome *> VillageFeature::allowedBiomes;
std::vector<Biome*> VillageFeature::allowedBiomes;
void VillageFeature::staticCtor()
{
allowedBiomes.push_back( Biome::plains );
allowedBiomes.push_back( Biome::desert );
void VillageFeature::staticCtor() {
allowedBiomes.push_back(Biome::plains);
allowedBiomes.push_back(Biome::desert);
}
VillageFeature::VillageFeature(int villageSizeModifier, int iXZSize) : StructureFeature(), villageSizeModifier(villageSizeModifier)
{
m_iXZSize=iXZSize;
VillageFeature::VillageFeature(int villageSizeModifier, int iXZSize)
: StructureFeature(), villageSizeModifier(villageSizeModifier) {
m_iXZSize = iXZSize;
}
bool VillageFeature::isFeatureChunk(int x, int z,bool bIsSuperflat)
{
bool VillageFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) {
int townSpacing;
#ifdef _LARGE_WORLDS
if(level->dimension->getXZSize() > 128)
{
townSpacing = 32;
}
else
if (level->dimension->getXZSize() > 128) {
townSpacing = 32;
} else
#endif
if(bIsSuperflat)
{
townSpacing= 32;
}
else
{
townSpacing= 16;// 4J change 32;
}
if (bIsSuperflat) {
townSpacing = 32;
} else {
townSpacing = 16; // 4J change 32;
}
int minTownSeparation = 8;
@@ -48,7 +40,8 @@ bool VillageFeature::isFeatureChunk(int x, int z,bool bIsSuperflat)
int xCenterTownChunk = x / townSpacing;
int zCenterTownChunk = z / townSpacing;
Random *r = level->getRandomFor(xCenterTownChunk, zCenterTownChunk, 10387312);
Random* r =
level->getRandomFor(xCenterTownChunk, zCenterTownChunk, 10387312);
xCenterTownChunk *= townSpacing;
zCenterTownChunk *= townSpacing;
xCenterTownChunk += r->nextInt(townSpacing - minTownSeparation);
@@ -56,19 +49,19 @@ bool VillageFeature::isFeatureChunk(int x, int z,bool bIsSuperflat)
x = xx;
z = zz;
bool forcePlacement = false;
LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
if( levelGenOptions != NULL )
{
forcePlacement = levelGenOptions->isFeatureChunk(x,z,eFeature_Village);
}
bool forcePlacement = false;
LevelGenerationOptions* levelGenOptions = app.getLevelGenerationOptions();
if (levelGenOptions != NULL) {
forcePlacement =
levelGenOptions->isFeatureChunk(x, z, eFeature_Village);
}
if (forcePlacement || (x == xCenterTownChunk && z == zCenterTownChunk) )
{
bool biomeOk = level->getBiomeSource()->containsOnly(x * 16 + 8, z * 16 + 8, 0, allowedBiomes);
if (biomeOk)
{
//app.DebugPrintf("Biome ok for Village at %d, %d\n",(x * 16 + 8),(z * 16 + 8));
if (forcePlacement || (x == xCenterTownChunk && z == zCenterTownChunk)) {
bool biomeOk = level->getBiomeSource()->containsOnly(
x * 16 + 8, z * 16 + 8, 0, allowedBiomes);
if (biomeOk) {
// app.DebugPrintf("Biome ok for Village at %d, %d\n",(x * 16 +
// 8),(z * 16 + 8));
return true;
}
}
@@ -76,46 +69,46 @@ bool VillageFeature::isFeatureChunk(int x, int z,bool bIsSuperflat)
return false;
}
StructureStart *VillageFeature::createStructureStart(int x, int z)
{
// 4J added
app.AddTerrainFeaturePosition(eTerrainFeature_Village,x,z);
StructureStart* VillageFeature::createStructureStart(int x, int z) {
// 4J added
app.AddTerrainFeaturePosition(eTerrainFeature_Village, x, z);
return new VillageStart(level, random, x, z, villageSizeModifier, m_iXZSize);
return new VillageStart(level, random, x, z, villageSizeModifier,
m_iXZSize);
}
VillageFeature::VillageStart::VillageStart(Level *level, Random *random, int chunkX, int chunkZ, int villageSizeModifier, int iXZSize)
{
valid = false; // 4J added initialiser
m_iXZSize=iXZSize;
VillageFeature::VillageStart::VillageStart(Level* level, Random* random,
int chunkX, int chunkZ,
int villageSizeModifier,
int iXZSize) {
valid = false; // 4J added initialiser
m_iXZSize = iXZSize;
std::list<VillagePieces::PieceWeight *> *pieceSet = VillagePieces::createPieceSet(random, villageSizeModifier);
std::list<VillagePieces::PieceWeight*>* pieceSet =
VillagePieces::createPieceSet(random, villageSizeModifier);
// 4jcraft added casts to u
VillagePieces::StartPiece *startRoom = new VillagePieces::StartPiece(level->getBiomeSource(), 0, random, ((unsigned) chunkX << 4) + 2, ((unsigned) chunkZ << 4) + 2, pieceSet, villageSizeModifier, level);
pieces.push_back(startRoom);
VillagePieces::StartPiece* startRoom = new VillagePieces::StartPiece(
level->getBiomeSource(), 0, random, ((unsigned)chunkX << 4) + 2,
((unsigned)chunkZ << 4) + 2, pieceSet, villageSizeModifier, level);
pieces.push_back(startRoom);
startRoom->addChildren(startRoom, &pieces, random);
std::vector<StructurePiece *> *pendingRoads = &startRoom->pendingRoads;
std::vector<StructurePiece *> *pendingHouses = &startRoom->pendingHouses;
while (!pendingRoads->empty() || !pendingHouses->empty())
{
std::vector<StructurePiece*>* pendingRoads = &startRoom->pendingRoads;
std::vector<StructurePiece*>* pendingHouses = &startRoom->pendingHouses;
while (!pendingRoads->empty() || !pendingHouses->empty()) {
// prioritize roads
if (pendingRoads->empty())
{
if (pendingRoads->empty()) {
int pos = random->nextInt((int)pendingHouses->size());
AUTO_VAR(it, pendingHouses->begin() + pos);
StructurePiece *structurePiece = *it;
pendingHouses->erase(it);
AUTO_VAR(it, pendingHouses->begin() + pos);
StructurePiece* structurePiece = *it;
pendingHouses->erase(it);
structurePiece->addChildren(startRoom, &pieces, random);
}
else
{
} else {
int pos = random->nextInt((int)pendingRoads->size());
AUTO_VAR(it, pendingRoads->begin() + pos);
StructurePiece *structurePiece = *it;
pendingRoads->erase(it);
AUTO_VAR(it, pendingRoads->begin() + pos);
StructurePiece* structurePiece = *it;
pendingRoads->erase(it);
structurePiece->addChildren(startRoom, &pieces, random);
}
}
@@ -123,23 +116,23 @@ VillageFeature::VillageStart::VillageStart(Level *level, Random *random, int chu
calculateBoundingBox();
int count = 0;
for( AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++ )
{
StructurePiece *piece = *it;
if (dynamic_cast<VillagePieces::VillageRoadPiece *>(piece) == NULL)
{
for (AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++) {
StructurePiece* piece = *it;
if (dynamic_cast<VillagePieces::VillageRoadPiece*>(piece) == NULL) {
count++;
}
}
valid = count > 2;
}
valid = count > 2;
}
bool VillageFeature::VillageStart::isValid()
{
// 4J-PB - Adding a bounds check to ensure a village isn't over the edge of our world - we end up with half houses in that case
if((boundingBox->x0<(-m_iXZSize/2)) || (boundingBox->x1>(m_iXZSize/2)) || (boundingBox->z0<(-m_iXZSize/2)) || (boundingBox->z1>(m_iXZSize/2)))
{
valid=false;
}
return valid;
bool VillageFeature::VillageStart::isValid() {
// 4J-PB - Adding a bounds check to ensure a village isn't over the edge of
// our world - we end up with half houses in that case
if ((boundingBox->x0 < (-m_iXZSize / 2)) ||
(boundingBox->x1 > (m_iXZSize / 2)) ||
(boundingBox->z0 < (-m_iXZSize / 2)) ||
(boundingBox->z1 > (m_iXZSize / 2))) {
valid = false;
}
return valid;
}