mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-24 02:13:38 +00:00
40 lines
1.3 KiB
C++
40 lines
1.3 KiB
C++
#include "../../Platform/stdafx.h"
|
|
#include "../../Headers/net.minecraft.world.level.levelgen.structure.h"
|
|
#include "../../Util/JavaMath.h"
|
|
#include "../../Util/Mth.h"
|
|
|
|
const std::wstring MineShaftFeature::OPTION_CHANCE = L"chance";
|
|
|
|
MineShaftFeature::MineShaftFeature() { chance = 0.01; }
|
|
|
|
std::wstring MineShaftFeature::getFeatureName() { return L"Mineshaft"; }
|
|
|
|
MineShaftFeature::MineShaftFeature(
|
|
std::unordered_map<std::wstring, std::wstring> options) {
|
|
chance = 0.01;
|
|
|
|
for (AUTO_VAR(it, options.begin()); it != options.end(); ++it) {
|
|
if (it->first.compare(OPTION_CHANCE) == 0) {
|
|
chance = Mth::getDouble(it->second, chance);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool MineShaftFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) {
|
|
bool forcePlacement = false;
|
|
LevelGenerationOptions* levelGenOptions = app.getLevelGenerationOptions();
|
|
if (levelGenOptions != NULL) {
|
|
forcePlacement =
|
|
levelGenOptions->isFeatureChunk(x, z, eFeature_Mineshaft);
|
|
}
|
|
|
|
return forcePlacement || (random->nextDouble() < chance &&
|
|
random->nextInt(80) < std::max(abs(x), abs(z)));
|
|
}
|
|
|
|
StructureStart* MineShaftFeature::createStructureStart(int x, int z) {
|
|
// 4J added
|
|
app.AddTerrainFeaturePosition(eTerrainFeature_Mineshaft, x, z);
|
|
|
|
return new MineShaftStart(level, random, x, z);
|
|
} |