[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

By: Zeerix <zeerix@draig.de>
This commit is contained in:
CraftBukkit/Spigot 2011-12-23 00:54:34 +01:00
parent 117ad7c1be
commit 585a62f3d3
2 changed files with 52 additions and 4 deletions

View file

@ -365,16 +365,16 @@ public class CraftWorld implements World {
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
switch (type) {
case BIG_TREE:
return new WorldGenBigTree(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null);
return new WorldGenBigTree(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
case BIRCH:
return new WorldGenForest(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null);
return new WorldGenForest(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
case REDWOOD:
return new WorldGenTaiga2(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null);
return new WorldGenTaiga2(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
case TALL_REDWOOD:
return new WorldGenTaiga1().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
case TREE:
default:
return new WorldGenTrees(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null);
return new WorldGenTrees(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
}
}

View file

@ -0,0 +1,48 @@
package org.bukkit.craftbukkit.util;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.server.World;
import org.bukkit.BlockChangeDelegate;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.material.MaterialData;
public class StructureGrowDelegate implements BlockChangeDelegate {
private final CraftWorld world;
private final List<BlockState> blocks = new ArrayList<BlockState>();
public StructureGrowDelegate(World world) {
this.world = world.getWorld();
}
@Override
public boolean setRawTypeId(int x, int y, int z, int type) {
return setRawTypeIdAndData(x, y, z, type, 0);
}
@Override
public boolean setRawTypeIdAndData(int x, int y, int z, int type, int data) {
BlockState state = world.getBlockAt(x, y, z).getState();
state.setTypeId(type);
state.setData(new MaterialData(type, (byte) data));
blocks.add(state);
return true;
}
@Override
public int getTypeId(int x, int y, int z) {
return world.getBlockTypeIdAt(x, y, z);
}
@Override
public int getHeight() {
return world.getMaxHeight();
}
public List<BlockState> getBlocks() {
return blocks;
}
}