Added support for different tree generation types and a callback.

By: sk89q <the.sk89q@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2011-01-30 13:53:57 -08:00
parent 71abdb0010
commit b6d877d771

View File

@ -18,7 +18,9 @@ import org.bukkit.Chunk;
import org.bukkit.entity.ItemDrop; import org.bukkit.entity.ItemDrop;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.bukkit.BlockChangeDelegate;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.TreeType;
import org.bukkit.World; import org.bukkit.World;
public class CraftWorld implements World { public class CraftWorld implements World {
@ -194,14 +196,34 @@ public class CraftWorld implements World {
return (Boat) boat.getBukkitEntity(); return (Boat) boat.getBukkitEntity();
} }
public boolean generateTree(Location loc) { public boolean generateTree(Location loc, TreeType type) {
WorldGenTrees treeGen = new WorldGenTrees(); return generateTree(loc, type, world);
return treeGen.a(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
} }
public boolean generateBigTree(Location loc) { public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
WorldGenBigTree treeGen = new WorldGenBigTree(); switch (type) {
return treeGen.a(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); case BIG_TREE:
return (new WorldGenBigTree())
.generate(delegate, rand,
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
case BIRCH:
return (new WorldGenForest())
.generate(delegate, rand,
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
case REDWOOD:
return (new WorldGenTaiga2())
.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())
.generate(delegate, rand,
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
}
} }
public TileEntity getTileEntityAt(final int x, final int y, final int z) { public TileEntity getTileEntityAt(final int x, final int y, final int z) {