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/RandomScatteredLargeFeature.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/RandomScatteredLargeFeature.cpp')
| -rw-r--r-- | Minecraft.World/RandomScatteredLargeFeature.cpp | 96 |
1 files changed, 76 insertions, 20 deletions
diff --git a/Minecraft.World/RandomScatteredLargeFeature.cpp b/Minecraft.World/RandomScatteredLargeFeature.cpp index d460dc14..2a2290e3 100644 --- a/Minecraft.World/RandomScatteredLargeFeature.cpp +++ b/Minecraft.World/RandomScatteredLargeFeature.cpp @@ -1,9 +1,11 @@ #include "stdafx.h" #include "net.minecraft.world.level.h" #include "net.minecraft.world.level.biome.h" +#include "net.minecraft.world.level.levelgen.structure.h" #include "ScatteredFeaturePieces.h" #include "RandomScatteredLargeFeature.h" +const wstring RandomScatteredLargeFeature::OPTION_SPACING = L"distance"; vector<Biome *> RandomScatteredLargeFeature::allowedBiomes; void RandomScatteredLargeFeature::staticCtor() @@ -11,29 +13,55 @@ void RandomScatteredLargeFeature::staticCtor() allowedBiomes.push_back( Biome::desert ); allowedBiomes.push_back( Biome::desertHills ); allowedBiomes.push_back( Biome::jungle ); + allowedBiomes.push_back( Biome::jungleHills ); + allowedBiomes.push_back( Biome::swampland ); +} + +void RandomScatteredLargeFeature::_init() +{ + spacing = 32; + minSeparation = 8; + + swamphutEnemies.push_back(new Biome::MobSpawnerData(eTYPE_WITCH, 1, 1, 1)); } RandomScatteredLargeFeature::RandomScatteredLargeFeature() { + _init(); } -bool RandomScatteredLargeFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) +RandomScatteredLargeFeature::RandomScatteredLargeFeature(unordered_map<wstring, wstring> options) { - int featureSpacing = 32; - int minFeatureSeparation = 8; + _init(); + for(AUTO_VAR(it, options.begin()); it != options.end(); ++it) + { + if (it->first.compare(OPTION_SPACING) == 0) + { + spacing = Mth::getInt(it->second, spacing, minSeparation + 1); + } + } +} + +wstring RandomScatteredLargeFeature::getFeatureName() +{ + return L"Temple"; +} + +bool RandomScatteredLargeFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) +{ int xx = x; int zz = z; - if (x < 0) x -= featureSpacing - 1; - if (z < 0) z -= featureSpacing - 1; + if (x < 0) x -= spacing - 1; + if (z < 0) z -= spacing - 1; - int xCenterFeatureChunk = x / featureSpacing; - int zCenterFeatureChunk = z / featureSpacing; + int xCenterFeatureChunk = x / spacing; + int zCenterFeatureChunk = z / spacing; Random *r = level->getRandomFor(xCenterFeatureChunk, zCenterFeatureChunk, 14357617); - xCenterFeatureChunk *= featureSpacing; - zCenterFeatureChunk *= featureSpacing; - xCenterFeatureChunk += r->nextInt(featureSpacing - minFeatureSeparation); - zCenterFeatureChunk += r->nextInt(featureSpacing - minFeatureSeparation); + xCenterFeatureChunk *= spacing; + zCenterFeatureChunk *= spacing; + xCenterFeatureChunk += r->nextInt(spacing - minSeparation); + zCenterFeatureChunk += r->nextInt(spacing - minSeparation); x = xx; z = zz; @@ -46,11 +74,14 @@ bool RandomScatteredLargeFeature::isFeatureChunk(int x, int z, bool bIsSuperflat if (forcePlacement || (x == xCenterFeatureChunk && z == zCenterFeatureChunk)) { - bool biomeOk = level->getBiomeSource()->containsOnly(x * 16 + 8, z * 16 + 8, 0, allowedBiomes); - if (biomeOk) + Biome *biome = level->getBiomeSource()->getBiome(x * 16 + 8, z * 16 + 8); + for (AUTO_VAR(it,allowedBiomes.begin()); it != allowedBiomes.end(); ++it) { - // System.out.println("feature at " + (x * 16) + " " + (z * 16)); - return true; + Biome *a = *it; + if (biome == a) + { + return true; + } } } @@ -60,25 +91,50 @@ bool RandomScatteredLargeFeature::isFeatureChunk(int x, int z, bool bIsSuperflat StructureStart *RandomScatteredLargeFeature::createStructureStart(int x, int z) { - // System.out.println("feature at " + (x * 16) + " " + (z * 16)); return new ScatteredFeatureStart(level, random, x, z); } +RandomScatteredLargeFeature::ScatteredFeatureStart::ScatteredFeatureStart() +{ + // for reflection +} -RandomScatteredLargeFeature::ScatteredFeatureStart::ScatteredFeatureStart(Level *level, Random *random, int chunkX, int chunkZ) +RandomScatteredLargeFeature::ScatteredFeatureStart::ScatteredFeatureStart(Level *level, Random *random, int chunkX, int chunkZ) : StructureStart(chunkX, chunkZ) { - if (level->getBiome(chunkX * 16 + 8, chunkZ * 16 + 8) == Biome::jungle) + Biome *biome = level->getBiome(chunkX * 16 + 8, chunkZ * 16 + 8); + if (biome == Biome::jungle || biome == Biome::jungleHills) { ScatteredFeaturePieces::JunglePyramidPiece *startRoom = new ScatteredFeaturePieces::JunglePyramidPiece(random, chunkX * 16, chunkZ * 16); pieces.push_back(startRoom); - // System.out.println("jungle feature at " + (chunkX * 16) + " " + (chunkZ * 16)); + } + else if (biome == Biome::swampland) + { + ScatteredFeaturePieces::SwamplandHut *startRoom = new ScatteredFeaturePieces::SwamplandHut(random, chunkX * 16, chunkZ * 16); + pieces.push_back(startRoom); } else { ScatteredFeaturePieces::DesertPyramidPiece *startRoom = new ScatteredFeaturePieces::DesertPyramidPiece(random, chunkX * 16, chunkZ * 16); pieces.push_back(startRoom); - // System.out.println("desert feature at " + (chunkX * 16) + " " + (chunkZ * 16)); } calculateBoundingBox(); +} + +bool RandomScatteredLargeFeature::isSwamphut(int cellX, int cellY, int cellZ) +{ + StructureStart *structureAt = getStructureAt(cellX, cellY, cellZ); + if (structureAt == NULL || !( dynamic_cast<ScatteredFeatureStart *>( structureAt ) ) || structureAt->pieces.empty()) + { + return false; + } + StructurePiece *first = NULL; + AUTO_VAR(it, structureAt->pieces.begin()); + if(it != structureAt->pieces.end() ) first = *it; + return dynamic_cast<ScatteredFeaturePieces::SwamplandHut *>(first) != NULL; +} + +vector<Biome::MobSpawnerData *> *RandomScatteredLargeFeature::getSwamphutEnemies() +{ + return &swamphutEnemies; }
\ No newline at end of file |
