Improved biome selection system
This commit is contained in:
parent
006de315b4
commit
33fa173cbb
3 changed files with 1796 additions and 1763 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package mysticruins;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
|
@ -15,37 +16,63 @@ public class Config {
|
|||
public static int DunRarity;
|
||||
public static Set<Integer>[] allowId = new HashSet[4];
|
||||
public static final String[] allows = { "Ruin allowed dimension id", "Dungeon allowed dimension id", "Ruin allowed biome id", "Dungeon allowed biome id" };
|
||||
public static Set<Type>[] allowType = new HashSet[2];
|
||||
|
||||
public static void initialize(File file) {
|
||||
config = new Configuration(file);
|
||||
config.load();
|
||||
StringBuilder build = new StringBuilder("Available biome tags are: ");
|
||||
for (Type t : Type.values()) {
|
||||
build.append(t);
|
||||
build.append(",");
|
||||
}
|
||||
config.addCustomCategoryComment("General", build.toString());
|
||||
RuinRarity = config.get("General", "Ruin Rarity", 2, "Tries per chunk : lower to make rarer").getInt();
|
||||
DunRarity = config.get("General", "Mystic Dungeon Rarity", 1, "Tries per chunk : lower to make rarer").getInt();
|
||||
String[] ID;
|
||||
for (int i = 0; i < allows.length; i++) {
|
||||
ID = config.get("General", allows[i], i < 2 ? "0," : "1,2,3,4,5,6,7,21,22", i < 2 ? "" : "Use ALL or * for all biomes, biome id or biome tags").getString().split(",");
|
||||
ID = config.get("General", allows[i], i < 2 ? "0," : "ALL,-WATER", i < 2 ? "" : "Use ALL or * for all biomes, select with biome id or biome tags, prefix with - to exclude").getString()
|
||||
.split(",");
|
||||
allowId[i] = new HashSet();
|
||||
if (i > 1) {
|
||||
allowType[i - 2] = new HashSet();
|
||||
}
|
||||
for (String txt : ID) {
|
||||
try {
|
||||
allowId[i].add(Integer.parseInt(txt.trim()));
|
||||
} catch (NumberFormatException e) {
|
||||
if (i > 1) {
|
||||
if (txt.equals("*") || txt.equalsIgnoreCase("ALL")) {
|
||||
allowId[i].clear();
|
||||
for (BiomeGenBase biome : BiomeGenBase.biomeList) {
|
||||
if (biome != null) {
|
||||
allowId[i].add(biome.biomeID);
|
||||
if (txt.startsWith("-") && i > 1) {
|
||||
txt = txt.substring(1).trim();
|
||||
try {
|
||||
allowId[i].remove(Integer.parseInt(txt));
|
||||
} catch (NumberFormatException e) {
|
||||
try {
|
||||
allowType[i - 2].remove(Type.valueOf(txt.toUpperCase()));
|
||||
} catch (IllegalArgumentException l) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
int j = Integer.parseInt(txt.trim());
|
||||
allowId[i].add(j);
|
||||
if (i > 1) {
|
||||
allowType[i - 2].addAll(Arrays.asList(BiomeDictionary.getTypesForBiome(BiomeGenBase.biomeList[j])));
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
if (i > 1) {
|
||||
if (txt.equals("*") || txt.equalsIgnoreCase("ALL")) {
|
||||
for (int j = 0; j < BiomeGenBase.biomeList.length; j++) {
|
||||
allowId[i].add(j);
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
try {
|
||||
for (BiomeGenBase biome : BiomeDictionary.getBiomesForType(Type.valueOf(txt.toUpperCase()))) {
|
||||
if (biome != null) {
|
||||
for (Type t : Type.values()) {
|
||||
allowType[i - 2].add(t);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Type type = Type.valueOf(txt.toUpperCase());
|
||||
allowType[i - 2].add(type);
|
||||
for (BiomeGenBase biome : BiomeDictionary.getBiomesForType(type)) {
|
||||
allowId[i].add(biome.biomeID);
|
||||
}
|
||||
} catch (IllegalArgumentException l) {
|
||||
}
|
||||
} catch (IllegalArgumentException l) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,10 +1,14 @@
|
|||
package mysticruins;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
|
||||
public class WorldGenMystic implements IWorldGenerator {
|
||||
|
|
@ -17,6 +21,9 @@ public class WorldGenMystic implements IWorldGenerator {
|
|||
if (Config.allowId[0].contains(world.provider.dimensionId)) {
|
||||
generateRuins(world, random, chunkX * 16, chunkZ * 16);
|
||||
}
|
||||
if (world.getWorldInfo().getTerrainType() == WorldType.FLAT) {
|
||||
return;
|
||||
}
|
||||
if (Config.allowId[1].contains(world.provider.dimensionId)) {
|
||||
generateDungeon(world, random, chunkX * 16, chunkZ * 16);
|
||||
}
|
||||
|
|
@ -24,29 +31,31 @@ public class WorldGenMystic implements IWorldGenerator {
|
|||
|
||||
private void generateDungeon(World world, Random random, int blockX, int blockZ) {
|
||||
int Xcoord1, Ycoord1, Zcoord1;
|
||||
BiomeGenBase biome;
|
||||
for (int i = 0; i < Config.DunRarity; i++) {
|
||||
Xcoord1 = blockX + random.nextInt(16) + 8;
|
||||
Ycoord1 = random.nextInt(9) + 28;
|
||||
Zcoord1 = blockZ + random.nextInt(16) + 8;
|
||||
if (!Config.allowId[3].contains(world.getBiomeGenForCoords(Xcoord1, Zcoord1).biomeID)) {
|
||||
continue;
|
||||
biome = world.getBiomeGenForCoords(Xcoord1, Zcoord1);
|
||||
if (Config.allowId[3].contains(biome.biomeID) && Config.allowType[1].containsAll(Arrays.asList(BiomeDictionary.getTypesForBiome(biome)))) {
|
||||
if (dungeon.generate(world, random, Xcoord1, Ycoord1, Zcoord1))
|
||||
break;
|
||||
}
|
||||
if (dungeon.generate(world, random, Xcoord1, Ycoord1, Zcoord1))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void generateRuins(World world, Random random, int blockX, int blockZ) {
|
||||
int Xcoord1, Ycoord1, Zcoord1;
|
||||
BiomeGenBase biome;
|
||||
for (int i = 0; i < Config.RuinRarity; i++) {
|
||||
Xcoord1 = blockX + random.nextInt(16) + 8;
|
||||
Ycoord1 = random.nextInt(11) + 60;
|
||||
Zcoord1 = blockZ + random.nextInt(16) + 8;
|
||||
if (!Config.allowId[2].contains(world.getBiomeGenForCoords(Xcoord1, Zcoord1).biomeID)) {
|
||||
continue;
|
||||
biome = world.getBiomeGenForCoords(Xcoord1, Zcoord1);
|
||||
if (Config.allowId[2].contains(biome.biomeID) && Config.allowType[0].containsAll(Arrays.asList(BiomeDictionary.getTypesForBiome(biome)))) {
|
||||
if (ruin.generate(world, random, Xcoord1, Ycoord1, Zcoord1) || ruin1.generate(world, random, Xcoord1, Ycoord1, Zcoord1))
|
||||
break;
|
||||
}
|
||||
if (ruin.generate(world, random, Xcoord1, Ycoord1, Zcoord1) || ruin1.generate(world, random, Xcoord1, Ycoord1, Zcoord1))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue