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

@@ -7,56 +7,60 @@
#include "../../Headers/net.minecraft.world.level.h"
#include "../../Level/LevelData.h"
StructureFeature::~StructureFeature()
{
for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ )
{
delete it->second;
}
StructureFeature::~StructureFeature() {
for (AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end();
it++) {
delete it->second;
}
}
void StructureFeature::addFeature(Level *level, int x, int z, int xOffs, int zOffs, byteArray blocks)
{
void StructureFeature::addFeature(Level* level, int x, int z, int xOffs,
int zOffs, byteArray blocks) {
// this method is called for each chunk within 8 chunk's distance from
// the chunk being generated, but not all chunks are the sources of
// structures
if (cachedStructures.find(ChunkPos::hashCode(x, z)) != cachedStructures.end())
{
if (cachedStructures.find(ChunkPos::hashCode(x, z)) !=
cachedStructures.end()) {
return;
}
// clear random key
random->nextInt();
// 4J-PB - want to know if it's a superflat land, so we don't generate so many villages - we've changed the distance required between villages on the xbox
if (isFeatureChunk(x, z,level->getLevelData()->getGenerator() == LevelType::lvl_flat))
{
StructureStart *start = createStructureStart(x, z);
// 4J-PB - want to know if it's a superflat land, so we don't generate so
// many villages - we've changed the distance required between villages on
// the xbox
if (isFeatureChunk(
x, z,
level->getLevelData()->getGenerator() == LevelType::lvl_flat)) {
StructureStart* start = createStructureStart(x, z);
cachedStructures[ChunkPos::hashCode(x, z)] = start;
}
}
bool StructureFeature::postProcess(Level *level, Random *random, int chunkX, int chunkZ)
{
// 4J Stu - The x and z used to be offset by (+8) here, but that means we can miss out half structures on the edge of the world
// Normal feature generation offsets generation by half a chunk to ensure that it can generate the entire feature in chunks already created
// Structure features don't need this, as the PlaceBlock function only places blocks inside the BoundingBox specified, and parts
// of a struture piece can be added in more than one post-process call
int cx = ((unsigned) chunkX << 4); // + 8;
int cz = ((unsigned)chunkZ << 4); // + 8;
bool StructureFeature::postProcess(Level* level, Random* random, int chunkX,
int chunkZ) {
// 4J Stu - The x and z used to be offset by (+8) here, but that means we
// can miss out half structures on the edge of the world Normal feature
// generation offsets generation by half a chunk to ensure that it can
// generate the entire feature in chunks already created Structure features
// don't need this, as the PlaceBlock function only places blocks inside the
// BoundingBox specified, and parts of a struture piece can be added in more
// than one post-process call
int cx = ((unsigned)chunkX << 4); // + 8;
int cz = ((unsigned)chunkZ << 4); // + 8;
bool intersection = false;
for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ )
{
StructureStart *structureStart = it->second;
for (AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end();
it++) {
StructureStart* structureStart = it->second;
if (structureStart->isValid())
{
if (structureStart->getBoundingBox()->intersects(cx, cz, cx + 15, cz + 15))
{
BoundingBox *bb = new BoundingBox(cx, cz, cx + 15, cz + 15);
if (structureStart->isValid()) {
if (structureStart->getBoundingBox()->intersects(cx, cz, cx + 15,
cz + 15)) {
BoundingBox* bb = new BoundingBox(cx, cz, cx + 15, cz + 15);
structureStart->postProcess(level, random, bb);
delete bb;
delete bb;
intersection = true;
}
}
@@ -65,21 +69,18 @@ bool StructureFeature::postProcess(Level *level, Random *random, int chunkX, int
return intersection;
}
bool StructureFeature::isIntersection(int cellX, int cellZ)
{
for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ )
{
StructureStart *structureStart = it->second;
if (structureStart->isValid())
{
if (structureStart->getBoundingBox()->intersects(cellX, cellZ, cellX, cellZ))
{
AUTO_VAR(it2, structureStart->getPieces()->begin());
while( it2 != structureStart->getPieces()->end() )
{
StructurePiece *next = *it2++;
if (next->getBoundingBox()->intersects(cellX, cellZ, cellX, cellZ))
{
bool StructureFeature::isIntersection(int cellX, int cellZ) {
for (AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end();
it++) {
StructureStart* structureStart = it->second;
if (structureStart->isValid()) {
if (structureStart->getBoundingBox()->intersects(cellX, cellZ,
cellX, cellZ)) {
AUTO_VAR(it2, structureStart->getPieces()->begin());
while (it2 != structureStart->getPieces()->end()) {
StructurePiece* next = *it2++;
if (next->getBoundingBox()->intersects(cellX, cellZ, cellX,
cellZ)) {
return true;
}
}
@@ -92,117 +93,109 @@ bool StructureFeature::isIntersection(int cellX, int cellZ)
///////////////////////////////////////////
// 4J-PB - Below functions added from 1.2.3
///////////////////////////////////////////
bool StructureFeature::isInsideFeature(int cellX, int cellY, int cellZ)
{
//for (StructureStart structureStart : cachedStructures.values())
for(AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); ++it)
{
StructureStart *pStructureStart = it->second;
bool StructureFeature::isInsideFeature(int cellX, int cellY, int cellZ) {
// for (StructureStart structureStart : cachedStructures.values())
for (AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end();
++it) {
StructureStart* pStructureStart = it->second;
if (pStructureStart->isValid())
{
if (pStructureStart->getBoundingBox()->intersects(cellX, cellZ, cellX, cellZ))
{
/*
Iterator<StructurePiece> it = structureStart.getPieces().iterator();
while (it.hasNext()) {
StructurePiece next = it.next();
if (next.getBoundingBox().isInside(cellX, cellY, cellZ)) {
return true;
}
*/
std::list<StructurePiece *> *pieces=pStructureStart->getPieces();
if (pStructureStart->isValid()) {
if (pStructureStart->getBoundingBox()->intersects(cellX, cellZ,
cellX, cellZ)) {
/*
Iterator<StructurePiece> it =
structureStart.getPieces().iterator(); while (it.hasNext()) {
StructurePiece next = it.next();
if (next.getBoundingBox().isInside(cellX, cellY, cellZ)) {
return true;
}
*/
std::list<StructurePiece*>* pieces =
pStructureStart->getPieces();
for ( AUTO_VAR(it2, pieces->begin()); it2 != pieces->end(); it2++ )
{
StructurePiece* piece = *it2;
if ( piece->getBoundingBox()->isInside(cellX, cellY, cellZ) )
{
return true;
}
}
}
}
}
return false;
for (AUTO_VAR(it2, pieces->begin()); it2 != pieces->end();
it2++) {
StructurePiece* piece = *it2;
if (piece->getBoundingBox()->isInside(cellX, cellY,
cellZ)) {
return true;
}
}
}
}
}
return false;
}
TilePos *StructureFeature::getNearestGeneratedFeature(Level *level, int cellX, int cellY, int cellZ)
{
TilePos* StructureFeature::getNearestGeneratedFeature(Level* level, int cellX,
int cellY, int cellZ) {
// this is a hack that will "force" the feature to generate positions
// even if the player hasn't generated new chunks yet
this->level = level;
// this is a hack that will "force" the feature to generate positions
// even if the player hasn't generated new chunks yet
this->level = level;
random->setSeed(level->getSeed());
__int64 xScale = random->nextLong();
__int64 zScale = random->nextLong();
__int64 xx = (cellX >> 4) * xScale;
__int64 zz = (cellZ >> 4) * zScale;
random->setSeed(xx ^ zz ^ level->getSeed());
random->setSeed(level->getSeed());
__int64 xScale = random->nextLong();
__int64 zScale = random->nextLong();
__int64 xx = (cellX >> 4) * xScale;
__int64 zz = (cellZ >> 4) * zScale;
random->setSeed(xx ^ zz ^ level->getSeed());
addFeature(level, cellX >> 4, cellZ >> 4, 0, 0, byteArray());
addFeature(level, cellX >> 4, cellZ >> 4, 0, 0, byteArray());
double minDistance = DBL_MAX;
TilePos* selected = NULL;
double minDistance = DBL_MAX;
TilePos *selected = NULL;
for (AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end();
++it) {
StructureStart* pStructureStart = it->second;
for(AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); ++it)
{
StructureStart *pStructureStart = it->second;
if (pStructureStart->isValid()) {
// StructurePiece *pStructurePiece =
// pStructureStart->getPieces().get(0);
StructurePiece* pStructurePiece =
*pStructureStart->getPieces()->begin();
TilePos* locatorPosition = pStructurePiece->getLocatorPosition();
if (pStructureStart->isValid())
{
int dx = locatorPosition->x - cellX;
int dy = locatorPosition->y - cellY;
int dz = locatorPosition->z - cellZ;
double dist = dx + dx * dy * dy + dz * dz;
//StructurePiece *pStructurePiece = pStructureStart->getPieces().get(0);
StructurePiece* pStructurePiece = * pStructureStart->getPieces()->begin();
TilePos *locatorPosition = pStructurePiece->getLocatorPosition();
if (dist < minDistance) {
minDistance = dist;
selected = locatorPosition;
}
}
}
if (selected != NULL) {
return selected;
} else {
std::vector<TilePos>* guesstimatedFeaturePositions =
getGuesstimatedFeaturePositions();
if (guesstimatedFeaturePositions != NULL) {
TilePos* pSelectedPos = new TilePos(0, 0, 0);
int dx = locatorPosition->x - cellX;
int dy = locatorPosition->y - cellY;
int dz = locatorPosition->z - cellZ;
double dist = dx + dx * dy * dy + dz * dz;
for (AUTO_VAR(it, guesstimatedFeaturePositions->begin());
it != guesstimatedFeaturePositions->end(); ++it) {
int dx = (*it).x - cellX;
int dy = (*it).y - cellY;
int dz = (*it).z - cellZ;
double dist = dx + dx * dy * dy + dz * dz;
if (dist < minDistance)
{
minDistance = dist;
selected = locatorPosition;
}
}
}
if (selected != NULL)
{
return selected;
}
else
{
std::vector<TilePos> *guesstimatedFeaturePositions = getGuesstimatedFeaturePositions();
if (guesstimatedFeaturePositions != NULL)
{
TilePos *pSelectedPos = new TilePos(0,0,0);
for(AUTO_VAR(it, guesstimatedFeaturePositions->begin()); it != guesstimatedFeaturePositions->end(); ++it)
{
int dx = (*it).x - cellX;
int dy = (*it).y - cellY;
int dz = (*it).z - cellZ;
double dist = dx + dx * dy * dy + dz * dz;
if (dist < minDistance)
{
minDistance = dist;
pSelectedPos->x = (*it).x;
pSelectedPos->y = (*it).y;
pSelectedPos->z = (*it).z;
}
}
delete guesstimatedFeaturePositions;
return pSelectedPos;
}
}
return NULL;
if (dist < minDistance) {
minDistance = dist;
pSelectedPos->x = (*it).x;
pSelectedPos->y = (*it).y;
pSelectedPos->z = (*it).z;
}
}
delete guesstimatedFeaturePositions;
return pSelectedPos;
}
}
return NULL;
}
std::vector<TilePos> *StructureFeature::getGuesstimatedFeaturePositions()
{
return NULL;
std::vector<TilePos>* StructureFeature::getGuesstimatedFeaturePositions() {
return NULL;
}