MapGenStronghold .java

net.minecraft.world.gen.structure.MapGenStronghold (class): members: structureCoords, field_151546_e, field_82671_h, field_82672_i, ranBiomeCheck, Start.

net.minecraft.world.gen.structureclass168 linescommonextends MapGenStructure5.8 KB

API Surface (4)

String getStructureName()
boolean canSpawnStructureAtCoords(int chunkX, int chunkZ)
List<BlockPos> getCoordList()
StructureStart getStructureStart(int chunkX, int chunkZ)

Fields & Constants (5)

field_151546_e
ranBiomeCheck
structureCoords
field_82671_h
field_82672_i

String literals (4)

"distance"
"count"
"spread"
"Stronghold"

Full Source

MapGenStronghold.java168 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.world.gen.structure;
2
3
import com.google.common.collect.Lists;
4
import java.util.List;
5
import java.util.Map;
6
import java.util.Random;
7
import java.util.Map.Entry;
8
import net.minecraft.util.BlockPos;
9
import net.minecraft.util.MathHelper;
10
import net.minecraft.world.ChunkCoordIntPair;
11
import net.minecraft.world.World;
12
import net.minecraft.world.biome.BiomeGenBase;
13
14
public class MapGenStronghold extends MapGenStructure
15
{
16
    private List<BiomeGenBase> field_151546_e;
17
18
    /**
19
     * is spawned false and set true once the defined BiomeGenBases were compared with the present ones
20
     */
21
    private boolean ranBiomeCheck;
22
    private ChunkCoordIntPair[] structureCoords;
23
    private double field_82671_h;
24
    private int field_82672_i;
25
26
    public MapGenStronghold()
27
    {
28
        this.structureCoords = new ChunkCoordIntPair[3];
29
        this.field_82671_h = 32.0D;
30
        this.field_82672_i = 3;
31
        this.field_151546_e = Lists.<BiomeGenBase>newArrayList();
32
33
        for (BiomeGenBase biomegenbase : BiomeGenBase.getBiomeGenArray())
34
        {
35
            if (biomegenbase != null && biomegenbase.minHeight > 0.0F)
36
            {
37
                this.field_151546_e.add(biomegenbase);
38
            }
39
        }
40
    }
41
42
    public MapGenStronghold(Map<String, String> p_i2068_1_)
43
    {
44
        this();
45
46
        for (Entry<String, String> entry : p_i2068_1_.entrySet())
47
        {
48
            if (((String)entry.getKey()).equals("distance"))
49
            {
50
                this.field_82671_h = MathHelper.parseDoubleWithDefaultAndMax((String)entry.getValue(), this.field_82671_h, 1.0D);
51
            }
52
            else if (((String)entry.getKey()).equals("count"))
53
            {
54
                this.structureCoords = new ChunkCoordIntPair[MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.structureCoords.length, 1)];
55
            }
56
            else if (((String)entry.getKey()).equals("spread"))
57
            {
58
                this.field_82672_i = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.field_82672_i, 1);
59
            }
60
        }
61
    }
62
63
    public String getStructureName()
64
    {
65
        return "Stronghold";
66
    }
67
68
    protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ)
69
    {
70
        if (!this.ranBiomeCheck)
71
        {
72
            Random random = new Random();
73
            random.setSeed(this.worldObj.getSeed());
74
            double d0 = random.nextDouble() * Math.PI * 2.0D;
75
            int i = 1;
76
77
            for (int j = 0; j < this.structureCoords.length; ++j)
78
            {
79
                double d1 = (1.25D * (double)i + random.nextDouble()) * this.field_82671_h * (double)i;
80
                int k = (int)Math.round(Math.cos(d0) * d1);
81
                int l = (int)Math.round(Math.sin(d0) * d1);
82
                BlockPos blockpos = this.worldObj.getWorldChunkManager().findBiomePosition((k << 4) + 8, (l << 4) + 8, 112, this.field_151546_e, random);
83
84
                if (blockpos != null)
85
                {
86
                    k = blockpos.getX() >> 4;
87
                    l = blockpos.getZ() >> 4;
88
                }
89
90
                this.structureCoords[j] = new ChunkCoordIntPair(k, l);
91
                d0 += (Math.PI * 2D) * (double)i / (double)this.field_82672_i;
92
93
                if (j == this.field_82672_i)
94
                {
95
                    i += 2 + random.nextInt(5);
96
                    this.field_82672_i += 1 + random.nextInt(2);
97
                }
98
            }
99
100
            this.ranBiomeCheck = true;
101
        }
102
103
        for (ChunkCoordIntPair chunkcoordintpair : this.structureCoords)
104
        {
105
            if (chunkX == chunkcoordintpair.chunkXPos && chunkZ == chunkcoordintpair.chunkZPos)
106
            {
107
                return true;
108
            }
109
        }
110
111
        return false;
112
    }
113
114
    protected List<BlockPos> getCoordList()
115
    {
116
        List<BlockPos> list = Lists.<BlockPos>newArrayList();
117
118
        for (ChunkCoordIntPair chunkcoordintpair : this.structureCoords)
119
        {
120
            if (chunkcoordintpair != null)
121
            {
122
                list.add(chunkcoordintpair.getCenterBlock(64));
123
            }
124
        }
125
126
        return list;
127
    }
128
129
    protected StructureStart getStructureStart(int chunkX, int chunkZ)
130
    {
131
        MapGenStronghold.Start mapgenstronghold$start;
132
133
        for (mapgenstronghold$start = new MapGenStronghold.Start(this.worldObj, this.rand, chunkX, chunkZ); mapgenstronghold$start.getComponents().isEmpty() || ((StructureStrongholdPieces.Stairs2)mapgenstronghold$start.getComponents().get(0)).strongholdPortalRoom == null; mapgenstronghold$start = new MapGenStronghold.Start(this.worldObj, this.rand, chunkX, chunkZ))
134
        {
135
            ;
136
        }
137
138
        return mapgenstronghold$start;
139
    }
140
141
    public static class Start extends StructureStart
142
    {
143
        public Start()
144
        {
145
        }
146
147
        public Start(World worldIn, Random p_i2067_2_, int p_i2067_3_, int p_i2067_4_)
148
        {
149
            super(p_i2067_3_, p_i2067_4_);
150
            StructureStrongholdPieces.prepareStructurePieces();
151
            StructureStrongholdPieces.Stairs2 structurestrongholdpieces$stairs2 = new StructureStrongholdPieces.Stairs2(0, p_i2067_2_, (p_i2067_3_ << 4) + 2, (p_i2067_4_ << 4) + 2);
152
            this.components.add(structurestrongholdpieces$stairs2);
153
            structurestrongholdpieces$stairs2.buildComponent(structurestrongholdpieces$stairs2, this.components, p_i2067_2_);
154
            List<StructureComponent> list = structurestrongholdpieces$stairs2.field_75026_c;
155
156
            while (!list.isEmpty())
157
            {
158
                int i = p_i2067_2_.nextInt(list.size());
159
                StructureComponent structurecomponent = (StructureComponent)list.remove(i);
160
                structurecomponent.buildComponent(structurestrongholdpieces$stairs2, this.components, p_i2067_2_);
161
            }
162
163
            this.updateBoundingBox();
164
            this.markAvailableHeight(worldIn, p_i2067_2_, 10);
165
        }
166
    }
167
}
168

Deobfuscated MCP 1.8.9 source of MapGenStronghold from Marcelektro/MavenMCP-1.8.9 (net/minecraft/world/gen/structure/MapGenStronghold.java), stored verbatim.