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
|
|
|
|
|
|
|
public class WorldGenTaiga2 extends WorldGenerator {
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public WorldGenTaiga2(boolean flag) {
|
|
|
|
super(flag);
|
|
|
|
}
|
2011-01-30 22:53:57 +01:00
|
|
|
|
|
|
|
public boolean a(World world, Random random, int i, int j, int k) {
|
|
|
|
// CraftBukkit start
|
|
|
|
// sk: The idea is to have (our) WorldServer implement
|
|
|
|
// BlockChangeDelegate and then we can implicitly cast World to
|
|
|
|
// WorldServer (a safe cast, AFAIK) and no code will be broken. This
|
|
|
|
// then allows plugins to catch manually-invoked generation events
|
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(4) + 6;
|
|
|
|
int i1 = 1 + random.nextInt(2);
|
|
|
|
int j1 = l - i1;
|
|
|
|
int k1 = 2 + random.nextInt(2);
|
|
|
|
boolean flag = true;
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (j >= 1 && j + l + 1 <= world.getHeight()) { // CraftBukkit
|
|
|
|
int l1;
|
|
|
|
int i2;
|
|
|
|
int j2;
|
|
|
|
int k2;
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (l1 = j; l1 <= j + 1 + l && flag; ++l1) {
|
|
|
|
boolean flag1 = true;
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (l1 - j < i1) {
|
|
|
|
k2 = 0;
|
|
|
|
} else {
|
|
|
|
k2 = k1;
|
|
|
|
}
|
2011-01-30 22:53:57 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (i2 = i - k2; i2 <= i + k2 && flag; ++i2) {
|
|
|
|
for (int l2 = k - k2; l2 <= k + k2 && flag; ++l2) {
|
|
|
|
if (l1 >= 0 && l1 < world.getHeight()) { // CraftBukkit
|
|
|
|
j2 = world.getTypeId(i2, l1, l2);
|
|
|
|
if (j2 != 0 && j2 != 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);
|
|
|
|
if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < world.getHeight() - l - 1) { // CraftBukkit
|
|
|
|
world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
|
|
|
|
k2 = random.nextInt(2);
|
|
|
|
i2 = 1;
|
|
|
|
byte b0 = 0;
|
2011-01-30 22:53:57 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
int i3;
|
|
|
|
int j3;
|
2011-01-30 22:53:57 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (j2 = 0; j2 <= j1; ++j2) {
|
|
|
|
j3 = j + l - j2;
|
2011-01-30 22:53:57 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (i3 = i - k2; i3 <= i + k2; ++i3) {
|
|
|
|
int k3 = i3 - i;
|
2011-01-30 22:53:57 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (int l3 = k - k2; l3 <= k + k2; ++l3) {
|
|
|
|
int i4 = l3 - k;
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if ((Math.abs(k3) != k2 || Math.abs(i4) != k2 || k2 <= 0) && !Block.o[world.getTypeId(i3, j3, l3)]) {
|
|
|
|
this.a(world, i3, j3, l3, Block.LEAVES.id, 1);
|
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
|
|
|
if (k2 >= i2) {
|
|
|
|
k2 = b0;
|
|
|
|
b0 = 1;
|
|
|
|
++i2;
|
|
|
|
if (i2 > k1) {
|
|
|
|
i2 = k1;
|
2011-01-30 22:53:57 +01:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
} else {
|
|
|
|
++k2;
|
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
|
|
|
j2 = random.nextInt(3);
|
2011-01-30 22:53:57 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (j3 = 0; j3 < l - j2; ++j3) {
|
|
|
|
i3 = world.getTypeId(i, j + j3, k);
|
|
|
|
if (i3 == 0 || i3 == Block.LEAVES.id) {
|
|
|
|
this.a(world, i, j + j3, k, Block.LOG.id, 1);
|
2011-01-30 22:53:57 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|