Fixed crash when changing dungeon rarity
-Added biome selection
This commit is contained in:
parent
5a3a9ccf0a
commit
42e3ecd745
5 changed files with 2532 additions and 2546 deletions
|
|
@ -10,27 +10,24 @@ public class Config {
|
||||||
public static Configuration config;
|
public static Configuration config;
|
||||||
public static int RuinRarity;
|
public static int RuinRarity;
|
||||||
public static int DunRarity;
|
public static int DunRarity;
|
||||||
public static List<Integer> ruinAllowId = new ArrayList();
|
public static List<Integer>[] allowId = new ArrayList[4];
|
||||||
public static List<Integer> dungeonAllowId = new ArrayList();
|
public static final String[] allows = { "Ruin allowed dimension id", "Dungeon allowed dimension id", "Ruin allowed biome id", "Dungeon allowed biome id" };
|
||||||
|
|
||||||
public static void initialize(File file) {
|
public static void initialize(File file) {
|
||||||
config = new Configuration(file);
|
config = new Configuration(file);
|
||||||
config.load();
|
config.load();
|
||||||
RuinRarity = config.get("General", "Ruin Rarity", 2).getInt();
|
RuinRarity = config.get("General", "Ruin Rarity", 2, "Tries per chunk : lower to make rarer").getInt();
|
||||||
DunRarity = config.get("General", "Mystic Dungeon Rarity", 1).getInt();
|
DunRarity = config.get("General", "Mystic Dungeon Rarity", 1, "Tries per chunk : lower to make rarer").getInt();
|
||||||
String[] ID = config.get("General", "Ruin allowed dimension id", "0,").getString().split(",");
|
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").getString().split(",");
|
||||||
|
allowId[i] = new ArrayList();
|
||||||
for (String txt : ID) {
|
for (String txt : ID) {
|
||||||
try {
|
try {
|
||||||
ruinAllowId.add(Integer.parseInt(txt.trim()));
|
allowId[i].add(Integer.parseInt(txt.trim()));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ID = config.get("General", "Dungeon allowed dimension id", "0,").getString().split(",");
|
|
||||||
for (String txt : ID) {
|
|
||||||
try {
|
|
||||||
dungeonAllowId.add(Integer.parseInt(txt.trim()));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,30 +15,20 @@ public class StructureMysticDungeon extends WorldGenerator {
|
||||||
@Override
|
@Override
|
||||||
public boolean generate(World world, Random random, int i, int j, int k) {
|
public boolean generate(World world, Random random, int i, int j, int k) {
|
||||||
if (world.getWorldInfo().getTerrainType() != WorldType.FLAT) {
|
if (world.getWorldInfo().getTerrainType() != WorldType.FLAT) {
|
||||||
int l = random.nextInt(100);
|
|
||||||
if (l >= 4) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (int i1 = 0; i1 < 1; i1++) {
|
|
||||||
int j1 = (i + random.nextInt(8)) - random.nextInt(8);
|
int j1 = (i + random.nextInt(8)) - random.nextInt(8);
|
||||||
int k1 = (j + random.nextInt(4)) - random.nextInt(4);
|
int k1 = (j + random.nextInt(4)) - random.nextInt(4);
|
||||||
int l1 = (k + random.nextInt(8)) - random.nextInt(8);
|
int l1 = (k + random.nextInt(8)) - random.nextInt(8);
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
/*
|
if (k1 <= 0) {
|
||||||
* if (world.isAirBlock(j1 - 1, k1 + 1, l1) &&
|
return false;
|
||||||
* world.isAirBlock(j1 - 1, k1 + 1, l1 + 1) &&
|
}
|
||||||
* world.isAirBlock(j1 - 1, k1 + 2, l1) && world.isAirBlock(j1 -
|
if (world.isAirBlock(j1 - 1, k1 + 1, l1) && world.isAirBlock(j1 - 1, k1 + 1, l1 + 1) && world.isAirBlock(j1 - 1, k1 + 2, l1) && world.isAirBlock(j1 - 1, k1 + 2, l1 + 1)
|
||||||
* 1, k1 + 2, l1 + 1) && world.getBlockId(j1, k1, l1) ==
|
&& world.getBlockId(j1, k1, l1) == Block.stone.blockID && world.getBlockId(j1, k1, l1 + 1) == Block.stone.blockID && world.getBlockId(j1 - 1, k1, l1) == Block.stone.blockID
|
||||||
* Block.stone.blockID && world.getBlockId(j1, k1, l1 + 1) ==
|
&& world.getBlockId(j1 - 1, k1, l1 + 1) == Block.stone.blockID && world.getBlockId(j1, k1 + 1, l1) == Block.stone.blockID
|
||||||
* Block.stone.blockID && world.getBlockId(j1 - 1, k1, l1) ==
|
&& world.getBlockId(j1, k1 + 1, l1 + 1) == Block.stone.blockID)
|
||||||
* Block.stone.blockID && world.getBlockId(j1 - 1, k1, l1 + 1)
|
|
||||||
* == Block.stone.blockID && world.getBlockId(j1, k1 + 1, l1) ==
|
|
||||||
* Block.stone.blockID && world.getBlockId(j1, k1 + 1, l1 + 1)
|
|
||||||
* == Block.stone.blockID)
|
|
||||||
*/
|
|
||||||
flag = true;
|
flag = true;
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
continue;
|
return false;
|
||||||
}
|
}
|
||||||
world.setBlock(j1, k1 + 1, l1, 0);
|
world.setBlock(j1, k1 + 1, l1, 0);
|
||||||
world.setBlock(j1, k1 + 2, l1, 0);
|
world.setBlock(j1, k1 + 2, l1, 0);
|
||||||
|
|
@ -628,8 +618,8 @@ public class StructureMysticDungeon extends WorldGenerator {
|
||||||
world.setBlock(j1, k1 + 2, l1 - 5, Block.cobblestone.blockID);
|
world.setBlock(j1, k1 + 2, l1 - 5, Block.cobblestone.blockID);
|
||||||
int k7 = random.nextInt(100);
|
int k7 = random.nextInt(100);
|
||||||
if (k7 <= 30) {
|
if (k7 <= 30) {
|
||||||
world.setBlock(j1 - 2, k1 + 5, l1 - 2, 0);
|
|
||||||
world.setBlock(j1 - 2, k1 + 5, l1 - 3, 0);
|
world.setBlock(j1 - 2, k1 + 5, l1 - 3, 0);
|
||||||
|
world.setBlock(j1 - 2, k1 + 5, l1 - 2, 0);
|
||||||
world.setBlock(j1 - 2, k1 + 5, l1 - 1, 0);
|
world.setBlock(j1 - 2, k1 + 5, l1 - 1, 0);
|
||||||
world.setBlock(j1 - 1, k1 + 5, l1 - 2, 0);
|
world.setBlock(j1 - 1, k1 + 5, l1 - 2, 0);
|
||||||
world.setBlock(j1 - 3, k1 + 5, l1 - 2, 0);
|
world.setBlock(j1 - 3, k1 + 5, l1 - 2, 0);
|
||||||
|
|
@ -1807,7 +1797,7 @@ public class StructureMysticDungeon extends WorldGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i8 != 2) {
|
if (i8 != 2) {
|
||||||
continue;
|
return true;
|
||||||
}
|
}
|
||||||
for (int y = 0; y < 4; y++) {
|
for (int y = 0; y < 4; y++) {
|
||||||
world.setBlock(j1 - 1, k1 - 10 - y, l1, Block.blockNetherQuartz.blockID, 2, 2);
|
world.setBlock(j1 - 1, k1 - 10 - y, l1, Block.blockNetherQuartz.blockID, 2, 2);
|
||||||
|
|
@ -1876,8 +1866,6 @@ public class StructureMysticDungeon extends WorldGenerator {
|
||||||
world.setBlock(j1 - 8, k1 - 10, l1 - 4, Block.blockNetherQuartz.blockID, 2, 2);
|
world.setBlock(j1 - 8, k1 - 10, l1 - 4, Block.blockNetherQuartz.blockID, 2, 2);
|
||||||
world.setBlock(j1 - 8, k1 - 10, l1 - 2, Block.blockNetherQuartz.blockID, 2, 2);
|
world.setBlock(j1 - 8, k1 - 10, l1 - 2, Block.blockNetherQuartz.blockID, 2, 2);
|
||||||
}
|
}
|
||||||
System.out.println((j1 - 8) + "," + (k1 - 10) + "," + (l1 - 2));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,16 +14,14 @@ public class StructureRuin$1 extends WorldGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean generate(World world, Random random, int i, int j, int k) {
|
public boolean generate(World world, Random random, int i, int j, int k) {
|
||||||
int l = random.nextInt(100);
|
|
||||||
if (l >= 10) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (int i1 = 0; i1 < 1; i1++) {
|
|
||||||
int j1 = (i + random.nextInt(8)) - random.nextInt(8);
|
int j1 = (i + random.nextInt(8)) - random.nextInt(8);
|
||||||
int k1 = (j + random.nextInt(4)) - random.nextInt(4);
|
int k1 = (j + random.nextInt(4)) - random.nextInt(4);
|
||||||
int l1 = (k + random.nextInt(8)) - random.nextInt(8);
|
int l1 = (k + random.nextInt(8)) - random.nextInt(8);
|
||||||
|
if (k1 <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!world.isAirBlock(j1, k1, l1) || world.getBlockId(j1, k1 - 1, l1) != Block.grass.blockID || !Block.pumpkin.canPlaceBlockAt(world, j1, k1, l1)) {
|
if (!world.isAirBlock(j1, k1, l1) || world.getBlockId(j1, k1 - 1, l1) != Block.grass.blockID || !Block.pumpkin.canPlaceBlockAt(world, j1, k1, l1)) {
|
||||||
continue;
|
return false;
|
||||||
}
|
}
|
||||||
int i2 = random.nextInt(3) + 1;
|
int i2 = random.nextInt(3) + 1;
|
||||||
if (i2 == 1) {
|
if (i2 == 1) {
|
||||||
|
|
@ -275,7 +273,7 @@ public class StructureRuin$1 extends WorldGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i2 != 3) {
|
if (i2 != 3) {
|
||||||
continue;
|
return true;
|
||||||
}
|
}
|
||||||
int l2 = random.nextInt(8) + 5;
|
int l2 = random.nextInt(8) + 5;
|
||||||
int k3 = random.nextInt(8) + 5;
|
int k3 = random.nextInt(8) + 5;
|
||||||
|
|
@ -313,8 +311,7 @@ public class StructureRuin$1 extends WorldGenerator {
|
||||||
flag2 = false;
|
flag2 = false;
|
||||||
do {
|
do {
|
||||||
if (world.isAirBlock(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 2) || world.isAirBlock(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 3) || world.isAirBlock(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 4)
|
if (world.isAirBlock(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 2) || world.isAirBlock(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 3) || world.isAirBlock(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 4)
|
||||||
|| world.getBlockId(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 2) == Block.waterStill.blockID
|
|| world.getBlockId(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 2) == Block.waterStill.blockID || world.getBlockId(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 3) == Block.waterStill.blockID
|
||||||
|| world.getBlockId(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 3) == Block.waterStill.blockID
|
|
||||||
|| world.getBlockId(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 4) == Block.waterStill.blockID) {
|
|| world.getBlockId(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 4) == Block.waterStill.blockID) {
|
||||||
k6++;
|
k6++;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -429,7 +426,6 @@ public class StructureRuin$1 extends WorldGenerator {
|
||||||
world.setBlock(j1 - 3, k1 - l5 - k6 - i5, l1 + k3 + 3, Block.chest.blockID);
|
world.setBlock(j1 - 3, k1 - l5 - k6 - i5, l1 + k3 + 3, Block.chest.blockID);
|
||||||
ChestFiller.fillWithRares(world.getBlockTileEntity(j1 - 3, k1 - l5 - k6 - i5, l1 + k3 + 3));
|
ChestFiller.fillWithRares(world.getBlockTileEntity(j1 - 3, k1 - l5 - k6 - i5, l1 + k3 + 3));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,16 +14,14 @@ public class StructureRuin extends WorldGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean generate(World world, Random random, int i, int j, int k) {
|
public boolean generate(World world, Random random, int i, int j, int k) {
|
||||||
int l = random.nextInt(100);
|
|
||||||
if (l >= 10) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (int i1 = 0; i1 < 1; i1++) {
|
|
||||||
int j1 = (i + random.nextInt(8)) - random.nextInt(8);
|
int j1 = (i + random.nextInt(8)) - random.nextInt(8);
|
||||||
int k1 = (j + random.nextInt(4)) - random.nextInt(4);
|
int k1 = (j + random.nextInt(4)) - random.nextInt(4);
|
||||||
int l1 = (k + random.nextInt(8)) - random.nextInt(8);
|
int l1 = (k + random.nextInt(8)) - random.nextInt(8);
|
||||||
|
if (k1 <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!world.isAirBlock(j1, k1, l1) || world.getBlockId(j1, k1 - 1, l1) != Block.grass.blockID || !Block.pumpkin.canPlaceBlockAt(world, j1, k1, l1)) {
|
if (!world.isAirBlock(j1, k1, l1) || world.getBlockId(j1, k1 - 1, l1) != Block.grass.blockID || !Block.pumpkin.canPlaceBlockAt(world, j1, k1, l1)) {
|
||||||
continue;
|
return false;
|
||||||
}
|
}
|
||||||
int i2 = random.nextInt(3) + 1;
|
int i2 = random.nextInt(3) + 1;
|
||||||
if (i2 == 1) {
|
if (i2 == 1) {
|
||||||
|
|
@ -274,7 +272,7 @@ public class StructureRuin extends WorldGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i2 != 3) {
|
if (i2 != 3) {
|
||||||
continue;
|
return true;
|
||||||
}
|
}
|
||||||
int l2 = random.nextInt(8) + 5;
|
int l2 = random.nextInt(8) + 5;
|
||||||
int k3 = random.nextInt(8) + 5;
|
int k3 = random.nextInt(8) + 5;
|
||||||
|
|
@ -312,8 +310,7 @@ public class StructureRuin extends WorldGenerator {
|
||||||
flag2 = false;
|
flag2 = false;
|
||||||
do {
|
do {
|
||||||
if (world.isAirBlock(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 2) || world.isAirBlock(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 3) || world.isAirBlock(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 4)
|
if (world.isAirBlock(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 2) || world.isAirBlock(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 3) || world.isAirBlock(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 4)
|
||||||
|| world.getBlockId(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 2) == Block.waterStill.blockID
|
|| world.getBlockId(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 2) == Block.waterStill.blockID || world.getBlockId(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 3) == Block.waterStill.blockID
|
||||||
|| world.getBlockId(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 3) == Block.waterStill.blockID
|
|
||||||
|| world.getBlockId(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 4) == Block.waterStill.blockID) {
|
|| world.getBlockId(j1 + k3 + l2, k1 - l5 - j7, l1 + j4 + 4) == Block.waterStill.blockID) {
|
||||||
k6++;
|
k6++;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -428,7 +425,6 @@ public class StructureRuin extends WorldGenerator {
|
||||||
world.setBlock(j1 - 3, k1 - l5 - k6 - i5, l1 + k3 + 3, Block.chest.blockID);
|
world.setBlock(j1 - 3, k1 - l5 - k6 - i5, l1 + k3 + 3, Block.chest.blockID);
|
||||||
ChestFiller.fillWithRares(world.getBlockTileEntity(j1 - 3, k1 - l5 - k6 - i5, l1 + k3 + 3));
|
ChestFiller.fillWithRares(world.getBlockTileEntity(j1 - 3, k1 - l5 - k6 - i5, l1 + k3 + 3));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,30 +14,39 @@ public class WorldGenMystic implements IWorldGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
|
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
|
||||||
if (Config.ruinAllowId.contains(world.provider.dimensionId)) {
|
if (Config.allowId[0].contains(world.provider.dimensionId)) {
|
||||||
generateRuins(world, random, chunkX * 16, chunkZ * 16);
|
generateRuins(world, random, chunkX * 16, chunkZ * 16);
|
||||||
}
|
}
|
||||||
if (Config.dungeonAllowId.contains(world.provider.dimensionId)) {
|
if (Config.allowId[1].contains(world.provider.dimensionId)) {
|
||||||
generateDungeon(world, random, chunkX * 16, chunkZ * 16);
|
generateDungeon(world, random, chunkX * 16, chunkZ * 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateDungeon(World world, Random random, int blockX, int blockZ) {
|
private void generateDungeon(World world, Random random, int blockX, int blockZ) {
|
||||||
|
int Xcoord1, Ycoord1, Zcoord1;
|
||||||
for (int i = 0; i < Config.DunRarity; i++) {
|
for (int i = 0; i < Config.DunRarity; i++) {
|
||||||
int Xcoord1 = blockX + random.nextInt(16) + 8;
|
Xcoord1 = blockX + random.nextInt(16) + 8;
|
||||||
int Ycoord1 = random.nextInt(9) + 28;
|
Ycoord1 = random.nextInt(9) + 28;
|
||||||
int Zcoord1 = blockZ + random.nextInt(16) + 8;
|
Zcoord1 = blockZ + random.nextInt(16) + 8;
|
||||||
dungeon.generate(world, random, Xcoord1, Ycoord1, Zcoord1);
|
if (!Config.allowId[3].contains(world.getBiomeGenForCoords(Xcoord1, Zcoord1).biomeID)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (dungeon.generate(world, random, Xcoord1, Ycoord1, Zcoord1))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateRuins(World world, Random random, int blockX, int blockZ) {
|
private void generateRuins(World world, Random random, int blockX, int blockZ) {
|
||||||
|
int Xcoord1, Ycoord1, Zcoord1;
|
||||||
for (int i = 0; i < Config.RuinRarity; i++) {
|
for (int i = 0; i < Config.RuinRarity; i++) {
|
||||||
int Xcoord1 = blockX + random.nextInt(16) + 8;
|
Xcoord1 = blockX + random.nextInt(16) + 8;
|
||||||
int Ycoord1 = random.nextInt(11) + 60;
|
Ycoord1 = random.nextInt(11) + 60;
|
||||||
int Zcoord1 = blockZ + random.nextInt(16) + 8;
|
Zcoord1 = blockZ + random.nextInt(16) + 8;
|
||||||
ruin.generate(world, random, Xcoord1, Ycoord1, Zcoord1);
|
if (!Config.allowId[2].contains(world.getBiomeGenForCoords(Xcoord1, Zcoord1).biomeID)) {
|
||||||
ruin1.generate(world, random, Xcoord1, Ycoord1, Zcoord1);
|
continue;
|
||||||
|
}
|
||||||
|
if (ruin.generate(world, random, Xcoord1, Ycoord1, Zcoord1) || ruin1.generate(world, random, Xcoord1, Ycoord1, Zcoord1))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue