mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-11 02:02:04 -07:00
Updated CraftBukkit to 1.2
This commit is contained in:
@@ -6,8 +6,21 @@ import org.bukkit.BlockChangeDelegate; // CraftBukkit
|
||||
|
||||
public class WorldGenTrees extends WorldGenerator {
|
||||
|
||||
private final int a;
|
||||
private final boolean b;
|
||||
private final int c;
|
||||
private final int d;
|
||||
|
||||
public WorldGenTrees(boolean flag) {
|
||||
this(flag, 4, 0, 0, false);
|
||||
}
|
||||
|
||||
public WorldGenTrees(boolean flag, int i, int j, int k, boolean flag1) {
|
||||
super(flag);
|
||||
this.a = i;
|
||||
this.c = j;
|
||||
this.d = k;
|
||||
this.b = flag1;
|
||||
}
|
||||
|
||||
public boolean a(World world, Random random, int i, int j, int k) {
|
||||
@@ -21,18 +34,17 @@ public class WorldGenTrees extends WorldGenerator {
|
||||
|
||||
public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k) {
|
||||
// CraftBukkit end
|
||||
int l = random.nextInt(3) + 4;
|
||||
int l = random.nextInt(3) + this.a;
|
||||
boolean flag = true;
|
||||
|
||||
if (j >= 1 && j + l + 1 <= world.getHeight()) { // CraftBukkit
|
||||
if (j >= 1 && j + l + 1 <= 256) {
|
||||
int i1;
|
||||
byte b0;
|
||||
int j1;
|
||||
int k1;
|
||||
int l1;
|
||||
|
||||
for (i1 = j; i1 <= j + 1 + l; ++i1) {
|
||||
byte b0 = 1;
|
||||
|
||||
b0 = 1;
|
||||
if (i1 == j) {
|
||||
b0 = 0;
|
||||
}
|
||||
@@ -41,11 +53,11 @@ public class WorldGenTrees extends WorldGenerator {
|
||||
b0 = 2;
|
||||
}
|
||||
|
||||
for (j1 = i - b0; j1 <= i + b0 && flag; ++j1) {
|
||||
for (k1 = k - b0; k1 <= k + b0 && flag; ++k1) {
|
||||
if (i1 >= 0 && i1 < world.getHeight()) { // CraftBukkit
|
||||
l1 = world.getTypeId(j1, i1, k1);
|
||||
if (l1 != 0 && l1 != Block.LEAVES.id) {
|
||||
for (int l1 = i - b0; l1 <= i + b0 && flag; ++l1) {
|
||||
for (j1 = k - b0; j1 <= k + b0 && flag; ++j1) {
|
||||
if (i1 >= 0 && i1 < 256) {
|
||||
k1 = world.getTypeId(l1, i1, j1);
|
||||
if (k1 != 0 && k1 != Block.LEAVES.id && k1 != Block.GRASS.id && k1 != Block.DIRT.id && k1 != Block.LOG.id) {
|
||||
flag = false;
|
||||
}
|
||||
} else {
|
||||
@@ -59,32 +71,82 @@ public class WorldGenTrees extends WorldGenerator {
|
||||
return false;
|
||||
} else {
|
||||
i1 = world.getTypeId(i, j - 1, k);
|
||||
if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < world.getHeight() - l - 1) { // CraftBukkit
|
||||
if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < 256 - l - 1) {
|
||||
world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
|
||||
b0 = 3;
|
||||
byte b1 = 0;
|
||||
|
||||
int i2;
|
||||
int j2;
|
||||
int k2;
|
||||
|
||||
for (i2 = j - 3 + l; i2 <= j + l; ++i2) {
|
||||
j1 = i2 - (j + l);
|
||||
k1 = 1 - j1 / 2;
|
||||
for (j1 = j - b0 + l; j1 <= j + l; ++j1) {
|
||||
k1 = j1 - (j + l);
|
||||
i2 = b1 + 1 - k1 / 2;
|
||||
|
||||
for (l1 = i - k1; l1 <= i + k1; ++l1) {
|
||||
int j2 = l1 - i;
|
||||
for (j2 = i - i2; j2 <= i + i2; ++j2) {
|
||||
k2 = j2 - i;
|
||||
|
||||
for (int k2 = k - k1; k2 <= k + k1; ++k2) {
|
||||
int l2 = k2 - k;
|
||||
for (int l2 = k - i2; l2 <= k + i2; ++l2) {
|
||||
int i3 = l2 - k;
|
||||
|
||||
if ((Math.abs(j2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.o[world.getTypeId(l1, i2, k2)]) {
|
||||
this.setTypeAndData(world, l1, i2, k2, Block.LEAVES.id, 0);
|
||||
if ((Math.abs(k2) != i2 || Math.abs(i3) != i2 || random.nextInt(2) != 0 && k1 != 0) && !Block.n[world.getTypeId(j2, j1, l2)]) {
|
||||
this.setTypeAndData(world, j2, j1, l2, Block.LEAVES.id, this.d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i2 = 0; i2 < l; ++i2) {
|
||||
j1 = world.getTypeId(i, j + i2, k);
|
||||
if (j1 == 0 || j1 == Block.LEAVES.id) {
|
||||
this.setTypeAndData(world, i, j + i2, k, Block.LOG.id, 0);
|
||||
for (j1 = 0; j1 < l; ++j1) {
|
||||
k1 = world.getTypeId(i, j + j1, k);
|
||||
if (k1 == 0 || k1 == Block.LEAVES.id) {
|
||||
this.setTypeAndData(world, i, j + j1, k, Block.LOG.id, this.c);
|
||||
if (this.b && j1 > 0) {
|
||||
if (random.nextInt(3) > 0 && ((World )world).isEmpty(i - 1, j + j1, k)) { // Craftbukkit cast to World
|
||||
this.setTypeAndData(world, i - 1, j + j1, k, Block.VINE.id, 8);
|
||||
}
|
||||
|
||||
if (random.nextInt(3) > 0 && ((World )world).isEmpty(i + 1, j + j1, k)) { // Craftbukkit cast to World
|
||||
this.setTypeAndData(world, i + 1, j + j1, k, Block.VINE.id, 2);
|
||||
}
|
||||
|
||||
if (random.nextInt(3) > 0 && ((World )world).isEmpty(i, j + j1, k - 1)) { // Craftbukkit cast to World
|
||||
this.setTypeAndData(world, i, j + j1, k - 1, Block.VINE.id, 1);
|
||||
}
|
||||
|
||||
if (random.nextInt(3) > 0 && ((World )world).isEmpty(i, j + j1, k + 1)) { // Craftbukkit cast to World
|
||||
this.setTypeAndData(world, i, j + j1, k + 1, Block.VINE.id, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.b) {
|
||||
for (j1 = j - 3 + l; j1 <= j + l; ++j1) {
|
||||
k1 = j1 - (j + l);
|
||||
i2 = 2 - k1 / 2;
|
||||
|
||||
for (j2 = i - i2; j2 <= i + i2; ++j2) {
|
||||
for (k2 = k - i2; k2 <= k + i2; ++k2) {
|
||||
if (world.getTypeId(j2, j1, k2) == Block.LEAVES.id) {
|
||||
if (random.nextInt(4) == 0 && world.getTypeId(j2 - 1, j1, k2) == 0) {
|
||||
this.a((World) world, j2 - 1, j1, k2, 8); // Craftbukkit cast to World
|
||||
}
|
||||
|
||||
if (random.nextInt(4) == 0 && world.getTypeId(j2 + 1, j1, k2) == 0) {
|
||||
this.a((World) world, j2 + 1, j1, k2, 2); // Craftbukkit cast to World
|
||||
}
|
||||
|
||||
if (random.nextInt(4) == 0 && world.getTypeId(j2, j1, k2 - 1) == 0) {
|
||||
this.a((World) world, j2, j1, k2 - 1, 1); // Craftbukkit cast to World
|
||||
}
|
||||
|
||||
if (random.nextInt(4) == 0 && world.getTypeId(j2, j1, k2 + 1) == 0) {
|
||||
this.a((World) world, j2, j1, k2 + 1, 4); // Craftbukkit cast to World
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,4 +159,19 @@ public class WorldGenTrees extends WorldGenerator {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void a(World world, int i, int j, int k, int l) {
|
||||
world.setTypeIdAndData(i, j, k, Block.VINE.id, l);
|
||||
int i1 = 4;
|
||||
|
||||
while (true) {
|
||||
--j;
|
||||
if (world.getTypeId(i, j, k) != 0 || i1 <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
world.setTypeIdAndData(i, j, k, Block.VINE.id, l);
|
||||
--i1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user