Archiviert
13
0

Fixed cast issues when passing delegates to world generators, and WorldGenMegaTree method exception. This fixes BUKKIT-866, and references BUKKIT-868.

Also bumped version to 1.2.2-R0.1-SNAPSHOT to match Bukkit.
Dieser Commit ist enthalten in:
Nathan Adams 2012-03-01 15:35:12 +00:00
Ursprung aa3678a783
Commit 6f1fecbd31
3 geänderte Dateien mit 191 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -4,7 +4,7 @@
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<packaging>jar</packaging>
<version>1.2.2-R0-SNAPSHOT</version>
<version>1.2.2-R0.1-SNAPSHOT</version>
<name>CraftBukkit</name>
<url>http://www.bukkit.org</url>
@ -51,7 +51,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.2.2-R0-SNAPSHOT</version>
<version>1.2.2-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

Datei anzeigen

@ -0,0 +1,177 @@
package net.minecraft.server;
import java.util.Random;
import org.bukkit.BlockChangeDelegate; // CraftBukkit
public class WorldGenMegaTree extends WorldGenerator {
private final int a;
private final int b;
private final int c;
public WorldGenMegaTree(boolean flag, int i, int j, int k) {
super(flag);
this.a = i;
this.b = j;
this.c = k;
}
public boolean a(World world, Random random, int i, int j, int k) {
// CraftBukkit start
return this.generate((BlockChangeDelegate) world, random, i, j, k);
}
public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k) {
// CraftBukkit end
int l = random.nextInt(3) + this.a;
boolean flag = true;
if (j >= 1 && j + l + 1 <= 256) {
int i1;
int j1;
int k1;
int l1;
for (i1 = j; i1 <= j + 1 + l; ++i1) {
byte b0 = 2;
if (i1 == j) {
b0 = 1;
}
if (i1 >= j + 1 + l - 2) {
b0 = 2;
}
for (j1 = i - b0; j1 <= i + b0 && flag; ++j1) {
for (k1 = k - b0; k1 <= k + b0 && flag; ++k1) {
if (i1 >= 0 && i1 < 256) {
l1 = world.getTypeId(j1, i1, k1);
if (l1 != 0 && l1 != Block.LEAVES.id && l1 != Block.GRASS.id && l1 != Block.DIRT.id && l1 != Block.LOG.id && l1 != Block.SAPLING.id) {
flag = false;
}
} else {
flag = false;
}
}
}
}
if (!flag) {
return false;
} else {
i1 = world.getTypeId(i, j - 1, k);
if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < 256 - l - 1) {
world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
world.setRawTypeId(i + 1, j - 1, k, Block.DIRT.id);
world.setRawTypeId(i, j - 1, k + 1, Block.DIRT.id);
world.setRawTypeId(i + 1, j - 1, k + 1, Block.DIRT.id);
this.a(world, i, k, j + l, 2, random);
for (int i2 = j + l - 2 - random.nextInt(4); i2 > j + l / 2; i2 -= 2 + random.nextInt(4)) {
float f = random.nextFloat() * 3.1415927F * 2.0F;
k1 = i + (int) (0.5F + MathHelper.cos(f) * 4.0F);
l1 = k + (int) (0.5F + MathHelper.sin(f) * 4.0F);
this.a(world, k1, l1, i2, 0, random);
for (int j2 = 0; j2 < 5; ++j2) {
k1 = i + (int) (1.5F + MathHelper.cos(f) * (float) j2);
l1 = k + (int) (1.5F + MathHelper.sin(f) * (float) j2);
this.setTypeAndData(world, k1, i2 - 3 + j2 / 2, l1, Block.LOG.id, this.b);
}
}
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.b);
if (j1 > 0) {
if (random.nextInt(3) > 0 && world.isEmpty(i - 1, j + j1, k)) {
this.setTypeAndData(world, i - 1, j + j1, k, Block.VINE.id, 8);
}
if (random.nextInt(3) > 0 && world.isEmpty(i, j + j1, k - 1)) {
this.setTypeAndData(world, i, j + j1, k - 1, Block.VINE.id, 1);
}
}
}
if (j1 < l - 1) {
k1 = world.getTypeId(i + 1, j + j1, k);
if (k1 == 0 || k1 == Block.LEAVES.id) {
this.setTypeAndData(world, i + 1, j + j1, k, Block.LOG.id, this.b);
if (j1 > 0) {
if (random.nextInt(3) > 0 && world.isEmpty(i + 2, j + j1, k)) {
this.setTypeAndData(world, i + 2, j + j1, k, Block.VINE.id, 2);
}
if (random.nextInt(3) > 0 && world.isEmpty(i + 1, j + j1, k - 1)) {
this.setTypeAndData(world, i + 1, j + j1, k - 1, Block.VINE.id, 1);
}
}
}
k1 = world.getTypeId(i + 1, j + j1, k + 1);
if (k1 == 0 || k1 == Block.LEAVES.id) {
this.setTypeAndData(world, i + 1, j + j1, k + 1, Block.LOG.id, this.b);
if (j1 > 0) {
if (random.nextInt(3) > 0 && world.isEmpty(i + 2, j + j1, k + 1)) {
this.setTypeAndData(world, i + 2, j + j1, k + 1, Block.VINE.id, 2);
}
if (random.nextInt(3) > 0 && world.isEmpty(i + 1, j + j1, k + 2)) {
this.setTypeAndData(world, i + 1, j + j1, k + 2, Block.VINE.id, 4);
}
}
}
k1 = world.getTypeId(i, j + j1, k + 1);
if (k1 == 0 || k1 == Block.LEAVES.id) {
this.setTypeAndData(world, i, j + j1, k + 1, Block.LOG.id, this.b);
if (j1 > 0) {
if (random.nextInt(3) > 0 && world.isEmpty(i - 1, j + j1, k + 1)) {
this.setTypeAndData(world, i - 1, j + j1, k + 1, Block.VINE.id, 8);
}
if (random.nextInt(3) > 0 && world.isEmpty(i, j + j1, k + 2)) {
this.setTypeAndData(world, i, j + j1, k + 2, Block.VINE.id, 4);
}
}
}
}
}
return true;
} else {
return false;
}
}
} else {
return false;
}
}
// CraftBukkit - Changed signature
private void a(BlockChangeDelegate world, int i, int j, int k, int l, Random random) {
byte b0 = 2;
for (int i1 = k - b0; i1 <= k; ++i1) {
int j1 = i1 - k;
int k1 = l + 1 - j1;
for (int l1 = i - k1; l1 <= i + k1 + 1; ++l1) {
int i2 = l1 - i;
for (int j2 = j - k1; j2 <= j + k1 + 1; ++j2) {
int k2 = j2 - j;
if ((i2 >= 0 || k2 >= 0 || i2 * i2 + k2 * k2 <= k1 * k1) && (i2 <= 0 && k2 <= 0 || i2 * i2 + k2 * k2 <= (k1 + 1) * (k1 + 1)) && (random.nextInt(4) != 0 || i2 * i2 + k2 * k2 <= (k1 - 1) * (k1 - 1)) && !Block.n[world.getTypeId(l1, i1, j2)]) {
this.setTypeAndData(world, l1, i1, j2, Block.LEAVES.id, this.c);
}
}
}
}
}
}

