mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-25 11:23:43 +00:00
# Conflicts: # Minecraft.Client/Network/PlayerChunkMap.cpp # Minecraft.Client/Network/PlayerList.cpp # Minecraft.Client/Network/ServerChunkCache.cpp # Minecraft.Client/Platform/Common/Consoles_App.cpp # Minecraft.Client/Platform/Common/DLC/DLCManager.cpp # Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp # Minecraft.Client/Platform/Common/GameRules/LevelRuleset.cpp # Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp # Minecraft.Client/Platform/Common/Tutorial/TutorialTask.cpp # Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp # Minecraft.Client/Platform/Common/UI/UIComponent_Panorama.cpp # Minecraft.Client/Platform/Common/UI/UIController.cpp # Minecraft.Client/Platform/Common/UI/UIController.h # Minecraft.Client/Platform/Extrax64Stubs.cpp # Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h # Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Storage.h # Minecraft.Client/Player/EntityTracker.cpp # Minecraft.Client/Player/ServerPlayer.cpp # Minecraft.Client/Rendering/EntityRenderers/PlayerRenderer.cpp # Minecraft.Client/Textures/Packs/DLCTexturePack.cpp # Minecraft.Client/Textures/Stitching/StitchedTexture.cpp # Minecraft.Client/Textures/Stitching/TextureMap.cpp # Minecraft.Client/Textures/Textures.cpp # Minecraft.World/Blocks/NotGateTile.cpp # Minecraft.World/Blocks/PressurePlateTile.cpp # Minecraft.World/Blocks/TileEntities/PotionBrewing.cpp # Minecraft.World/Enchantments/EnchantmentHelper.cpp # Minecraft.World/Entities/HangingEntity.cpp # Minecraft.World/Entities/LeashFenceKnotEntity.cpp # Minecraft.World/Entities/LivingEntity.cpp # Minecraft.World/Entities/Mobs/Boat.cpp # Minecraft.World/Entities/Mobs/Minecart.cpp # Minecraft.World/Entities/Mobs/Witch.cpp # Minecraft.World/Entities/SyncedEntityData.cpp # Minecraft.World/Items/LeashItem.cpp # Minecraft.World/Items/PotionItem.cpp # Minecraft.World/Level/BaseMobSpawner.cpp # Minecraft.World/Level/CustomLevelSource.cpp # Minecraft.World/Level/Level.cpp # Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp # Minecraft.World/Level/Storage/McRegionLevelStorage.cpp # Minecraft.World/Level/Storage/RegionFileCache.cpp # Minecraft.World/Player/Player.cpp # Minecraft.World/WorldGen/Biomes/BiomeCache.cpp # Minecraft.World/WorldGen/Features/RandomScatteredLargeFeature.cpp # Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp
131 lines
4.7 KiB
C++
131 lines
4.7 KiB
C++
#include "../../Platform/stdafx.h"
|
|
#include "../../Headers/net.minecraft.world.level.h"
|
|
#include "../../Headers/net.minecraft.world.level.biome.h"
|
|
#include "../../Headers/net.minecraft.world.level.levelgen.structure.h"
|
|
#include "../Structures/ScatteredFeaturePieces.h"
|
|
#include "RandomScatteredLargeFeature.h"
|
|
|
|
const std::wstring RandomScatteredLargeFeature::OPTION_SPACING = L"distance";
|
|
std::vector<Biome*> RandomScatteredLargeFeature::allowedBiomes;
|
|
|
|
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(); }
|
|
|
|
RandomScatteredLargeFeature::RandomScatteredLargeFeature(
|
|
std::unordered_map<std::wstring, std::wstring> options) {
|
|
_init();
|
|
|
|
for (auto it = options.begin(); it != options.end(); ++it) {
|
|
if (it->first.compare(OPTION_SPACING) == 0) {
|
|
spacing = Mth::getInt(it->second, spacing, minSeparation + 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
std::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 -= spacing - 1;
|
|
if (z < 0) z -= spacing - 1;
|
|
|
|
int xCenterFeatureChunk = x / spacing;
|
|
int zCenterFeatureChunk = z / spacing;
|
|
Random* r =
|
|
level->getRandomFor(xCenterFeatureChunk, zCenterFeatureChunk, 14357617);
|
|
xCenterFeatureChunk *= spacing;
|
|
zCenterFeatureChunk *= spacing;
|
|
xCenterFeatureChunk += r->nextInt(spacing - minSeparation);
|
|
zCenterFeatureChunk += r->nextInt(spacing - minSeparation);
|
|
x = xx;
|
|
z = zz;
|
|
|
|
bool forcePlacement = false;
|
|
LevelGenerationOptions* levelGenOptions = app.getLevelGenerationOptions();
|
|
if (levelGenOptions != nullptr) {
|
|
forcePlacement =
|
|
levelGenOptions->isFeatureChunk(x, z, eFeature_Temples);
|
|
}
|
|
|
|
if (forcePlacement ||
|
|
(x == xCenterFeatureChunk && z == zCenterFeatureChunk)) {
|
|
Biome* biome =
|
|
level->getBiomeSource()->getBiome(x * 16 + 8, z * 16 + 8);
|
|
for (auto it = allowedBiomes.begin(); it != allowedBiomes.end();
|
|
++it) {
|
|
Biome* a = *it;
|
|
if (biome == a) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
StructureStart* RandomScatteredLargeFeature::createStructureStart(int x,
|
|
int z) {
|
|
return new ScatteredFeatureStart(level, random, x, z);
|
|
}
|
|
|
|
RandomScatteredLargeFeature::ScatteredFeatureStart::ScatteredFeatureStart() {
|
|
// for reflection
|
|
}
|
|
|
|
RandomScatteredLargeFeature::ScatteredFeatureStart::ScatteredFeatureStart(
|
|
Level* level, Random* random, int chunkX, int chunkZ)
|
|
: StructureStart(chunkX, chunkZ) {
|
|
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);
|
|
} 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);
|
|
}
|
|
|
|
calculateBoundingBox();
|
|
}
|
|
|
|
bool RandomScatteredLargeFeature::isSwamphut(int cellX, int cellY, int cellZ) {
|
|
StructureStart* structureAt = getStructureAt(cellX, cellY, cellZ);
|
|
if (structureAt == nullptr ||
|
|
!(dynamic_cast<ScatteredFeatureStart*>(structureAt)) ||
|
|
structureAt->pieces.empty()) {
|
|
return false;
|
|
}
|
|
StructurePiece* first = nullptr;
|
|
auto it = structureAt->pieces.begin();
|
|
if (it != structureAt->pieces.end()) first = *it;
|
|
return dynamic_cast<ScatteredFeaturePieces::SwamplandHut*>(first) != nullptr;
|
|
}
|
|
|
|
std::vector<Biome::MobSpawnerData*>*
|
|
RandomScatteredLargeFeature::getSwamphutEnemies() {
|
|
return &swamphutEnemies;
|
|
} |