diff options
| author | daoge <3523206925@qq.com> | 2026-03-03 03:04:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-03 03:04:10 +0800 |
| commit | b3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch) | |
| tree | 267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/VillagePieces.cpp | |
| parent | 84c31a2331f7a0ec85b9d438992e244f60e5020f (diff) | |
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 <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.World/VillagePieces.cpp')
| -rw-r--r-- | Minecraft.World/VillagePieces.cpp | 395 |
1 files changed, 288 insertions, 107 deletions
diff --git a/Minecraft.World/VillagePieces.cpp b/Minecraft.World/VillagePieces.cpp index 27b21aa5..0a08d4fb 100644 --- a/Minecraft.World/VillagePieces.cpp +++ b/Minecraft.World/VillagePieces.cpp @@ -4,6 +4,7 @@ #include "net.minecraft.world.level.storage.h" #include "net.minecraft.world.level.tile.h" #include "net.minecraft.world.level.levelgen.h" +#include "net.minecraft.world.level.levelgen.structure.h" #include "net.minecraft.world.item.h" #include "net.minecraft.world.level.dimension.h" #include "net.minecraft.world.entity.npc.h" @@ -16,6 +17,23 @@ WeighedTreasureArray VillagePieces::Smithy::treasureItems; +void VillagePieces::loadStatic() +{ + StructureFeatureIO::setPieceId(eStructurePiece_BookHouse, BookHouse::Create, L"ViBH"); + StructureFeatureIO::setPieceId(eStructurePiece_DoubleFarmland, DoubleFarmland::Create, L"ViDF"); + StructureFeatureIO::setPieceId(eStructurePiece_Farmland, Farmland::Create, L"ViF"); + StructureFeatureIO::setPieceId(eStructurePiece_LightPost, LightPost::Create, L"ViL"); + StructureFeatureIO::setPieceId(eStructurePiece_PigHouse, PigHouse::Create, L"ViPH"); + StructureFeatureIO::setPieceId(eStructurePiece_SimpleHouse, SimpleHouse::Create, L"ViSH"); + StructureFeatureIO::setPieceId(eStructurePiece_SmallHut, SmallHut::Create, L"ViSmH"); + StructureFeatureIO::setPieceId(eStructurePiece_SmallTemple, SmallTemple::Create, L"ViST"); + StructureFeatureIO::setPieceId(eStructurePiece_Smithy, Smithy::Create, L"ViS"); + StructureFeatureIO::setPieceId(eStructurePiece_VillageStartPiece, StartPiece::Create, L"ViStart"); + StructureFeatureIO::setPieceId(eStructurePiece_StraightRoad, StraightRoad::Create, L"ViSR"); + StructureFeatureIO::setPieceId(eStructurePiece_TwoRoomHouse, TwoRoomHouse::Create, L"ViTRH"); + StructureFeatureIO::setPieceId(eStructurePiece_Well, Well::Create, L"ViW"); +} + VillagePieces::PieceWeight::PieceWeight(VillagePieces::EPieceClass pieceClass, int weight, int maxPlaceCount) : weight(weight) { this->placeCount = 0; // 4J added initialiser @@ -248,10 +266,39 @@ StructurePiece *VillagePieces::generateAndAddRoadPiece(StartPiece *startPiece, l return NULL; } +VillagePieces::VillagePiece::VillagePiece() +{ + heightPosition = -1; + spawnedVillagerCount = 0; + isDesertVillage = false; + startPiece = NULL; + // for reflection +} + VillagePieces::VillagePiece::VillagePiece(StartPiece *startPiece, int genDepth) : StructurePiece(genDepth) { + heightPosition = -1; + isDesertVillage = false; spawnedVillagerCount = 0; this->startPiece = startPiece; + if (startPiece != NULL) + { + this->isDesertVillage = startPiece->isDesertVillage; + } +} + +void VillagePieces::VillagePiece::addAdditonalSaveData(CompoundTag *tag) +{ + tag->putInt(L"HPos", heightPosition); + tag->putInt(L"VCount", spawnedVillagerCount); + tag->putBoolean(L"Desert", isDesertVillage); +} + +void VillagePieces::VillagePiece::readAdditonalSaveData(CompoundTag *tag) +{ + heightPosition = tag->getInt(L"HPos"); + spawnedVillagerCount = tag->getInt(L"VCount"); + isDesertVillage = tag->getBoolean(L"Desert"); } StructurePiece *VillagePieces::VillagePiece::generateHouseNorthernLeft(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int yOff, int zOff) @@ -366,13 +413,13 @@ int VillagePieces::VillagePiece::getVillagerProfession(int villagerNumber) int VillagePieces::VillagePiece::biomeBlock(int tile, int data) { - if (startPiece->isDesertVillage) + if (isDesertVillage) { if (tile == Tile::treeTrunk_Id) { return Tile::sandStone_Id; } - else if (tile == Tile::stoneBrick_Id) + else if (tile == Tile::cobblestone_Id) { return Tile::sandStone_Id; } @@ -398,13 +445,13 @@ int VillagePieces::VillagePiece::biomeBlock(int tile, int data) int VillagePieces::VillagePiece::biomeData(int tile, int data) { - if (startPiece->isDesertVillage) + if (isDesertVillage) { if (tile == Tile::treeTrunk_Id) { return 0; } - else if (tile == Tile::stoneBrick_Id) + else if (tile == Tile::cobblestone_Id) { return SandStoneTile::TYPE_DEFAULT; } @@ -439,9 +486,13 @@ void VillagePieces::VillagePiece::fillColumnDown(Level *level, int block, int da StructurePiece::fillColumnDown(level, bblock, bdata, x, startY, z, chunkBB); } -VillagePieces::Well::Well(StartPiece *startPiece, int genDepth, Random *random, int west, int north) : VillagePiece(startPiece, genDepth), isSource(true) +VillagePieces::Well::Well() +{ + // for reflection +} + +VillagePieces::Well::Well(StartPiece *startPiece, int genDepth, Random *random, int west, int north) : VillagePiece(startPiece, genDepth) { - heightPosition = -1; // 4J added initialiser orientation = random->nextInt(4); switch (orientation) @@ -456,10 +507,8 @@ VillagePieces::Well::Well(StartPiece *startPiece, int genDepth, Random *random, } } -VillagePieces::Well::Well(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction) : VillagePiece(startPiece, genDepth), isSource(false) +VillagePieces::Well::Well(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction) : VillagePiece(startPiece, genDepth) { - heightPosition = -1; // 4J added initialiser - orientation = direction; boundingBox = stairsBox; } @@ -472,19 +521,6 @@ void VillagePieces::Well::addChildren(StructurePiece *startPiece, list<Structure generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 + 1, boundingBox->y1 - 4, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); } -//VillagePieces::Well *VillagePieces::Well::createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) -//{ -// BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 4 - height, 0, width, height, depth, direction); -// -// if (!isOkBox(box) || StructurePiece::findCollisionPiece(pieces, box) != NULL) -// { -// delete box; -// return NULL; -// } -// -// return new Well(genDepth, random, box, direction); -//} - bool VillagePieces::Well::postProcess(Level *level, Random *random, BoundingBox *chunkBB) { if (heightPosition < 0) @@ -497,7 +533,7 @@ bool VillagePieces::Well::postProcess(Level *level, Random *random, BoundingBox boundingBox->move(0, heightPosition - boundingBox->y1 + 3, 0); } - generateBox(level, chunkBB, 1, 0, 1, 4, height - 3, 4, Tile::stoneBrick_Id, Tile::water_Id, false); + generateBox(level, chunkBB, 1, 0, 1, 4, height - 3, 4, Tile::cobblestone_Id, Tile::water_Id, false); placeBlock(level, 0, 0, 2, height - 3, 2, chunkBB); placeBlock(level, 0, 0, 3, height - 3, 2, chunkBB); placeBlock(level, 0, 0, 2, height - 3, 3, chunkBB); @@ -511,7 +547,7 @@ bool VillagePieces::Well::postProcess(Level *level, Random *random, BoundingBox placeBlock(level, Tile::fence_Id, 0, 1, height - 1, 4, chunkBB); placeBlock(level, Tile::fence_Id, 0, 4, height - 2, 4, chunkBB); placeBlock(level, Tile::fence_Id, 0, 4, height - 1, 4, chunkBB); - generateBox(level, chunkBB, 1, height, 1, 4, height, 4, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 1, height, 1, 4, height, 4, Tile::cobblestone_Id, Tile::cobblestone_Id, false); for (int z = 0; z <= 5; z++) { @@ -531,6 +567,11 @@ bool VillagePieces::Well::postProcess(Level *level, Random *random, BoundingBox } +VillagePieces::StartPiece::StartPiece() +{ + // for reflection +} + VillagePieces::StartPiece::StartPiece(BiomeSource *biomeSource, int genDepth, Random *random, int west, int north, list<PieceWeight *> *pieceSet, int villageSize, Level *level) : Well(NULL, 0, random, west, north) { isLibraryAdded = false; // 4J - added initialiser @@ -541,8 +582,7 @@ VillagePieces::StartPiece::StartPiece(BiomeSource *biomeSource, int genDepth, Ra m_level = level; Biome *biome = biomeSource->getBiome(west, north); - this->isDesertVillage = biome == Biome::desert || biome == Biome::desertHills; - this->startPiece = this; + isDesertVillage = biome == Biome::desert || biome == Biome::desertHills; } VillagePieces::StartPiece::~StartPiece() @@ -559,6 +599,11 @@ BiomeSource *VillagePieces::StartPiece::getBiomeSource() return biomeSource; } +VillagePieces::StraightRoad::StraightRoad() +{ + // for reflection +} + VillagePieces::StraightRoad::StraightRoad(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction) : VillageRoadPiece(startPiece, genDepth) { orientation = direction; @@ -566,6 +611,18 @@ VillagePieces::StraightRoad::StraightRoad(StartPiece *startPiece, int genDepth, length = Math::_max(stairsBox->getXSpan(), stairsBox->getZSpan()); } +void VillagePieces::StraightRoad::addAdditonalSaveData(CompoundTag *tag) +{ + VillageRoadPiece::addAdditonalSaveData(tag); + tag->putInt(L"Length", length); +} + +void VillagePieces::StraightRoad::readAdditonalSaveData(CompoundTag *tag) +{ + VillageRoadPiece::readAdditonalSaveData(tag); + length = tag->getInt(L"Length"); +} + void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random) { bool hasHouses = false; @@ -663,7 +720,7 @@ bool VillagePieces::StraightRoad::postProcess(Level *level, Random *random, Boun if (chunkBB->isInside(x, 64, z)) { int y = level->getTopSolidBlock(x, z) - 1; - level->setTileNoUpdate(x, y, z,tile); + level->setTileAndData(x, y, z,tile, 0, Tile::UPDATE_CLIENTS); } } } @@ -671,17 +728,30 @@ bool VillagePieces::StraightRoad::postProcess(Level *level, Random *random, Boun return true; } -/* -int heightPosition; -const bool hasTerrace;*/ +VillagePieces::SimpleHouse::SimpleHouse() +{ + hasTerrace = false; + // for reflection +} VillagePieces::SimpleHouse::SimpleHouse(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction) : VillagePiece(startPiece, genDepth), hasTerrace(random->nextBoolean()) { - heightPosition = -1; // 4J added initialiser orientation = direction; boundingBox = stairsBox; } +void VillagePieces::SimpleHouse::addAdditonalSaveData(CompoundTag *tag) +{ + VillagePiece::addAdditonalSaveData(tag); + tag->putBoolean(L"Terrace", hasTerrace); +} + +void VillagePieces::SimpleHouse::readAdditonalSaveData(CompoundTag *tag) +{ + VillagePiece::readAdditonalSaveData(tag); + hasTerrace = tag->getBoolean(L"Terrace"); +} + VillagePieces::SimpleHouse *VillagePieces::SimpleHouse::createPiece(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); @@ -708,24 +778,24 @@ bool VillagePieces::SimpleHouse::postProcess(Level *level, Random *random, Bound } // floor - generateBox(level, chunkBB, 0, 0, 0, 4, 0, 4, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 0, 0, 0, 4, 0, 4, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // roof generateBox(level, chunkBB, 0, 4, 0, 4, 4, 4, Tile::treeTrunk_Id, Tile::treeTrunk_Id, false); generateBox(level, chunkBB, 1, 4, 1, 3, 4, 3, Tile::wood_Id, Tile::wood_Id, false); // window walls - placeBlock(level, Tile::stoneBrick_Id, 0, 0, 1, 0, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 0, 2, 0, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 0, 3, 0, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 4, 1, 0, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 4, 2, 0, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 4, 3, 0, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 0, 1, 4, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 0, 2, 4, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 0, 3, 4, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 4, 1, 4, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 4, 2, 4, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 4, 3, 4, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 0, 1, 0, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 0, 2, 0, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 0, 3, 0, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 4, 1, 0, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 4, 2, 0, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 4, 3, 0, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 0, 1, 4, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 0, 2, 4, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 0, 3, 4, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 4, 1, 4, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 4, 2, 4, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 4, 3, 4, chunkBB); generateBox(level, chunkBB, 0, 1, 1, 0, 3, 3, Tile::wood_Id, Tile::wood_Id, false); generateBox(level, chunkBB, 4, 1, 1, 4, 3, 3, Tile::wood_Id, Tile::wood_Id, false); generateBox(level, chunkBB, 1, 1, 4, 3, 3, 4, Tile::wood_Id, Tile::wood_Id, false); @@ -787,7 +857,7 @@ bool VillagePieces::SimpleHouse::postProcess(Level *level, Random *random, Bound for (int x = 0; x < width; x++) { generateAirColumnUp(level, x, height, z, chunkBB); - fillColumnDown(level, Tile::stoneBrick_Id, 0, x, -1, z, chunkBB); + fillColumnDown(level, Tile::cobblestone_Id, 0, x, -1, z, chunkBB); } } @@ -797,6 +867,11 @@ bool VillagePieces::SimpleHouse::postProcess(Level *level, Random *random, Bound } +VillagePieces::SmallTemple::SmallTemple() +{ + // for reflection +} + VillagePieces::SmallTemple::SmallTemple(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction) : VillagePiece(startPiece, genDepth) { heightPosition = -1; // 4J added initialiser @@ -834,40 +909,40 @@ bool VillagePieces::SmallTemple::postProcess(Level *level, Random *random, Bound generateBox(level, chunkBB, 1, 5, 1, 3, 9, 3, 0, 0, false); // floor - generateBox(level, chunkBB, 1, 0, 0, 3, 0, 8, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 1, 0, 0, 3, 0, 8, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // front wall - generateBox(level, chunkBB, 1, 1, 0, 3, 10, 0, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 1, 1, 0, 3, 10, 0, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // left tall wall - generateBox(level, chunkBB, 0, 1, 1, 0, 10, 3, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 0, 1, 1, 0, 10, 3, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // right tall wall - generateBox(level, chunkBB, 4, 1, 1, 4, 10, 3, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 4, 1, 1, 4, 10, 3, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // left low wall - generateBox(level, chunkBB, 0, 0, 4, 0, 4, 7, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 0, 0, 4, 0, 4, 7, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // right low wall - generateBox(level, chunkBB, 4, 0, 4, 4, 4, 7, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 4, 0, 4, 4, 4, 7, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // far low wall - generateBox(level, chunkBB, 1, 1, 8, 3, 4, 8, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 1, 1, 8, 3, 4, 8, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // far upper wall - generateBox(level, chunkBB, 1, 5, 4, 3, 10, 4, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 1, 5, 4, 3, 10, 4, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // low roof - generateBox(level, chunkBB, 1, 5, 5, 3, 5, 7, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 1, 5, 5, 3, 5, 7, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // high roof - generateBox(level, chunkBB, 0, 9, 0, 4, 9, 4, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 0, 9, 0, 4, 9, 4, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // middle floor / roof - generateBox(level, chunkBB, 0, 4, 0, 4, 4, 4, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - placeBlock(level, Tile::stoneBrick_Id, 0, 0, 11, 2, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 4, 11, 2, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 2, 11, 0, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 2, 11, 4, chunkBB); + generateBox(level, chunkBB, 0, 4, 0, 4, 4, 4, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + placeBlock(level, Tile::cobblestone_Id, 0, 0, 11, 2, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 4, 11, 2, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 2, 11, 0, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 2, 11, 4, chunkBB); // altar pieces - placeBlock(level, Tile::stoneBrick_Id, 0, 1, 1, 6, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 1, 1, 7, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 2, 1, 7, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 3, 1, 6, chunkBB); - placeBlock(level, Tile::stoneBrick_Id, 0, 3, 1, 7, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 1, 1, 6, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 1, 1, 7, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 2, 1, 7, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 3, 1, 6, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 3, 1, 7, chunkBB); placeBlock(level, Tile::stairs_stone_Id, getOrientationData(Tile::stairs_stone_Id, 3), 1, 1, 5, chunkBB); placeBlock(level, Tile::stairs_stone_Id, getOrientationData(Tile::stairs_stone_Id, 3), 2, 1, 6, chunkBB); placeBlock(level, Tile::stairs_stone_Id, getOrientationData(Tile::stairs_stone_Id, 3), 3, 1, 5, chunkBB); @@ -919,7 +994,7 @@ bool VillagePieces::SmallTemple::postProcess(Level *level, Random *random, Bound for (int x = 0; x < width; x++) { generateAirColumnUp(level, x, height, z, chunkBB); - fillColumnDown(level, Tile::stoneBrick_Id, 0, x, -1, z, chunkBB); + fillColumnDown(level, Tile::cobblestone_Id, 0, x, -1, z, chunkBB); } } @@ -934,6 +1009,10 @@ int VillagePieces::SmallTemple::getVillagerProfession(int villagerNumber) return Villager::PROFESSION_PRIEST; } +VillagePieces::BookHouse::BookHouse() +{ + // for reflection +} VillagePieces::BookHouse::BookHouse(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction) : VillagePiece(startPiece, genDepth) { @@ -971,11 +1050,11 @@ bool VillagePieces::BookHouse::postProcess(Level *level, Random *random, Boundin generateBox(level, chunkBB, 1, 1, 1, 7, 5, 4, 0, 0, false); // floor - generateBox(level, chunkBB, 0, 0, 0, 8, 0, 5, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 0, 0, 0, 8, 0, 5, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // roof - generateBox(level, chunkBB, 0, 5, 0, 8, 5, 5, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 0, 6, 1, 8, 6, 4, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 0, 7, 2, 8, 7, 3, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 0, 5, 0, 8, 5, 5, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 0, 6, 1, 8, 6, 4, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 0, 7, 2, 8, 7, 3, Tile::cobblestone_Id, Tile::cobblestone_Id, false); int southStairs = getOrientationData(Tile::stairs_wood_Id, 3); int northStairs = getOrientationData(Tile::stairs_wood_Id, 2); for (int d = -1; d <= 2; d++) { @@ -986,14 +1065,14 @@ bool VillagePieces::BookHouse::postProcess(Level *level, Random *random, Boundin } // rock supports - generateBox(level, chunkBB, 0, 1, 0, 0, 1, 5, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 1, 1, 5, 8, 1, 5, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 8, 1, 0, 8, 1, 4, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 2, 1, 0, 7, 1, 0, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 0, 2, 0, 0, 4, 0, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 0, 2, 5, 0, 4, 5, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 8, 2, 5, 8, 4, 5, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 8, 2, 0, 8, 4, 0, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 0, 1, 0, 0, 1, 5, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 1, 1, 5, 8, 1, 5, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 8, 1, 0, 8, 1, 4, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 2, 1, 0, 7, 1, 0, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 0, 2, 0, 0, 4, 0, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 0, 2, 5, 0, 4, 5, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 8, 2, 5, 8, 4, 5, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 8, 2, 0, 8, 4, 0, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // wooden walls generateBox(level, chunkBB, 0, 2, 1, 0, 4, 4, Tile::wood_Id, Tile::wood_Id, false); @@ -1056,7 +1135,7 @@ bool VillagePieces::BookHouse::postProcess(Level *level, Random *random, Boundin for (int x = 0; x < width; x++) { generateAirColumnUp(level, x, height, z, chunkBB); - fillColumnDown(level, Tile::stoneBrick_Id, 0, x, -1, z, chunkBB); + fillColumnDown(level, Tile::cobblestone_Id, 0, x, -1, z, chunkBB); } } @@ -1071,6 +1150,11 @@ int VillagePieces::BookHouse::getVillagerProfession(int villagerNumber) return Villager::PROFESSION_LIBRARIAN; } +VillagePieces::SmallHut::SmallHut() +{ + // for reflection +} + VillagePieces::SmallHut::SmallHut(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction) : VillagePiece(startPiece, genDepth), lowCeiling(random->nextBoolean()), tablePlacement(random->nextInt(3)) { heightPosition = -1; // 4J added initialiser @@ -1079,6 +1163,20 @@ VillagePieces::SmallHut::SmallHut(StartPiece *startPiece, int genDepth, Random * boundingBox = stairsBox; } +void VillagePieces::SmallHut::addAdditonalSaveData(CompoundTag *tag) +{ + VillagePiece::addAdditonalSaveData(tag); + tag->putInt(L"T", tablePlacement); + tag->putBoolean(L"C", lowCeiling); +} + +void VillagePieces::SmallHut::readAdditonalSaveData(CompoundTag *tag) +{ + VillagePiece::readAdditonalSaveData(tag); + tablePlacement = tag->getInt(L"T"); + lowCeiling = tag->getBoolean(L"C"); +} + VillagePieces::SmallHut *VillagePieces::SmallHut::createPiece(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); @@ -1108,7 +1206,7 @@ bool VillagePieces::SmallHut::postProcess(Level *level, Random *random, Bounding generateBox(level, chunkBB, 1, 1, 1, 3, 5, 4, 0, 0, false); // floor - generateBox(level, chunkBB, 0, 0, 0, 3, 0, 4, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 0, 0, 0, 3, 0, 4, Tile::cobblestone_Id, Tile::cobblestone_Id, false); generateBox(level, chunkBB, 1, 0, 1, 2, 0, 3, Tile::dirt_Id, Tile::dirt_Id, false); // roof if (lowCeiling) { @@ -1163,7 +1261,7 @@ bool VillagePieces::SmallHut::postProcess(Level *level, Random *random, Bounding for (int x = 0; x < width; x++) { generateAirColumnUp(level, x, height, z, chunkBB); - fillColumnDown(level, Tile::stoneBrick_Id, 0, x, -1, z, chunkBB); + fillColumnDown(level, Tile::cobblestone_Id, 0, x, -1, z, chunkBB); } } @@ -1173,9 +1271,13 @@ bool VillagePieces::SmallHut::postProcess(Level *level, Random *random, Bounding } +VillagePieces::PigHouse::PigHouse() +{ + // for reflection +} + VillagePieces::PigHouse::PigHouse(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction) : VillagePiece(startPiece, genDepth) { - heightPosition = -1; // 4J added initialiser orientation = direction; boundingBox = stairsBox; } @@ -1212,7 +1314,7 @@ bool VillagePieces::PigHouse::postProcess(Level *level, Random *random, Bounding // pig floor generateBox(level, chunkBB, 2, 0, 6, 8, 0, 10, Tile::dirt_Id, Tile::dirt_Id, false); - placeBlock(level, Tile::stoneBrick_Id, 0, 6, 0, 6, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 6, 0, 6, chunkBB); // pig fence generateBox(level, chunkBB, 2, 1, 6, 2, 1, 10, Tile::fence_Id, Tile::fence_Id, false); generateBox(level, chunkBB, 8, 1, 6, 8, 1, 10, Tile::fence_Id, Tile::fence_Id, false); @@ -1220,10 +1322,10 @@ bool VillagePieces::PigHouse::postProcess(Level *level, Random *random, Bounding // floor generateBox(level, chunkBB, 1, 0, 1, 7, 0, 4, Tile::wood_Id, Tile::wood_Id, false); - generateBox(level, chunkBB, 0, 0, 0, 0, 3, 5, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 8, 0, 0, 8, 3, 5, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 1, 0, 0, 7, 1, 0, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 1, 0, 5, 7, 1, 5, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 0, 0, 0, 0, 3, 5, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 8, 0, 0, 8, 3, 5, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 1, 0, 0, 7, 1, 0, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 1, 0, 5, 7, 1, 5, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // roof generateBox(level, chunkBB, 1, 2, 0, 7, 3, 0, Tile::wood_Id, Tile::wood_Id, false); @@ -1294,7 +1396,7 @@ bool VillagePieces::PigHouse::postProcess(Level *level, Random *random, Bounding for (int x = 0; x < width; x++) { generateAirColumnUp(level, x, height, z, chunkBB); - fillColumnDown(level, Tile::stoneBrick_Id, 0, x, -1, z, chunkBB); + fillColumnDown(level, Tile::cobblestone_Id, 0, x, -1, z, chunkBB); } } @@ -1313,6 +1415,11 @@ int VillagePieces::PigHouse::getVillagerProfession(int villagerNumber) return Villager::PROFESSION_FARMER; } +VillagePieces::TwoRoomHouse::TwoRoomHouse() +{ + // for reflection +} + VillagePieces::TwoRoomHouse::TwoRoomHouse(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction) : VillagePiece(startPiece, genDepth) { heightPosition = -1; // 4J added initialiser @@ -1353,12 +1460,12 @@ bool VillagePieces::TwoRoomHouse::postProcess(Level *level, Random *random, Boun // floor generateBox(level, chunkBB, 2, 0, 5, 8, 0, 10, Tile::wood_Id, Tile::wood_Id, false); generateBox(level, chunkBB, 1, 0, 1, 7, 0, 4, Tile::wood_Id, Tile::wood_Id, false); - generateBox(level, chunkBB, 0, 0, 0, 0, 3, 5, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 8, 0, 0, 8, 3, 10, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 1, 0, 0, 7, 2, 0, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 1, 0, 5, 2, 1, 5, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 2, 0, 6, 2, 3, 10, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); - generateBox(level, chunkBB, 3, 0, 10, 7, 3, 10, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 0, 0, 0, 0, 3, 5, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 8, 0, 0, 8, 3, 10, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 1, 0, 0, 7, 2, 0, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 1, 0, 5, 2, 1, 5, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 2, 0, 6, 2, 3, 10, Tile::cobblestone_Id, Tile::cobblestone_Id, false); + generateBox(level, chunkBB, 3, 0, 10, 7, 3, 10, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // room 1 roof generateBox(level, chunkBB, 1, 2, 0, 7, 3, 0, Tile::wood_Id, Tile::wood_Id, false); @@ -1456,7 +1563,7 @@ bool VillagePieces::TwoRoomHouse::postProcess(Level *level, Random *random, Boun for (int x = 0; x < width; x++) { generateAirColumnUp(level, x, height, z, chunkBB); - fillColumnDown(level, Tile::stoneBrick_Id, 0, x, -1, z, chunkBB); + fillColumnDown(level, Tile::cobblestone_Id, 0, x, -1, z, chunkBB); } } for (int z = 5; z < depth - 1; z++) @@ -1464,7 +1571,7 @@ bool VillagePieces::TwoRoomHouse::postProcess(Level *level, Random *random, Boun for (int x = 2; x < width; x++) { generateAirColumnUp(level, x, height, z, chunkBB); - fillColumnDown(level, Tile::stoneBrick_Id, 0, x, -1, z, chunkBB); + fillColumnDown(level, Tile::cobblestone_Id, 0, x, -1, z, chunkBB); } } @@ -1476,7 +1583,7 @@ bool VillagePieces::TwoRoomHouse::postProcess(Level *level, Random *random, Boun void VillagePieces::Smithy::staticCtor() { - treasureItems = WeighedTreasureArray(13); + treasureItems = WeighedTreasureArray(17); treasureItems[0] = new WeighedTreasure(Item::diamond_Id, 0, 1, 3, 3); treasureItems[1] = new WeighedTreasure(Item::ironIngot_Id, 0, 1, 5, 10); treasureItems[2] = new WeighedTreasure(Item::goldIngot_Id, 0, 1, 3, 5); @@ -1490,11 +1597,21 @@ void VillagePieces::Smithy::staticCtor() treasureItems[10] = new WeighedTreasure(Item::boots_iron_Id, 0, 1, 1, 5); treasureItems[11] = new WeighedTreasure(Tile::obsidian_Id, 0, 3, 7, 5); treasureItems[12] = new WeighedTreasure(Tile::sapling_Id, 0, 3, 7, 5); + // very rare for villages ... + treasureItems[13] = new WeighedTreasure(Item::saddle_Id, 0, 1, 1, 3); + treasureItems[14] = new WeighedTreasure(Item::horseArmorMetal_Id, 0, 1, 1, 1); + treasureItems[15] = new WeighedTreasure(Item::horseArmorGold_Id, 0, 1, 1, 1); + treasureItems[16] = new WeighedTreasure(Item::horseArmorDiamond_Id, 0, 1, 1, 1); + // ... +} + +VillagePieces::Smithy::Smithy() +{ + // for reflection } VillagePieces::Smithy::Smithy(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction) : VillagePiece(startPiece, genDepth) { - heightPosition = -1; // 4J added initialiser hasPlacedChest = false; orientation = direction; @@ -1514,6 +1631,18 @@ VillagePieces::Smithy *VillagePieces::Smithy::createPiece(StartPiece *startPiece return new Smithy(startPiece, genDepth, random, box, direction); } +void VillagePieces::Smithy::addAdditonalSaveData(CompoundTag *tag) +{ + VillagePiece::addAdditonalSaveData(tag); + tag->putBoolean(L"Chest", hasPlacedChest); +} + +void VillagePieces::Smithy::readAdditonalSaveData(CompoundTag *tag) +{ + VillagePiece::readAdditonalSaveData(tag); + hasPlacedChest = tag->getBoolean(L"Chest"); +} + bool VillagePieces::Smithy::postProcess(Level *level, Random *random, BoundingBox *chunkBB) { if (heightPosition < 0) @@ -1530,10 +1659,10 @@ bool VillagePieces::Smithy::postProcess(Level *level, Random *random, BoundingBo generateBox(level, chunkBB, 0, 1, 0, 9, 4, 6, 0, 0, false); // floor - generateBox(level, chunkBB, 0, 0, 0, 9, 0, 6, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 0, 0, 0, 9, 0, 6, Tile::cobblestone_Id, Tile::cobblestone_Id, false); // roof - generateBox(level, chunkBB, 0, 4, 0, 9, 4, 6, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 0, 4, 0, 9, 4, 6, Tile::cobblestone_Id, Tile::cobblestone_Id, false); generateBox(level, chunkBB, 0, 5, 0, 9, 5, 6, Tile::stoneSlabHalf_Id, Tile::stoneSlabHalf_Id, false); generateBox(level, chunkBB, 1, 5, 1, 8, 5, 5, 0, 0, false); @@ -1553,13 +1682,13 @@ bool VillagePieces::Smithy::postProcess(Level *level, Random *random, BoundingBo generateBox(level, chunkBB, 9, 1, 0, 9, 3, 0, Tile::fence_Id, Tile::fence_Id, false); // furnace - generateBox(level, chunkBB, 6, 1, 4, 9, 4, 6, Tile::stoneBrick_Id, Tile::stoneBrick_Id, false); + generateBox(level, chunkBB, 6, 1, 4, 9, 4, 6, Tile::cobblestone_Id, Tile::cobblestone_Id, false); placeBlock(level, Tile::lava_Id, 0, 7, 1, 5, chunkBB); placeBlock(level, Tile::lava_Id, 0, 8, 1, 5, chunkBB); placeBlock(level, Tile::ironFence_Id, 0, 9, 2, 5, chunkBB); placeBlock(level, Tile::ironFence_Id, 0, 9, 2, 4, chunkBB); generateBox(level, chunkBB, 7, 2, 4, 8, 2, 5, 0, 0, false); - placeBlock(level, Tile::stoneBrick_Id, 0, 6, 1, 3, chunkBB); + placeBlock(level, Tile::cobblestone_Id, 0, 6, 1, 3, chunkBB); placeBlock(level, Tile::furnace_Id, 0, 6, 2, 3, chunkBB); placeBlock(level, Tile::furnace_Id, 0, 6, 3, 3, chunkBB); placeBlock(level, Tile::stoneSlab_Id, 0, 8, 1, 1, chunkBB); @@ -1602,7 +1731,7 @@ bool VillagePieces::Smithy::postProcess(Level *level, Random *random, BoundingBo for (int x = 0; x < width; x++) { generateAirColumnUp(level, x, height, z, chunkBB); - fillColumnDown(level, Tile::stoneBrick_Id, 0, x, -1, z, chunkBB); + fillColumnDown(level, Tile::cobblestone_Id, 0, x, -1, z, chunkBB); } } @@ -1617,9 +1746,15 @@ int VillagePieces::Smithy::getVillagerProfession(int villagerNumber) return Villager::PROFESSION_SMITH; } +VillagePieces::Farmland::Farmland() +{ + cropsA = 0; + cropsB = 0; + // for reflection +} + VillagePieces::Farmland::Farmland(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction) : VillagePiece(startPiece, genDepth) { - heightPosition = -1; // 4J added initialiser orientation = direction; boundingBox = stairsBox; @@ -1632,7 +1767,7 @@ int VillagePieces::Farmland::selectCrops(Random *random) switch (random->nextInt(5)) { default: - return Tile::crops_Id; + return Tile::wheat_Id; case 0: return Tile::carrots_Id; case 1: @@ -1640,6 +1775,20 @@ int VillagePieces::Farmland::selectCrops(Random *random) } } +void VillagePieces::Farmland::addAdditonalSaveData(CompoundTag *tag) +{ + VillagePiece::addAdditonalSaveData(tag); + tag->putInt(L"CA", cropsA); + tag->putInt(L"CB", cropsB); +} + +void VillagePieces::Farmland::readAdditonalSaveData(CompoundTag *tag) +{ + VillagePiece::readAdditonalSaveData(tag); + cropsA = tag->getInt(L"CA"); + cropsB = tag->getInt(L"CB"); +} + VillagePieces::Farmland *VillagePieces::Farmland::createPiece(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth) { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); @@ -1700,6 +1849,15 @@ bool VillagePieces::Farmland::postProcess(Level *level, Random *random, Bounding } +VillagePieces::DoubleFarmland::DoubleFarmland() +{ + cropsA = 0; + cropsB = 0; + cropsC = 0; + cropsD = 0; + // for reflection +} + VillagePieces::DoubleFarmland::DoubleFarmland(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *stairsBox, int direction) : VillagePiece(startPiece, genDepth) { heightPosition = -1; // 4J added initialiser @@ -1712,12 +1870,30 @@ VillagePieces::DoubleFarmland::DoubleFarmland(StartPiece *startPiece, int genDep cropsD = selectCrops(random); } +void VillagePieces::DoubleFarmland::addAdditonalSaveData(CompoundTag *tag) +{ + VillagePiece::addAdditonalSaveData(tag); + tag->putInt(L"CA", cropsA); + tag->putInt(L"CB", cropsB); + tag->putInt(L"CC", cropsC); + tag->putInt(L"CD", cropsD); +} + +void VillagePieces::DoubleFarmland::readAdditonalSaveData(CompoundTag *tag) +{ + VillagePiece::readAdditonalSaveData(tag); + cropsA = tag->getInt(L"CA"); + cropsB = tag->getInt(L"CB"); + cropsC = tag->getInt(L"CC"); + cropsD = tag->getInt(L"CD"); +} + int VillagePieces::DoubleFarmland::selectCrops(Random *random) { switch (random->nextInt(5)) { default: - return Tile::crops_Id; + return Tile::wheat_Id; case 0: return Tile::carrots_Id; case 1: @@ -1794,6 +1970,11 @@ bool VillagePieces::DoubleFarmland::postProcess(Level *level, Random *random, Bo } +VillagePieces::LightPost::LightPost() +{ + // for reflection +} + VillagePieces::LightPost::LightPost(StartPiece *startPiece, int genDepth, Random *random, BoundingBox *box, int direction) : VillagePiece(startPiece, genDepth) { heightPosition = -1; // 4J - added initialiser @@ -1835,7 +2016,7 @@ bool VillagePieces::LightPost::postProcess(Level *level, Random *random, Boundin placeBlock(level, Tile::fence_Id, 0, 1, 2, 0, chunkBB); // head - placeBlock(level, Tile::cloth_Id, DyePowderItem::WHITE, 1, 3, 0, chunkBB); + placeBlock(level, Tile::wool_Id, DyePowderItem::WHITE, 1, 3, 0, chunkBB); // torches placeBlock(level, Tile::torch_Id, 0, 0, 3, 0, chunkBB); |
