GenLayerBiomeEdge .java

net.minecraft.world.gen.layer.GenLayerBiomeEdge (class, 167 lines): extends GenLayer. members: getInts. imports: BiomeGenBase.

net.minecraft.world.gen.layerclass167 linescommonextends GenLayer7.7 KB

API Surface (1)

int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight)

Code Graph: Dependencies (3)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

GenLayerBiomeEdge.java167 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.world.gen.layer;
2
3
import net.minecraft.world.biome.BiomeGenBase;
4
5
public class GenLayerBiomeEdge extends GenLayer
6
{
7
    public GenLayerBiomeEdge(long p_i45475_1_, GenLayer p_i45475_3_)
8
    {
9
        super(p_i45475_1_);
10
        this.parent = p_i45475_3_;
11
    }
12
13
    /**
14
     * Returns a list of integer values generated by this layer. These may be interpreted as temperatures, rainfall
15
     * amounts, or biomeList[] indices based on the particular GenLayer subclass.
16
     */
17
    public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight)
18
    {
19
        int[] aint = this.parent.getInts(areaX - 1, areaY - 1, areaWidth + 2, areaHeight + 2);
20
        int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);
21
22
        for (int i = 0; i < areaHeight; ++i)
23
        {
24
            for (int j = 0; j < areaWidth; ++j)
25
            {
26
                this.initChunkSeed((long)(j + areaX), (long)(i + areaY));
27
                int k = aint[j + 1 + (i + 1) * (areaWidth + 2)];
28
29
                if (!this.replaceBiomeEdgeIfNecessary(aint, aint1, j, i, areaWidth, k, BiomeGenBase.extremeHills.biomeID, BiomeGenBase.extremeHillsEdge.biomeID) && !this.replaceBiomeEdge(aint, aint1, j, i, areaWidth, k, BiomeGenBase.mesaPlateau_F.biomeID, BiomeGenBase.mesa.biomeID) && !this.replaceBiomeEdge(aint, aint1, j, i, areaWidth, k, BiomeGenBase.mesaPlateau.biomeID, BiomeGenBase.mesa.biomeID) && !this.replaceBiomeEdge(aint, aint1, j, i, areaWidth, k, BiomeGenBase.megaTaiga.biomeID, BiomeGenBase.taiga.biomeID))
30
                {
31
                    if (k == BiomeGenBase.desert.biomeID)
32
                    {
33
                        int l1 = aint[j + 1 + (i + 1 - 1) * (areaWidth + 2)];
34
                        int i2 = aint[j + 1 + 1 + (i + 1) * (areaWidth + 2)];
35
                        int j2 = aint[j + 1 - 1 + (i + 1) * (areaWidth + 2)];
36
                        int k2 = aint[j + 1 + (i + 1 + 1) * (areaWidth + 2)];
37
38
                        if (l1 != BiomeGenBase.icePlains.biomeID && i2 != BiomeGenBase.icePlains.biomeID && j2 != BiomeGenBase.icePlains.biomeID && k2 != BiomeGenBase.icePlains.biomeID)
39
                        {
40
                            aint1[j + i * areaWidth] = k;
41
                        }
42
                        else
43
                        {
44
                            aint1[j + i * areaWidth] = BiomeGenBase.extremeHillsPlus.biomeID;
45
                        }
46
                    }
47
                    else if (k == BiomeGenBase.swampland.biomeID)
48
                    {
49
                        int l = aint[j + 1 + (i + 1 - 1) * (areaWidth + 2)];
50
                        int i1 = aint[j + 1 + 1 + (i + 1) * (areaWidth + 2)];
51
                        int j1 = aint[j + 1 - 1 + (i + 1) * (areaWidth + 2)];
52
                        int k1 = aint[j + 1 + (i + 1 + 1) * (areaWidth + 2)];
53
54
                        if (l != BiomeGenBase.desert.biomeID && i1 != BiomeGenBase.desert.biomeID && j1 != BiomeGenBase.desert.biomeID && k1 != BiomeGenBase.desert.biomeID && l != BiomeGenBase.coldTaiga.biomeID && i1 != BiomeGenBase.coldTaiga.biomeID && j1 != BiomeGenBase.coldTaiga.biomeID && k1 != BiomeGenBase.coldTaiga.biomeID && l != BiomeGenBase.icePlains.biomeID && i1 != BiomeGenBase.icePlains.biomeID && j1 != BiomeGenBase.icePlains.biomeID && k1 != BiomeGenBase.icePlains.biomeID)
55
                        {
56
                            if (l != BiomeGenBase.jungle.biomeID && k1 != BiomeGenBase.jungle.biomeID && i1 != BiomeGenBase.jungle.biomeID && j1 != BiomeGenBase.jungle.biomeID)
57
                            {
58
                                aint1[j + i * areaWidth] = k;
59
                            }
60
                            else
61
                            {
62
                                aint1[j + i * areaWidth] = BiomeGenBase.jungleEdge.biomeID;
63
                            }
64
                        }
65
                        else
66
                        {
67
                            aint1[j + i * areaWidth] = BiomeGenBase.plains.biomeID;
68
                        }
69
                    }
70
                    else
71
                    {
72
                        aint1[j + i * areaWidth] = k;
73
                    }
74
                }
75
            }
76
        }
