[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,14 +2,7 @@ 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;
import org.bukkit.material.MaterialData;
// CraftBukkit end
import org.bukkit.BlockChangeDelegate; // CraftBukkit
public class WorldGenTaiga2 extends WorldGenerator {
@@ -23,10 +16,10 @@ public class WorldGenTaiga2 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) {
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);
@@ -68,15 +61,7 @@ public class WorldGenTaiga2 extends WorldGenerator {
} else {
l1 = world.getTypeId(i, j - 1, k);
if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < world.getHeight() - l - 1) { // CraftBukkit
// CraftBukkit start
if (event == null) {
world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
} else {
BlockState dirtState = bukkitWorld.getBlockAt(i, j - 1, k).getState();
dirtState.setTypeId(Block.DIRT.id);
event.getBlocks().add(dirtState);
}
// CraftBukkit end
world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
k2 = random.nextInt(2);
i2 = 1;
byte b0 = 0;
@@ -94,16 +79,7 @@ public class WorldGenTaiga2 extends WorldGenerator {
int i4 = l3 - k;
if ((Math.abs(k3) != k2 || Math.abs(i4) != k2 || k2 <= 0) && !Block.o[world.getTypeId(i3, j3, l3)]) {
// CraftBukkit start
if (event == null) {
this.setTypeAndData(world, i3, j3, l3, Block.LEAVES.id, 1);
} else {
BlockState leavesState = bukkitWorld.getBlockAt(i3, j3, l3).getState();
leavesState.setTypeId(Block.LEAVES.id);
leavesState.setData(new MaterialData(Block.LEAVES.id, (byte) 1));
event.getBlocks().add(leavesState);
}
// CraftBukkit end
this.setTypeAndData(world, i3, j3, l3, Block.LEAVES.id, 1);
}
}
}
@@ -125,28 +101,10 @@ public class WorldGenTaiga2 extends WorldGenerator {
for (j3 = 0; j3 < l - j2; ++j3) {
i3 = world.getTypeId(i, j + j3, k);
if (i3 == 0 || i3 == Block.LEAVES.id) {
// CraftBukkit start
if (event == null) {
this.setTypeAndData(world, i, j + j3, k, Block.LOG.id, 1);
} else {
BlockState logState = bukkitWorld.getBlockAt(i, j + j3, k).getState();
logState.setTypeId(Block.LOG.id);
logState.setData(new MaterialData(Block.LOG.id, (byte) 1));
event.getBlocks().add(logState);
}
// CraftBukkit end
this.setTypeAndData(world, i, j + j3, k, Block.LOG.id, 1);
}
}
// CraftBukkit start
if (event != null) {
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
for (BlockState state : event.getBlocks()) {
state.update(true);
}
}
}
// CraftBukkit end
return true;
} else {
return false;