mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-24 15:43:38 +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
122 lines
4.1 KiB
C++
122 lines
4.1 KiB
C++
#include "../../Platform/stdafx.h"
|
|
#include "../Biomes/Biome.h"
|
|
#include "NetherBridgeFeature.h"
|
|
#include "../Structures/NetherBridgePieces.h"
|
|
#include "../../Blocks/MobSpawner.h"
|
|
#include "../../Headers/net.minecraft.world.entity.monster.h"
|
|
#include "../../Headers/net.minecraft.world.level.h"
|
|
#include "../../Headers/net.minecraft.world.level.dimension.h"
|
|
|
|
NetherBridgeFeature::NetherBridgeFeature() : StructureFeature() {
|
|
bridgeEnemies.push_back(new Biome::MobSpawnerData(eTYPE_BLAZE, 10, 2, 3));
|
|
bridgeEnemies.push_back(
|
|
new Biome::MobSpawnerData(eTYPE_PIGZOMBIE, 5, 4, 4));
|
|
bridgeEnemies.push_back(
|
|
new Biome::MobSpawnerData(eTYPE_SKELETON, 10, 4, 4));
|
|
bridgeEnemies.push_back(
|
|
new Biome::MobSpawnerData(eTYPE_LAVASLIME, 3, 4, 4));
|
|
isSpotSelected = false;
|
|
netherFortressPos = nullptr;
|
|
}
|
|
|
|
NetherBridgeFeature::~NetherBridgeFeature() {
|
|
if (netherFortressPos != nullptr) delete netherFortressPos;
|
|
}
|
|
|
|
std::wstring NetherBridgeFeature::getFeatureName() { return L"Fortress"; }
|
|
|
|
std::vector<Biome::MobSpawnerData*>* NetherBridgeFeature::getBridgeEnemies() {
|
|
return &bridgeEnemies;
|
|
}
|
|
|
|
bool NetherBridgeFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) {
|
|
// 4J Stu - New implementation to force a nether fortress
|
|
if (!isSpotSelected) {
|
|
// Set the random
|
|
random->setSeed(level->getSeed());
|
|
random->nextInt();
|
|
|
|
// Due to our nether size we want to accept chunks in the range
|
|
// [(-3,-3),(3,3)] (7x7). This is 49 possible chunks that should give
|
|
// the fortress enough room to grow within our limited nether
|
|
int chunk = random->nextInt(49);
|
|
|
|
int xCoord = chunk % 7;
|
|
int zCoord = chunk / 7;
|
|
|
|
netherFortressPos = new ChunkPos(xCoord, zCoord);
|
|
|
|
isSpotSelected = true;
|
|
}
|
|
|
|
bool forcePlacement = false;
|
|
LevelGenerationOptions* levelGenOptions = app.getLevelGenerationOptions();
|
|
if (levelGenOptions != nullptr) {
|
|
forcePlacement =
|
|
levelGenOptions->isFeatureChunk(x, z, eFeature_NetherBridge);
|
|
}
|
|
|
|
if (forcePlacement ||
|
|
(x == netherFortressPos->x && z == netherFortressPos->z))
|
|
return true;
|
|
|
|
#ifdef _LARGE_WORLDS
|
|
int xzSize = level->dimension->getXZSize();
|
|
if (xzSize > 30) {
|
|
// For large worlds, lets allow the PC version of the spawning to place
|
|
// nether fortresses (plus the one we forced above)
|
|
int cx = x >> 4;
|
|
int cz = z >> 4;
|
|
|
|
random->setSeed(cx ^ (cz << 4) ^ level->getSeed());
|
|
random->nextInt();
|
|
|
|
if (random->nextInt(3) != 0) {
|
|
return false;
|
|
}
|
|
if (x != ((cx << 4) + 4 + random->nextInt(8))) {
|
|
return false;
|
|
}
|
|
if (z != ((cz << 4) + 4 + random->nextInt(8))) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
#endif
|
|
|
|
return false;
|
|
}
|
|
|
|
StructureStart* NetherBridgeFeature::createStructureStart(int x, int z) {
|
|
return new NetherBridgeStart(level, random, x, z);
|
|
}
|
|
|
|
void NetherBridgeFeature::clearCachedBuildings() { cachedStructures.clear(); }
|
|
|
|
NetherBridgeFeature::NetherBridgeStart::NetherBridgeStart() {
|
|
// for reflection
|
|
}
|
|
|
|
NetherBridgeFeature::NetherBridgeStart::NetherBridgeStart(Level* level,
|
|
Random* random,
|
|
int chunkX,
|
|
int chunkZ)
|
|
: StructureStart(chunkX, chunkZ) {
|
|
NetherBridgePieces::StartPiece* start = new NetherBridgePieces::StartPiece(
|
|
random, (chunkX << 4) + 2, (chunkZ << 4) + 2, level);
|
|
pieces.push_back(start);
|
|
start->addChildren(start, &pieces, random);
|
|
|
|
std::vector<StructurePiece*>* pendingChildren = &start->pendingChildren;
|
|
while (!pendingChildren->empty()) {
|
|
int pos = random->nextInt((int)pendingChildren->size());
|
|
auto it = pendingChildren->begin() + pos;
|
|
StructurePiece* structurePiece = *it;
|
|
pendingChildren->erase(it);
|
|
structurePiece->addChildren(start, &pieces, random);
|
|
}
|
|
|
|
calculateBoundingBox();
|
|
moveInsideHeights(level, random, 48, 70);
|
|
}
|