[Bleeding] Undo changes to the tree WorldGenerators.

- All StructureGrowEvent handling for these is in BlockSapling now, using a BlockChangeDelegate to collect the data.
- Moved StructureGrowDelegate into a separate class
This commit is contained in:
Zeerix
2011-12-23 00:54:34 +01:00
committed by EvilSeph
parent 796d4a8a74
commit 7a49e29b55
7 changed files with 109 additions and 240 deletions

View File

@@ -2,23 +2,13 @@ package net.minecraft.server;
import java.util.Random;
// CraftBukkit start
import org.bukkit.BlockChangeDelegate;
import org.bukkit.Bukkit;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.event.world.StructureGrowEvent;
// CraftBukkit end
import org.bukkit.BlockChangeDelegate; // CraftBukkit
public class WorldGenBigTree extends WorldGenerator {
static final byte[] a = new byte[] { (byte) 2, (byte) 0, (byte) 0, (byte) 1, (byte) 2, (byte) 1};
Random b = new Random();
// CraftBukkit start
BlockChangeDelegate world;
StructureGrowEvent event;
CraftWorld bukkitWorld;
// CraftBukkit end
BlockChangeDelegate world; // CraftBukkit
int[] d = new int[] { 0, 0, 0};
int e = 0;
int f;
@@ -131,15 +121,7 @@ public class WorldGenBigTree extends WorldGenerator {
if (l1 != 0 && l1 != 18) {
++k1;
} else {
// CraftBukkit start
if (event == null) {
this.setTypeAndData(this.world, aint1[0], aint1[1], aint1[2], l, 0);
} else {
BlockState state = bukkitWorld.getBlockAt(aint1[0], aint1[1], aint1[2]).getState();
state.setTypeId(l);
event.getBlocks().add(state);
}
// CraftBukkit end
this.setTypeAndData(this.world, aint1[0], aint1[1], aint1[2], l, 0);
++k1;
}
}
@@ -215,15 +197,7 @@ public class WorldGenBigTree extends WorldGenerator {
aint3[b1] = MathHelper.floor((double) (aint[b1] + j) + 0.5D);
aint3[b2] = MathHelper.floor((double) aint[b2] + (double) j * d0 + 0.5D);
aint3[b3] = MathHelper.floor((double) aint[b3] + (double) j * d1 + 0.5D);
// CraftBukkit start
if (event == null) {
this.setTypeAndData(this.world, aint3[0], aint3[1], aint3[2], i, 0);
} else {
BlockState state = bukkitWorld.getBlockAt(aint3[0], aint3[1], aint3[2]).getState();
state.setTypeId(i);
event.getBlocks().add(state);
}
// CraftBukkit end
this.setTypeAndData(this.world, aint3[0], aint3[1], aint3[2], i, 0);
}
}
}
@@ -368,12 +342,10 @@ public class WorldGenBigTree extends WorldGenerator {
// 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
return this.generate((BlockChangeDelegate) world, random, i, j, k, null, null, world.getWorld());
return this.generate((BlockChangeDelegate) world, random, i, j, k);
}
public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k, StructureGrowEvent event, ItemStack itemstack, CraftWorld bukkitWorld) {
this.event = event;
this.bukkitWorld = bukkitWorld;
public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k) {
// CraftBukkit end
this.world = world;
long l = random.nextLong();
@@ -393,17 +365,6 @@ public class WorldGenBigTree extends WorldGenerator {
this.b();
this.c();
this.d();
// CraftBukkit start
if (event != null) {
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
world.setRawTypeId(i, j, k, 0);
for (BlockState state : event.getBlocks()) {
state.update(true);
}
}
}
// CraftBukkit end
return true;
}
}