forked from GTNewHorizons/Climate-Control
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenLayerSubBiome.java
More file actions
133 lines (113 loc) · 5.29 KB
/
GenLayerSubBiome.java
File metadata and controls
133 lines (113 loc) · 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package climateControl.customGenLayer;
/*
* this class replaces GenLayerHills with a configurable subbiome replacer
* it also calls the BoP subbiome replacer after determining the subbiome, if BoP is on
*/
import java.util.logging.Logger;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.gen.layer.IntCache;
import climateControl.ClimateControl;
import climateControl.biomeSettings.BiomeReplacer;
import climateControl.biomeSettings.BoPSubBiomeReplacer;
import climateControl.genLayerPack.GenLayerPack;
import climateControl.generator.BiomeSwapper;
import climateControl.generator.SubBiomeChooser;
import climateControl.utils.IntRandomizer;
import climateControl.utils.Zeno410Logger;
public class GenLayerSubBiome extends GenLayerPack {
public static Logger logger = new Zeno410Logger("GenLayerSubBiome").logger();
private GenLayer rivers;
private final SubBiomeChooser subBiomeChooser;
private final BiomeSwapper mBiomes;
private BiomeReplacer BoPSubBiomeReplacer;
private IntRandomizer randomCallback = new IntRandomizer() {
public int nextInt(int maximum) {
return GenLayerSubBiome.this.nextInt(maximum);
}
};
public GenLayerSubBiome(long p_i45479_1_, GenLayer biomes, GenLayer rivers, SubBiomeChooser subBiomeChooser,
BiomeSwapper mBiomes, boolean doBoP) {
super(p_i45479_1_);
this.parent = biomes;
this.rivers = rivers;
this.subBiomeChooser = subBiomeChooser;
this.mBiomes = mBiomes;
this.initChunkSeed(0, 0);
if (ClimateControl.isBoPLoaded && doBoP) {
BoPSubBiomeReplacer = new BoPSubBiomeReplacer(randomCallback);
}
}
/**
* Returns a list of integer values generated by this layer. These may be interpreted as temperatures, rainfall
* amounts, or biomeList[] indices based on the particular GenLayer subclass.
*/
public int[] getInts(int par1, int par2, int par3, int par4) {
int[] biomeVals = this.parent.getInts(par1 - 1, par2 - 1, par3 + 2, par4 + 2);
int[] riverVals = this.rivers.getInts(par1 - 1, par2 - 1, par3 + 2, par4 + 2);
int[] aint2 = IntCache.getIntCache(par3 * par4);
poison(aint2, par3 * par4);
for (int i = 0; i < (par3 + 2) * (par4 + 2); i++) {
if (biomeVals[i] > 256) throw new RuntimeException("" + biomeVals[i]);
}
for (int i1 = 0; i1 < par4; ++i1) {
for (int j1 = 0; j1 < par3; ++j1) {
this.initChunkSeed((long) (j1 + par1), (long) (i1 + par2));
int biomeVal = biomeVals[j1 + 1 + (i1 + 1) * (par3 + 2)];
int riverVal = riverVals[j1 + 1 + (i1 + 1) * (par3 + 2)];
boolean flag = (riverVal - 2) % 29 == 0;
// logger.info("biome "+biomeVal);
if (biomeVal != 0 && riverVal >= 2 && (riverVal - 2) % 29 == 1 && biomeVal < 128) {
aint2[j1 + i1 * par3] = mBiomes.replacement(biomeVal);
// logger.info("Mbiome "+biomeVal + " to "+aint2[j1 + i1 * par3]);
} else if (this.nextInt(3) != 0 && !flag) {
aint2[j1 + i1 * par3] = biomeVal;
} else {
int i2 = this.subBiomeChooser.subBiome(biomeVal, randomCallback, j1 + par1, i1 + par2);
int j2;
if (flag && i2 != biomeVal) {
int newI2 = this.mBiomes.replacement(i2);
if (newI2 != i2) {
i2 = newI2;
} else {
i2 = biomeVal;
}
}
if (i2 == biomeVal) {
aint2[j1 + i1 * par3] = biomeVal;
} else {
j2 = biomeVals[j1 + 1 + (i1 + 1 - 1) * (par3 + 2)];
int k2 = biomeVals[j1 + 1 + 1 + (i1 + 1) * (par3 + 2)];
int l2 = biomeVals[j1 + 1 - 1 + (i1 + 1) * (par3 + 2)];
int i3 = biomeVals[j1 + 1 + (i1 + 1 + 1) * (par3 + 2)];
int j3 = 0;
if (compareBiomesById(j2, biomeVal)) {
++j3;
}
if (compareBiomesById(k2, biomeVal)) {
++j3;
}
if (compareBiomesById(l2, biomeVal)) {
++j3;
}
if (compareBiomesById(i3, biomeVal)) {
++j3;
}
if (j3 >= 3) {
aint2[j1 + i1 * par3] = i2;
} else {
aint2[j1 + i1 * par3] = biomeVal;
}
}
}
// now the GenLayerHills stuff is done so run BoP subbiome replacements if it's on
if (this.BoPSubBiomeReplacer != null) {
this.initChunkSeed(j1 + par1, i1 + par2);
aint2[j1 + i1 * par3] = BoPSubBiomeReplacer
.replacement(aint2[j1 + i1 * par3], randomCallback, j1 + par1, i1 + par2);
}
}
}
taste(aint2, par3 * par4);
return aint2;
}
}