the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 130 lines 3.5 kB view raw
1#include "stdafx.h" 2#include "Biome.h" 3#include "NetherBridgeFeature.h" 4#include "NetherBridgePieces.h" 5#include "MobSpawner.h" 6#include "net.minecraft.world.entity.monster.h" 7#include "net.minecraft.world.level.h" 8#include "net.minecraft.world.level.dimension.h" 9 10 11NetherBridgeFeature::NetherBridgeFeature() : StructureFeature() 12{ 13 bridgeEnemies.push_back(new Biome::MobSpawnerData(eTYPE_BLAZE, 10, 2, 3)); 14 bridgeEnemies.push_back(new Biome::MobSpawnerData(eTYPE_PIGZOMBIE, 5, 4, 4)); 15 bridgeEnemies.push_back(new Biome::MobSpawnerData(eTYPE_SKELETON, 10, 4, 4)); 16 bridgeEnemies.push_back(new Biome::MobSpawnerData(eTYPE_LAVASLIME, 3, 4, 4)); 17 isSpotSelected=false; 18 netherFortressPos = NULL; 19 20} 21 22NetherBridgeFeature::~NetherBridgeFeature() 23{ 24 if( netherFortressPos != NULL ) delete netherFortressPos; 25} 26 27wstring NetherBridgeFeature::getFeatureName() 28{ 29 return L"Fortress"; 30} 31 32vector<Biome::MobSpawnerData *> *NetherBridgeFeature::getBridgeEnemies() 33{ 34 return &bridgeEnemies; 35} 36 37bool NetherBridgeFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) 38{ 39 // 4J Stu - New implementation to force a nether fortress 40 if (!isSpotSelected) 41 { 42 // Set the random 43 random->setSeed(level->getSeed()); 44 random->nextInt(); 45 46 // 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 47 // the fortress enough room to grow within our limited nether 48 int chunk = random->nextInt(49); 49 50 int xCoord = chunk % 7; 51 int zCoord = chunk / 7; 52 53 netherFortressPos = new ChunkPos(xCoord, zCoord); 54 55 isSpotSelected = true; 56 } 57 58 bool forcePlacement = false; 59 LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); 60 if( levelGenOptions != NULL ) 61 { 62 forcePlacement = levelGenOptions->isFeatureChunk(x,z,eFeature_NetherBridge); 63 } 64 65 if(forcePlacement || (x == netherFortressPos->x && z == netherFortressPos->z) ) return true; 66 67#ifdef _LARGE_WORLDS 68 int xzSize = level->dimension->getXZSize(); 69 if(xzSize > 30) 70 { 71 // For large worlds, lets allow the PC version of the spawning to place nether fortresses (plus the one we forced above) 72 int cx = x >> 4; 73 int cz = z >> 4; 74 75 random->setSeed(cx ^ (cz << 4) ^ level->getSeed()); 76 random->nextInt(); 77 78 if (random->nextInt(3) != 0) 79 { 80 return false; 81 } 82 if (x != ((cx << 4) + 4 + random->nextInt(8))) 83 { 84 return false; 85 } 86 if (z != ((cz << 4) + 4 + random->nextInt(8))) 87 { 88 return false; 89 } 90 return true; 91 } 92#endif 93 94 return false; 95} 96 97StructureStart *NetherBridgeFeature::createStructureStart(int x, int z) 98{ 99 return new NetherBridgeStart(level, random, x, z); 100} 101 102void NetherBridgeFeature::clearCachedBuildings() 103{ 104 cachedStructures.clear(); 105} 106 107NetherBridgeFeature::NetherBridgeStart::NetherBridgeStart() 108{ 109 // for reflection 110} 111 112NetherBridgeFeature::NetherBridgeStart::NetherBridgeStart(Level *level, Random *random, int chunkX, int chunkZ) : StructureStart(chunkX, chunkZ) 113{ 114 NetherBridgePieces::StartPiece *start = new NetherBridgePieces::StartPiece(random, (chunkX << 4) + 2, (chunkZ << 4) + 2, level); 115 pieces.push_back(start); 116 start->addChildren(start, &pieces, random); 117 118 vector<StructurePiece *> *pendingChildren = &start->pendingChildren; 119 while (!pendingChildren->empty()) 120 { 121 int pos = random->nextInt((int)pendingChildren->size()); 122 AUTO_VAR(it, pendingChildren->begin() + pos); 123 StructurePiece *structurePiece = *it; 124 pendingChildren->erase(it); 125 structurePiece->addChildren(start, &pieces, random); 126 } 127 128 calculateBoundingBox(); 129 moveInsideHeights(level, random, 48, 70); 130}