77
78
        return aint1;
79
    }
80
81
    /**
82
     * Creates a border around a biome if necessary, e.g. A transition from hot to cold climates would otherwise occur.
83
     */
84
    private boolean replaceBiomeEdgeIfNecessary(int[] p_151636_1_, int[] p_151636_2_, int p_151636_3_, int p_151636_4_, int p_151636_5_, int p_151636_6_, int p_151636_7_, int p_151636_8_)
85
    {
86
        if (!biomesEqualOrMesaPlateau(p_151636_6_, p_151636_7_))
87
        {
88
            return false;
89
        }
90
        else
91
        {
92
            int i = p_151636_1_[p_151636_3_ + 1 + (p_151636_4_ + 1 - 1) * (p_151636_5_ + 2)];
93
            int j = p_151636_1_[p_151636_3_ + 1 + 1 + (p_151636_4_ + 1) * (p_151636_5_ + 2)];
94
            int k = p_151636_1_[p_151636_3_ + 1 - 1 + (p_151636_4_ + 1) * (p_151636_5_ + 2)];
95
            int l = p_151636_1_[p_151636_3_ + 1 + (p_151636_4_ + 1 + 1) * (p_151636_5_ + 2)];
96
97
            if (this.canBiomesBeNeighbors(i, p_151636_7_) && this.canBiomesBeNeighbors(j, p_151636_7_) && this.canBiomesBeNeighbors(k, p_151636_7_) && this.canBiomesBeNeighbors(l, p_151636_7_))
98
            {
99
                p_151636_2_[p_151636_3_ + p_151636_4_ * p_151636_5_] = p_151636_6_;
100
            }
101
            else
102
            {
103
                p_151636_2_[p_151636_3_ + p_151636_4_ * p_151636_5_] = p_151636_8_;
104
            }
105
106
            return true;
107
        }
108
    }
109
110
    /**
111
     * Creates a border around a biome.
112
     */
113
    private boolean replaceBiomeEdge(int[] p_151635_1_, int[] p_151635_2_, int p_151635_3_, int p_151635_4_, int p_151635_5_, int p_151635_6_, int p_151635_7_, int p_151635_8_)
114
    {
115
        if (p_151635_6_ != p_151635_7_)
116
        {
117
            return false;
118
        }
119
        else
120
        {
121
            int i = p_151635_1_[p_151635_3_ + 1 + (p_151635_4_ + 1 - 1) * (p_151635_5_ + 2)];
122
            int j = p_151635_1_[p_151635_3_ + 1 + 1 + (p_151635_4_ + 1) * (p_151635_5_ + 2)];
123
            int k = p_151635_1_[p_151635_3_ + 1 - 1 + (p_151635_4_ + 1) * (p_151635_5_ + 2)];
124
            int l = p_151635_1_[p_151635_3_ + 1 + (p_151635_4_ + 1 + 1) * (p_151635_5_ + 2)];
125
126
            if (biomesEqualOrMesaPlateau(i, p_151635_7_) && biomesEqualOrMesaPlateau(j, p_151635_7_) && biomesEqualOrMesaPlateau(k, p_151635_7_) && biomesEqualOrMesaPlateau(l, p_151635_7_))
127
            {
128
                p_151635_2_[p_151635_3_ + p_151635_4_ * p_151635_5_] = p_151635_6_;
129
            }
130
            else
131
            {
132
                p_151635_2_[p_151635_3_ + p_151635_4_ * p_151635_5_] = p_151635_8_;
133
            }
134
135
            return true;
136
        }
137
    }
138
139
    /**
140
     * Returns if two biomes can logically be neighbors. If one is hot and the other cold, for example, it returns
141
     * false.
142
     */
143
    private boolean canBiomesBeNeighbors(int p_151634_1_, int p_151634_2_)
144
    {
145
        if (biomesEqualOrMesaPlateau(p_151634_1_, p_151634_2_))
146
        {
147
            return true;
148
        }
149
        else
150
        {
151
            BiomeGenBase biomegenbase = BiomeGenBase.getBiome(p_151634_1_);
152
            BiomeGenBase biomegenbase1 = BiomeGenBase.getBiome(p_151634_2_);
153
154
            if (biomegenbase != null && biomegenbase1 != null)
155
            {
156
                BiomeGenBase.TempCategory biomegenbase$tempcategory = biomegenbase.getTempCategory();
157
                BiomeGenBase.TempCategory biomegenbase$tempcategory1 = biomegenbase1.getTempCategory();
158
                return biomegenbase$tempcategory == biomegenbase$tempcategory1 || biomegenbase$tempcategory == BiomeGenBase.TempCategory.MEDIUM || biomegenbase$tempcategory1 == BiomeGenBase.TempCategory.MEDIUM;
159
            }
160
            else
161
            {
162
                return false;
163
            }
164
        }
165
    }
166
}
167

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