2011-01-30 22:53:57 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
import org.bukkit.BlockChangeDelegate; // CraftBukkit
|
2011-01-30 22:53:57 +01:00
|
|
|
|
2012-03-16 07:32:25 +01:00
|
|
|
public class WorldGenTaiga1 extends WorldGenerator implements BlockSapling.TreeGenerator { // CraftBukkit add interface
|
2011-01-30 22:53:57 +01:00
|
|
|
|
|
|
|
public WorldGenTaiga1() {}
|
|
|
|
|
|
|
|
public boolean a(World world, Random random, int i, int j, int k) {
|
2012-07-29 09:33:13 +02:00
|
|
|
// CraftBukkit start - moved to generate
|
2011-06-27 00:25:01 +02:00
|
|
|
return this.generate((BlockChangeDelegate) world, random, i, j, k);
|
2011-01-30 22:53:57 +01:00
|
|
|
}
|
2011-02-02 00:32:18 +01:00
|
|
|
|
2011-01-30 22:53:57 +01:00
|
|
|
public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k) {
|
|
|
|
// CraftBukkit end
|
|
|
|
int l = random.nextInt(5) + 7;
|
|
|
|
int i1 = l - random.nextInt(2) - 3;
|
|
|
|
int j1 = l - i1;
|
|
|
|
int k1 = 1 + random.nextInt(j1 + 1);
|
|
|
|
boolean flag = true;
|
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
if (j >= 1 && j + l + 1 <= 128) {
|
2011-11-20 09:01:14 +01:00
|
|
|
int l1;
|
|
|
|
int i2;
|
|
|
|
int j2;
|
|
|
|
int k2;
|
|
|
|
int l2;
|
|
|
|
|
|
|
|
for (l1 = j; l1 <= j + 1 + l && flag; ++l1) {
|
|
|
|
boolean flag1 = true;
|
|
|
|
|
|
|
|
if (l1 - j < i1) {
|
|
|
|
l2 = 0;
|
|
|
|
} else {
|
|
|
|
l2 = k1;
|
|
|
|
}
|
2011-01-30 22:53:57 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (i2 = i - l2; i2 <= i + l2 && flag; ++i2) {
|
|
|
|
for (j2 = k - l2; j2 <= k + l2 && flag; ++j2) {
|
2012-03-01 11:49:23 +01:00
|
|
|
if (l1 >= 0 && l1 < 128) {
|
2011-11-20 09:01:14 +01:00
|
|
|
k2 = world.getTypeId(i2, l1, j2);
|
|
|
|
if (k2 != 0 && k2 != Block.LEAVES.id) {
|
|
|
|
flag = false;
|
2011-01-30 22:53:57 +01:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
} else {
|
2011-01-30 22:53:57 +01:00
|
|
|
flag = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-01-30 22:53:57 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (!flag) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
l1 = world.getTypeId(i, j - 1, k);
|
2012-03-01 11:49:23 +01:00
|
|
|
if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < 128 - l - 1) {
|
2012-03-22 21:39:39 +01:00
|
|
|
this.setType(world, i, j - 1, k, Block.DIRT.id);
|
2011-11-20 09:01:14 +01:00
|
|
|
l2 = 0;
|
2011-01-30 22:53:57 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (i2 = j + l; i2 >= j + i1; --i2) {
|
|
|
|
for (j2 = i - l2; j2 <= i + l2; ++j2) {
|
|
|
|
k2 = j2 - i;
|
2011-01-30 22:53:57 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (int i3 = k - l2; i3 <= k + l2; ++i3) {
|
|
|
|
int j3 = i3 - k;
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
if ((Math.abs(k2) != l2 || Math.abs(j3) != l2 || l2 <= 0) && !Block.n[world.getTypeId(j2, i2, i3)]) {
|
2012-03-22 21:39:39 +01:00
|
|
|
this.setTypeAndData(world, j2, i2, i3, Block.LEAVES.id, 1);
|
2011-01-30 22:53:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (l2 >= 1 && i2 == j + i1 + 1) {
|
|
|
|
--l2;
|
|
|
|
} else if (l2 < k1) {
|
|
|
|
++l2;
|
2011-01-30 22:53:57 +01:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-01-30 22:53:57 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (i2 = 0; i2 < l - 1; ++i2) {
|
|
|
|
j2 = world.getTypeId(i, j + i2, k);
|
|
|
|
if (j2 == 0 || j2 == Block.LEAVES.id) {
|
2012-03-22 21:39:39 +01:00
|
|
|
this.setTypeAndData(world, i, j + i2, k, Block.LOG.id, 1);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-30 22:53:57 +01:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
} else {
|
|
|
|
return false;
|
2011-01-30 22:53:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|