Datei anzeigen

@ -102,19 +102,19 @@ public class WorldGenTrees extends WorldGenerator {
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
if (random.nextInt(3) > 0 && (world).isEmpty(i - 1, j + j1, k)) {
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
if (random.nextInt(3) > 0 && (world).isEmpty(i + 1, j + j1, k)) {
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
if (random.nextInt(3) > 0 && (world).isEmpty(i, j + j1, k - 1)) {
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
if (random.nextInt(3) > 0 && (world).isEmpty(i, j + j1, k + 1)) {
this.setTypeAndData(world, i, j + j1, k + 1, Block.VINE.id, 4);
}
}
@ -130,19 +130,19 @@ public class WorldGenTrees extends WorldGenerator {
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
this.a(world, j2 - 1, j1, k2, 8);
}
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
this.a(world, j2 + 1, j1, k2, 2);
}
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
this.a(world, j2, j1, k2 - 1, 1);
}
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
this.a(world, j2, j1, k2 + 1, 4);
}
}
}
@ -160,8 +160,9 @@ public class WorldGenTrees extends WorldGenerator {
}
}
private void a(World world, int i, int j, int k, int l) {
world.setTypeIdAndData(i, j, k, Block.VINE.id, l);
// CraftBukkit - Changed world to BlockChangeDelegate
private void a(BlockChangeDelegate world, int i, int j, int k, int l) {
world.setRawTypeIdAndData(i, j, k, Block.VINE.id, l); // CraftBukkit - "raw"
int i1 = 4;
while (true) {
@ -170,7 +171,7 @@ public class WorldGenTrees extends WorldGenerator {
return;
}
world.setTypeIdAndData(i, j, k, Block.VINE.id, l);
world.setRawTypeIdAndData(i, j, k, Block.VINE.id, l); // CraftBukkit - "raw"
--i1;
}
}