mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-05-28 05:34:34 +00:00
TU24
This commit is contained in:
@@ -10,7 +10,6 @@ StructureStart::StructureStart()
|
||||
{
|
||||
chunkX = chunkZ = 0;
|
||||
boundingBox = nullptr; // 4J added initialiser
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
StructureStart::StructureStart(int x, int z)
|
||||
@@ -45,8 +44,7 @@ void StructureStart::postProcess(Level *level, Random *random, BoundingBox *chun
|
||||
|
||||
while( it != pieces.end() )
|
||||
{
|
||||
StructurePiece *piece = *it;
|
||||
if( piece->getBoundingBox()->intersects(chunkBB) && !piece->postProcess(level, random, chunkBB) )
|
||||
if( (*it)->getBoundingBox()->intersects(chunkBB) && !(*it)->postProcess(level, random, chunkBB))
|
||||
{
|
||||
// this piece can't be placed, so remove it to avoid future
|
||||
// attempts
|
||||
@@ -54,11 +52,6 @@ void StructureStart::postProcess(Level *level, Random *random, BoundingBox *chun
|
||||
}
|
||||
else
|
||||
{
|
||||
if( piece->isDirty() )
|
||||
{
|
||||
dirty = true;
|
||||
piece->clearDirty();
|
||||
}
|
||||
it++;
|
||||
}
|
||||
}
|
||||
@@ -74,51 +67,51 @@ void StructureStart::calculateBoundingBox()
|
||||
}
|
||||
}
|
||||
|
||||
byteArray StructureStart::createTag(int chunkX, int chunkZ)
|
||||
CompoundTag *StructureStart::createTag(int chunkX, int chunkZ)
|
||||
{
|
||||
ByteArrayOutputStream baos;
|
||||
DataOutputStream dos(&baos);
|
||||
CompoundTag *tag = new CompoundTag();
|
||||
|
||||
dos.writeInt(1); // version
|
||||
dos.writeUTF(StructureFeatureIO::getEncodeId(this));
|
||||
dos.writeInt(chunkX);
|
||||
dos.writeInt(chunkZ);
|
||||
boundingBox->write(&dos);
|
||||
tag->putString(L"id", StructureFeatureIO::getEncodeId(this));
|
||||
tag->putInt(L"ChunkX", chunkX);
|
||||
tag->putInt(L"ChunkZ", chunkZ);
|
||||
tag->put(L"BB", boundingBox->createTag(L"BB"));
|
||||
|
||||
for (auto it = pieces.begin(); it != pieces.end(); ++it)
|
||||
{
|
||||
StructurePiece *piece = *it;
|
||||
piece->write(&dos);
|
||||
}
|
||||
|
||||
addAdditionalSaveData(&dos);
|
||||
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
void StructureStart::addAdditionalSaveData(DataOutputStream *dos)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void StructureStart::load(Level *level, DataInputStream *dis)
|
||||
{
|
||||
chunkX = dis->readInt();
|
||||
chunkZ = dis->readInt();
|
||||
|
||||
boundingBox = new BoundingBox();
|
||||
boundingBox->read(dis);
|
||||
|
||||
int count = dis->readInt();
|
||||
for (int i = 0; i < count; i++)
|
||||
ListTag<CompoundTag> *childrenTags = new ListTag<CompoundTag>(L"Children");
|
||||
for(auto& piece : pieces)
|
||||
{
|
||||
pieces.push_back(StructureFeatureIO::loadStaticPiece(dis, level));
|
||||
childrenTags->add(piece->createTag());
|
||||
}
|
||||
tag->put(L"Children", childrenTags);
|
||||
|
||||
addAdditonalSaveData(tag);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
void StructureStart::addAdditonalSaveData(CompoundTag *tag)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void StructureStart::load(Level *level, CompoundTag *tag)
|
||||
{
|
||||
chunkX = tag->getInt(L"ChunkX");
|
||||
chunkZ = tag->getInt(L"ChunkZ");
|
||||
if (tag->contains(L"BB"))
|
||||
{
|
||||
boundingBox = new BoundingBox(tag->getIntArray(L"BB"));
|
||||
}
|
||||
|
||||
readAdditonalSaveData(dis);
|
||||
ListTag<CompoundTag> *children = (ListTag<CompoundTag> *) tag->getList(L"Children");
|
||||
for (int i = 0; i < children->size(); i++)
|
||||
{
|
||||
pieces.push_back(StructureFeatureIO::loadStaticPiece(children->get(i), level));
|
||||
}
|
||||
|
||||
readAdditonalSaveData(tag);
|
||||
}
|
||||
|
||||
void StructureStart::readAdditonalSaveData(DataInputStream *dis)
|
||||
void StructureStart::readAdditonalSaveData(CompoundTag *tag)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -180,14 +173,4 @@ int StructureStart::getChunkX()
|
||||
int StructureStart::getChunkZ()
|
||||
{
|
||||
return chunkZ;
|
||||
}
|
||||
|
||||
void StructureStart::clearDirty()
|
||||
{
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
bool StructureStart::isDirty()
|
||||
{
|
||||
return dirty;
|
||||
}
|
||||
Reference in New Issue
Block a user