From b3feddfef372618c8a9d7a0abcaf18cfad866c18 Mon Sep 17 00:00:00 2001 From: daoge <3523206925@qq.com> Date: Tue, 3 Mar 2026 03:04:10 +0800 Subject: feat: TU19 (Dec 2014) Features & Content (#155) * try to resolve merge conflict * feat: TU19 (Dec 2014) Features & Content (#32) * December 2014 files * Working release build * Fix compilation issues * Add sound to Windows64Media * Add DLC content and force Tutorial DLC * Revert "Add DLC content and force Tutorial DLC" This reverts commit 97a43994725008e35fceb984d5549df9c8cea470. * Disable broken light packing * Disable breakpoint during DLC texture map load Allows DLC loading but the DLC textures are still broken * Fix post build not working * ... * fix vs2022 build * fix cmake build --------- Co-authored-by: Loki --- Minecraft.World/StructureStart.cpp | 121 +++++++++++++++++++++++++++++-------- 1 file changed, 95 insertions(+), 26 deletions(-) (limited to 'Minecraft.World/StructureStart.cpp') diff --git a/Minecraft.World/StructureStart.cpp b/Minecraft.World/StructureStart.cpp index 22a4312c..9e5ba0a8 100644 --- a/Minecraft.World/StructureStart.cpp +++ b/Minecraft.World/StructureStart.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "net.minecraft.world.level.h" +#include "net.minecraft.world.level.levelgen.structure.h" #include "StructureStart.h" #include "StructurePiece.h" #include "BoundingBox.h" @@ -7,9 +8,17 @@ StructureStart::StructureStart() { + chunkX = chunkZ = 0; boundingBox = NULL; // 4J added initialiser } +StructureStart::StructureStart(int x, int z) +{ + this->chunkX = x; + this->chunkZ = z; + boundingBox = NULL; +} + StructureStart::~StructureStart() { for(AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++ ) @@ -37,8 +46,8 @@ void StructureStart::postProcess(Level *level, Random *random, BoundingBox *chun { if( (*it)->getBoundingBox()->intersects(chunkBB) && !(*it)->postProcess(level, random, chunkBB)) { - // this piece can't be placed, so remove it to avoid future - // attempts + // this piece can't be placed, so remove it to avoid future + // attempts it = pieces.erase(it); } else @@ -50,7 +59,7 @@ void StructureStart::postProcess(Level *level, Random *random, BoundingBox *chun void StructureStart::calculateBoundingBox() { - boundingBox = BoundingBox::getUnknownBox(); + boundingBox = BoundingBox::getUnknownBox(); for( AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++ ) { @@ -59,53 +68,113 @@ void StructureStart::calculateBoundingBox() } } +CompoundTag *StructureStart::createTag(int chunkX, int chunkZ) +{ + CompoundTag *tag = new CompoundTag(); + + 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")); + + ListTag *childrenTags = new ListTag(L"Children"); + for(AUTO_VAR(it, pieces.begin()); it != pieces.end(); ++it) + { + StructurePiece *piece = *it; + 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")); + } + + ListTag *children = (ListTag *) 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(CompoundTag *tag) +{ + +} + void StructureStart::moveBelowSeaLevel(Level *level, Random *random, int offset) { const int MAX_Y = level->seaLevel - offset; - // set lowest possible position (at bedrock) - int y1Pos = boundingBox->getYSpan() + 1; - // move up randomly within the available span - if (y1Pos < MAX_Y) + // set lowest possible position (at bedrock) + int y1Pos = boundingBox->getYSpan() + 1; + // move up randomly within the available span + if (y1Pos < MAX_Y) { - y1Pos += random->nextInt(MAX_Y - y1Pos); - } + y1Pos += random->nextInt(MAX_Y - y1Pos); + } - // move all bounding boxes - int dy = y1Pos - boundingBox->y1; - boundingBox->move(0, dy, 0); + // move all bounding boxes + int dy = y1Pos - boundingBox->y1; + boundingBox->move(0, dy, 0); for( AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++ ) { StructurePiece *piece = *it; - piece->getBoundingBox()->move(0, dy, 0); - } + piece->getBoundingBox()->move(0, dy, 0); + } } void StructureStart::moveInsideHeights(Level *level, Random *random, int lowestAllowed, int highestAllowed) { - int heightSpan = highestAllowed - lowestAllowed + 1 - boundingBox->getYSpan(); - int y0Pos = 1; + int heightSpan = highestAllowed - lowestAllowed + 1 - boundingBox->getYSpan(); + int y0Pos = 1; - if (heightSpan > 1) + if (heightSpan > 1) { - y0Pos = lowestAllowed + random->nextInt(heightSpan); - } + y0Pos = lowestAllowed + random->nextInt(heightSpan); + } else { - y0Pos = lowestAllowed; - } + y0Pos = lowestAllowed; + } - // move all bounding boxes - int dy = y0Pos - boundingBox->y0; - boundingBox->move(0, dy, 0); + // move all bounding boxes + int dy = y0Pos - boundingBox->y0; + boundingBox->move(0, dy, 0); for( AUTO_VAR(it, pieces.begin()); it != pieces.end(); it++ ) { StructurePiece *piece = *it; - piece->getBoundingBox()->move(0, dy, 0); - } + piece->getBoundingBox()->move(0, dy, 0); + } } bool StructureStart::isValid() { return true; +} + +int StructureStart::getChunkX() +{ + return chunkX; +} + +int StructureStart::getChunkZ() +{ + return chunkZ; } \ No newline at end of file -- cgit v1.2.3