001 package net.minecraft.src; 002 003 import java.util.ArrayList; 004 import java.util.Collections; 005 import java.util.List; 006 import java.util.Random; 007 008 public class MapGenStronghold extends MapGenStructure 009 { 010 private BiomeGenBase[] allowedBiomeGenBases; 011 012 /** 013 * is spawned false and set true once the defined BiomeGenBases were compared with the present ones 014 */ 015 private boolean ranBiomeCheck; 016 private ChunkCoordIntPair[] structureCoords; 017 018 public MapGenStronghold() 019 { 020 this.allowedBiomeGenBases = new BiomeGenBase[] {BiomeGenBase.desert, BiomeGenBase.forest, BiomeGenBase.extremeHills, BiomeGenBase.swampland, BiomeGenBase.taiga, BiomeGenBase.icePlains, BiomeGenBase.iceMountains, BiomeGenBase.desertHills, BiomeGenBase.forestHills, BiomeGenBase.extremeHillsEdge, BiomeGenBase.jungle, BiomeGenBase.jungleHills}; 021 this.structureCoords = new ChunkCoordIntPair[3]; 022 } 023 024 protected boolean canSpawnStructureAtCoords(int par1, int par2) 025 { 026 if (!this.ranBiomeCheck) 027 { 028 Random var3 = new Random(); 029 var3.setSeed(this.worldObj.getSeed()); 030 double var4 = var3.nextDouble() * Math.PI * 2.0D; 031 032 for (int var6 = 0; var6 < this.structureCoords.length; ++var6) 033 { 034 double var7 = (1.25D + var3.nextDouble()) * 32.0D; 035 int var9 = (int)Math.round(Math.cos(var4) * var7); 036 int var10 = (int)Math.round(Math.sin(var4) * var7); 037 ArrayList var11 = new ArrayList(); 038 Collections.addAll(var11, this.allowedBiomeGenBases); 039 ChunkPosition var12 = this.worldObj.getWorldChunkManager().findBiomePosition((var9 << 4) + 8, (var10 << 4) + 8, 112, var11, var3); 040 041 if (var12 != null) 042 { 043 var9 = var12.x >> 4; 044 var10 = var12.z >> 4; 045 } 046 else 047 { 048 System.out.println("Placed stronghold in INVALID biome at (" + var9 + ", " + var10 + ")"); 049 } 050 051 this.structureCoords[var6] = new ChunkCoordIntPair(var9, var10); 052 var4 += (Math.PI * 2D) / (double)this.structureCoords.length; 053 } 054 055 this.ranBiomeCheck = true; 056 } 057 058 ChunkCoordIntPair[] var13 = this.structureCoords; 059 int var14 = var13.length; 060 061 for (int var5 = 0; var5 < var14; ++var5) 062 { 063 ChunkCoordIntPair var15 = var13[var5]; 064 065 if (par1 == var15.chunkXPos && par2 == var15.chunkZPos) 066 { 067 System.out.println(par1 + ", " + par2); 068 return true; 069 } 070 } 071 072 return false; 073 } 074 075 protected List func_75052_o_() 076 { 077 ArrayList var1 = new ArrayList(); 078 ChunkCoordIntPair[] var2 = this.structureCoords; 079 int var3 = var2.length; 080 081 for (int var4 = 0; var4 < var3; ++var4) 082 { 083 ChunkCoordIntPair var5 = var2[var4]; 084 085 if (var5 != null) 086 { 087 var1.add(var5.getChunkPosition(64)); 088 } 089 } 090 091 return var1; 092 } 093 094 protected StructureStart getStructureStart(int par1, int par2) 095 { 096 StructureStrongholdStart var3; 097 098 for (var3 = new StructureStrongholdStart(this.worldObj, this.rand, par1, par2); var3.getComponents().isEmpty() || ((ComponentStrongholdStairs2)var3.getComponents().get(0)).portalRoom == null; var3 = new StructureStrongholdStart(this.worldObj, this.rand, par1, par2)) 099 { 100 ; 101 } 102 103 return var3; 104 } 105 }