6 #include "../Entities/EnderCrystal.h"
7 #include "../WorldStorage/SchematicFileSerializer.h"
13 {-2, -1, -2}, {-2, -1, -1}, {-2, -1, 0}, {-2, -1, 1}, {-2, -1, 2},
14 {2, -1, -2}, {2, -1, -1}, {2, -1, 0}, {2, -1, 1}, {2, -1, 2},
15 {-1, -1, -2}, {0, -1, -2}, {1, -1, -2},
16 {-1, -1, 2}, {0, -1, 2}, {1, -1, 2},
19 {-2, 0, -2}, {-2, 0, -1}, {-2, 0, 0}, {-2, 0, 1}, {-2, 0, 2},
20 {2, 0, -2}, {2, 0, -1}, {2, 0, 0}, {2, 0, 1}, {2, 0, 2},
21 {-1, 0, -2}, {0, 0, -2}, {1, 0, -2},
22 {-1, 0, 2}, {0, 0, 2}, {1, 0, 2},
25 {-2, 1, -2}, {-2, 1, -1}, {-2, 1, 0}, {-2, 1, 1}, {-2, 1, 2},
26 {2, 1, -2}, {2, 1, -1}, {2, 1, 0}, {2, 1, 1}, {2, 1, 2},
27 {-1, 1, -2}, {0, 1, -2}, {1, 1, -2},
28 {-1, 1, 2}, {0, 1, 2}, {1, 1, 2},
40 {-1, -1, -1}, {0, -1, -1}, {1, -1, -1},
41 {-1, -1, 1}, {0, -1, 1}, {1, -1, 1},
42 {-1, -1, 0}, {1, -1, 0},
45 {-1, 0, -1}, {0, 0, -1}, {1, 0, -1},
46 {-1, 0, 1}, {0, 0, 1}, {1, 0, 1},
47 {-1, 0, 0}, {1, 0, 0}, {0, 0, 0},
50 {-1, 1, -1}, {0, 1, -1}, {1, 1, -1},
51 {-1, 1, 1}, {0, 1, 1}, {1, 1, 1},
52 {-1, 1, 0}, {1, 1, 0}, {0, 1, 0},
75 LOGWARNING(
"EnderDragonFightStructuresGen is missing its end fountain prefab, please update your Cuberite server files! There will be no end fountain!");
84 std::vector<sTowerProperties> TowerProperties;
85 for (
const auto & TowerProperty : TowerPropertiesVector)
88 if (TowerPropertyVector.size() != 3)
90 LOGWARNING(
"Got unknown parameters on generating obsidian pillars: %s, Please use \"Height|Radius|HasCage\"; ...", TowerProperty);
94 int Radius = std::stoi(TowerPropertyVector[1]);
100 else if (
NoCaseCompare(TowerPropertyVector[2],
"false") == 0)
106 LOGWARNING(
"Got unknown value for boolean of the tower: %s should have a cage! %s. Tower will not be generated!", TowerProperty, TowerPropertyVector[2]);
109 TowerProperties.push_back({
Vector3d(), Height, Radius, HasCage});
114 std::shuffle(TowerProperties.begin(), TowerProperties.end(), std::default_random_engine(
static_cast<std::default_random_engine::result_type
>(
m_Noise.
GetSeed())));
116 for (
size_t I = 0; I < TowerProperties.size(); I++)
119 TowerProperties[I].m_Pos = TowerPos;
122 for (
int X = -TowerProperties[I].m_Radius - ChunkWidth; X <= TowerProperties[I].m_Radius + ChunkWidth; X+=std::min(TowerProperties[I].m_Radius, ChunkWidth))
124 for (
int Z = -TowerProperties[I].m_Radius - ChunkWidth; Z <= TowerProperties[I].m_Radius + ChunkWidth; Z+=std::min(TowerProperties[I].m_Radius, ChunkWidth))
134 bool ShouldPlace =
true;
135 for (
const auto & Property :
m_TowerPos[Chunk])
137 ShouldPlace &= !(TowerPos == Property.m_Pos);
141 m_TowerPos[Chunk].emplace_back(TowerProperties[I]);
146 Angle = fmod(Angle + (2.0 * M_PI /
static_cast<double>(TowerProperties.size())), 2.0 * M_PI);
158 if ((Coords.m_ChunkX >
m_MaxX) ||
159 (Coords.m_ChunkX <
m_MinX) ||
160 (Coords.m_ChunkZ >
m_MaxZ) ||
161 (Coords.m_ChunkZ <
m_MinZ))
210 for (
const auto & Property : It->second)
228 Vector3i NewPos = {Pos.
x + X, 1, Pos.z + Z};
234 for (
int Y = 0; Y <= a_Properties.
m_Height - 2; Y++)
263 for (
int X = -2; X <= 2; ++X)
265 for (
int Z = -2; Z <= 2; ++Z)
282 auto EnderCrystal = std::make_unique<cEnderCrystal>(
Vector3d(0.5, a_Properties.
m_Height, 0.5) + a_Properties.
m_Pos,
true);
283 a_ChunkDesc.
GetEntities().emplace_back(std::move(EnderCrystal));
std::enable_if< std::is_arithmetic< T >::value, C >::type FloorC(T a_Value)
Floors a value, then casts it to C (an int by default).
void LOGWARNING(std::string_view a_Format, const Args &... args)
AStringVector StringSplitAndTrim(const AString &str, const AString &delim)
Split the string at any of the listed delimiters and trim each value.
int NoCaseCompare(const AString &s1, const AString &s2)
Case-insensitive string comparison.
Vector3< double > Vector3d
Wraps the chunk coords into a single structure.
static void BlockToChunk(int a_X, int a_Z, int &a_ChunkX, int &a_ChunkZ)
Converts absolute block coords to chunk coords:
static void AbsoluteToRelative(int &a_X, int &a_Y, int &a_Z, int &a_ChunkX, int &a_ChunkZ)
Converts absolute block coords into relative (chunk + block) coords:
static bool IsValidRelPos(Vector3i a_RelPos)
Validates a chunk relative coordinate.
void SetBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType)
cEntityList & GetEntities(void)
void WriteBlockArea(const cBlockArea &a_BlockArea, int a_RelX, int a_RelY, int a_RelZ, cBlockArea::eMergeStrategy a_MergeStrategy=cBlockArea::msOverwrite)
Writes the block area into the chunk, with its origin set at the specified relative coords.
cChunkCoords GetChunkCoords() const
static const std::array< Vector3i, 26 > m_CageAir
void Init(const AString &a_TowerProperties, int a_Radius)
void GenFinish(cChunkDesc &a_ChunkDesc) override
void PlaceTower(cChunkDesc &a_ChunkDesc, const sTowerProperties &a_TowerProperties)
std::map< cChunkCoords, std::vector< sTowerProperties > > m_TowerPos
static const std::array< Vector3i, 48 > m_CagePos
cEnderDragonFightStructuresGen(int a_Seed)
NOISE_DATATYPE IntNoise1D(int a_X) const
static AString GetPathSeparator()
Returns the path separator used by the current platform.
static bool IsFile(const AString &a_Path)
Returns true if the specified path is a regular file.
static void LoadFromSchematicFile(cBlockArea &a_BlockArea, const std::string &a_FileName)
Loads an area from a .schematic file.