From d434857d8ae097bd4d7133df57272b5a055a65ae Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Tue, 13 Mar 2012 19:38:39 -0700 Subject: [PATCH] [Bleeding] Added support for all TreeType entries to CraftWorld.generateTree(). Addresses BUKKIT-1161 By: zml2008 --- .../org/bukkit/craftbukkit/CraftWorld.java | 36 ++++++++++++++++--- .../util/StructureGrowDelegate.java | 8 +++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 2c41ba892f..25967d9126 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -369,19 +369,45 @@ public class CraftWorld implements World { } public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { + BlockSapling.TreeGenerator gen; switch (type) { case BIG_TREE: - return new WorldGenBigTree(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + gen = new WorldGenBigTree(true); + break; case BIRCH: - return new WorldGenForest(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + gen = new WorldGenForest(true); + break; case REDWOOD: - return new WorldGenTaiga2(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + gen = new WorldGenTaiga2(true); + break; case TALL_REDWOOD: - return new WorldGenTaiga1().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + gen = new WorldGenTaiga1(); + break; + case JUNGLE: + gen = new WorldGenMegaTree(true, 10 + rand.nextInt(20), 3, 3); + break; + case SMALL_JUNGLE: + gen = new WorldGenTrees(true, 4 + rand.nextInt(7), 3, 3, false); + break; + case JUNGLE_BUSH: + gen = new WorldGenGroundBush(3, 0); + break; + case RED_MUSHROOM: + gen = new WorldGenHugeMushroom(1); + break; + case BROWN_MUSHROOM: + gen = new WorldGenHugeMushroom(0); + break; + case SWAMP: + gen = new WorldGenSwampTree(); + break; case TREE: default: - return new WorldGenTrees(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + gen = new WorldGenTrees(true); + break; } + + return gen.generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); } public TileEntity getTileEntityAt(final int x, final int y, final int z) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/StructureGrowDelegate.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/StructureGrowDelegate.java index f7bab681d5..6566b9e0c7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/StructureGrowDelegate.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/StructureGrowDelegate.java @@ -30,6 +30,14 @@ public class StructureGrowDelegate implements BlockChangeDelegate { return true; } + public boolean setTypeId(int x, int y, int z, int typeId) { + return setRawTypeId(x, y, z, typeId); + } + + public boolean setTypeIdAndData(int x, int y, int z, int typeId, int data) { + return setRawTypeIdAndData(x, y, z, typeId, data); + } + public int getTypeId(int x, int y, int z) { return world.getBlockTypeIdAt(x, y, z); }