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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
package bloodasp.galacticgreg.dynconfig;
import java.util.HashMap;
import java.util.Map;
import net.minecraftforge.common.ChestGenHooks;
import bloodasp.galacticgreg.GalacticGreg;
import bloodasp.galacticgreg.api.Enums.DimensionType;
import bloodasp.galacticgreg.api.ModContainer;
import bloodasp.galacticgreg.api.ModDimensionDef;
import bloodasp.galacticgreg.registry.GalacticGregRegistry;
import gregtech.api.GregTech_API;
/**
* This dynamic config is different to the OreMix one. This is used/bound to the ModDimensionDef, and the
* OreMixWorldConfig is bound to the veins. Don't get confused!
*
*/
public class DynamicDimensionConfig {
public static class AsteroidConfig {
public int MinSize;
public int MaxSize;
public int Probability;
public int OreChance;
public int OrePrimaryOffset;
public int SpecialBlockChance;
public int SmallOreChance;
public boolean ObeyHeightLimits;
public int OreGenMaxY;
public int FloatingAsteroidMinY;
public boolean HiddenOres;
public int LootChestChance;
public int LootChestTable;
public int NumLootItems;
public boolean RandomizeNumLootItems;
}
private static Map<String, AsteroidConfig> _mDynamicAsteroidMap = new HashMap<>();
private static String getConfigKeyName(ModContainer pMC, ModDimensionDef pMDD) {
return String.format("galacticgreg.asteroids.%s.%s", pMC.getModName(), pMDD.getDimensionName());
}
private static String getConfigKeyName(ModContainer pMC, ModDimensionDef pMDD, String pSubCat) {
return String.format("%s.%s", getConfigKeyName(pMC, pMDD), pSubCat);
}
public static AsteroidConfig getAsteroidConfig(ModDimensionDef pDimDef) {
return _mDynamicAsteroidMap.getOrDefault(pDimDef.getDimIdentifier(), null);
}
public static boolean InitDynamicConfig() {
try {
for (ModContainer mc : GalacticGregRegistry.getModContainers()) {
if (!mc.getEnabled()) continue;
for (ModDimensionDef mdd : mc.getDimensionList()) {
DimensionType dt = mdd.getDimensionType();
if (dt == DimensionType.Asteroid || dt == DimensionType.AsteroidAndPlanet) {
String tDimIdentifier = mdd.getDimIdentifier();
if (_mDynamicAsteroidMap.containsKey(tDimIdentifier)) GalacticGreg.Logger.warn(
"Found 2 Dimensions with the same Identifier! This should never happen, and you should report this to me. Identifier in question: %s",
tDimIdentifier);
else {
AsteroidConfig aConf = new AsteroidConfig();
aConf.MinSize = GregTech_API.sWorldgenFile.get(getConfigKeyName(mc, mdd), "SizeMin", 5);
aConf.MaxSize = GregTech_API.sWorldgenFile.get(getConfigKeyName(mc, mdd), "SizeMax", 15);
aConf.Probability = GregTech_API.sWorldgenFile
.get(getConfigKeyName(mc, mdd), "Probability", 200);
aConf.SpecialBlockChance = GregTech_API.sWorldgenFile
.get(getConfigKeyName(mc, mdd), "SpecialBlockChance", 5);
aConf.OreChance = GregTech_API.sWorldgenFile
.get(getConfigKeyName(mc, mdd, "orespawn"), "BaseOreChance", 5);
aConf.OrePrimaryOffset = GregTech_API.sWorldgenFile
.get(getConfigKeyName(mc, mdd, "orespawn"), "PrimaryToRareOreOffset", 5);
aConf.SmallOreChance = GregTech_API.sWorldgenFile
.get(getConfigKeyName(mc, mdd, "orespawn"), "SmallOreChance", 10);
aConf.ObeyHeightLimits = GregTech_API.sWorldgenFile
.get(getConfigKeyName(mc, mdd, "orespawn"), "ObeyHeightLimits", false);
aConf.HiddenOres = GregTech_API.sWorldgenFile
.get(getConfigKeyName(mc, mdd, "orespawn"), "OresOnlyInsideAsteroids", false);
if (GalacticGreg.GalacticConfig.LootChestsEnabled) {
aConf.LootChestChance = GregTech_API.sWorldgenFile
.get(getConfigKeyName(mc, mdd, "loot"), "LootChestChance", 1);
aConf.LootChestTable = GregTech_API.sWorldgenFile
.get(getConfigKeyName(mc, mdd, "loot"), "LootChestTable", 3);
aConf.NumLootItems = GregTech_API.sWorldgenFile
.get(getConfigKeyName(mc, mdd, "loot"), "LootChestItemCount", 10);
aConf.RandomizeNumLootItems = GregTech_API.sWorldgenFile
.get(getConfigKeyName(mc, mdd, "loot"), "RandomizeLootItemCount", true);
} else {
aConf.LootChestChance = 0;
aConf.LootChestTable = 1;
aConf.NumLootItems = 0;
aConf.RandomizeNumLootItems = false;
}
if (dt == DimensionType.AsteroidAndPlanet) {
int tDefaultMaxY = mdd.getPreConfiguratedGroundOreMaxY();
int tDefaultMinY = mdd.getPreConfiguratedFloatingAsteroidMinY();
aConf.OreGenMaxY = GregTech_API.sWorldgenFile
.get(getConfigKeyName(mc, mdd, "floating"), "OreGenMaxY", tDefaultMaxY);
aConf.FloatingAsteroidMinY = GregTech_API.sWorldgenFile
.get(getConfigKeyName(mc, mdd, "floating"), "FloatingAsteroidMinY", tDefaultMinY);
}
if (aConf.MaxSize > 50) GalacticGreg.Logger.warn(
"Asteroid-MaxSize for dimID [%s] is larger than 50. This might cause memory-problems, as the maximum asteroid size will be larger than 50*50*50 blocks",
tDimIdentifier);
_mDynamicAsteroidMap.put(tDimIdentifier, aConf);
}
}
}
}
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
/**
* Convert numbers to actual loot-table entries
*
* @param pACfg
* @return
*/
public static String getLootChestTable(AsteroidConfig pACfg) {
String tLootTable = ChestGenHooks.MINESHAFT_CORRIDOR;
switch (pACfg.LootChestTable) {
case 2:
tLootTable = ChestGenHooks.PYRAMID_DESERT_CHEST;
break;
case 3:
tLootTable = ChestGenHooks.PYRAMID_JUNGLE_CHEST;
break;
case 4:
tLootTable = ChestGenHooks.PYRAMID_JUNGLE_DISPENSER;
break;
case 5:
tLootTable = ChestGenHooks.STRONGHOLD_CORRIDOR;
break;
case 6:
tLootTable = ChestGenHooks.STRONGHOLD_LIBRARY;
break;
case 7:
tLootTable = ChestGenHooks.STRONGHOLD_CROSSING;
break;
case 8:
tLootTable = ChestGenHooks.VILLAGE_BLACKSMITH;
break;
case 9:
tLootTable = ChestGenHooks.BONUS_CHEST;
break;
case 10:
tLootTable = ChestGenHooks.DUNGEON_CHEST;
break;
}
return tLootTable;
}
}
|