the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "net.minecraft.world.level.h"
3#include "net.minecraft.world.level.biome.h"
4#include "net.minecraft.world.level.levelgen.structure.h"
5#include "ScatteredFeaturePieces.h"
6#include "RandomScatteredLargeFeature.h"
7
8const wstring RandomScatteredLargeFeature::OPTION_SPACING = L"distance";
9vector<Biome *> RandomScatteredLargeFeature::allowedBiomes;
10
11void RandomScatteredLargeFeature::staticCtor()
12{
13 allowedBiomes.push_back( Biome::desert );
14 allowedBiomes.push_back( Biome::desertHills );
15 allowedBiomes.push_back( Biome::jungle );
16 allowedBiomes.push_back( Biome::jungleHills );
17 allowedBiomes.push_back( Biome::swampland );
18}
19
20void RandomScatteredLargeFeature::_init()
21{
22 spacing = 32;
23 minSeparation = 8;
24
25 swamphutEnemies.push_back(new Biome::MobSpawnerData(eTYPE_WITCH, 1, 1, 1));
26}
27
28RandomScatteredLargeFeature::RandomScatteredLargeFeature()
29{
30 _init();
31}
32
33RandomScatteredLargeFeature::RandomScatteredLargeFeature(unordered_map<wstring, wstring> options)
34{
35 _init();
36
37 for(AUTO_VAR(it, options.begin()); it != options.end(); ++it)
38 {
39 if (it->first.compare(OPTION_SPACING) == 0)
40 {
41 spacing = Mth::getInt(it->second, spacing, minSeparation + 1);
42 }
43 }
44}
45
46wstring RandomScatteredLargeFeature::getFeatureName()
47{
48 return L"Temple";
49}
50
51bool RandomScatteredLargeFeature::isFeatureChunk(int x, int z, bool bIsSuperflat)
52{
53 int xx = x;
54 int zz = z;
55 if (x < 0) x -= spacing - 1;
56 if (z < 0) z -= spacing - 1;
57
58 int xCenterFeatureChunk = x / spacing;
59 int zCenterFeatureChunk = z / spacing;
60 Random *r = level->getRandomFor(xCenterFeatureChunk, zCenterFeatureChunk, 14357617);
61 xCenterFeatureChunk *= spacing;
62 zCenterFeatureChunk *= spacing;
63 xCenterFeatureChunk += r->nextInt(spacing - minSeparation);
64 zCenterFeatureChunk += r->nextInt(spacing - minSeparation);
65 x = xx;
66 z = zz;
67
68 bool forcePlacement = false;
69 LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions();
70 if( levelGenOptions != NULL )
71 {
72 forcePlacement = levelGenOptions->isFeatureChunk(x,z,eFeature_Temples);
73 }
74
75 if (forcePlacement || (x == xCenterFeatureChunk && z == zCenterFeatureChunk))
76 {
77 Biome *biome = level->getBiomeSource()->getBiome(x * 16 + 8, z * 16 + 8);
78 for (AUTO_VAR(it,allowedBiomes.begin()); it != allowedBiomes.end(); ++it)
79 {
80 Biome *a = *it;
81 if (biome == a)
82 {
83 return true;
84 }
85 }
86 }
87
88 return false;
89
90}
91
92StructureStart *RandomScatteredLargeFeature::createStructureStart(int x, int z)
93{
94 return new ScatteredFeatureStart(level, random, x, z);
95}
96
97RandomScatteredLargeFeature::ScatteredFeatureStart::ScatteredFeatureStart()
98{
99 // for reflection
100}
101
102RandomScatteredLargeFeature::ScatteredFeatureStart::ScatteredFeatureStart(Level *level, Random *random, int chunkX, int chunkZ) : StructureStart(chunkX, chunkZ)
103{
104 Biome *biome = level->getBiome(chunkX * 16 + 8, chunkZ * 16 + 8);
105 if (biome == Biome::jungle || biome == Biome::jungleHills)
106 {
107 ScatteredFeaturePieces::JunglePyramidPiece *startRoom = new ScatteredFeaturePieces::JunglePyramidPiece(random, chunkX * 16, chunkZ * 16);
108 pieces.push_back(startRoom);
109 }
110 else if (biome == Biome::swampland)
111 {
112 ScatteredFeaturePieces::SwamplandHut *startRoom = new ScatteredFeaturePieces::SwamplandHut(random, chunkX * 16, chunkZ * 16);
113 pieces.push_back(startRoom);
114 }
115 else
116 {
117 ScatteredFeaturePieces::DesertPyramidPiece *startRoom = new ScatteredFeaturePieces::DesertPyramidPiece(random, chunkX * 16, chunkZ * 16);
118 pieces.push_back(startRoom);
119 }
120
121 calculateBoundingBox();
122}
123
124bool RandomScatteredLargeFeature::isSwamphut(int cellX, int cellY, int cellZ)
125{
126 StructureStart *structureAt = getStructureAt(cellX, cellY, cellZ);
127 if (structureAt == NULL || !( dynamic_cast<ScatteredFeatureStart *>( structureAt ) ) || structureAt->pieces.empty())
128 {
129 return false;
130 }
131 StructurePiece *first = NULL;
132 AUTO_VAR(it, structureAt->pieces.begin());
133 if(it != structureAt->pieces.end() ) first = *it;
134 return dynamic_cast<ScatteredFeaturePieces::SwamplandHut *>(first) != NULL;
135}
136
137vector<Biome::MobSpawnerData *> *RandomScatteredLargeFeature::getSwamphutEnemies()
138{
139 return &swamphutEnemies;
140}