2015-02-26 23:41:06 +01:00
|
|
|
--- /home/matt/mc-dev-private//net/minecraft/server/BlockSapling.java 2015-02-26 22:40:22.243608143 +0000
|
|
|
|
+++ src/main/java/net/minecraft/server/BlockSapling.java 2015-02-26 22:40:22.247608143 +0000
|
2014-11-25 22:32:16 +01:00
|
|
|
@@ -2,10 +2,20 @@
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+import org.bukkit.Location;
|
|
|
|
+import org.bukkit.TreeType;
|
|
|
|
+import org.bukkit.block.BlockState;
|
|
|
|
+import org.bukkit.event.world.StructureGrowEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement {
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
public static final BlockStateEnum<BlockWood.EnumLogVariant> TYPE = BlockStateEnum.of("type", BlockWood.EnumLogVariant.class);
|
2014-11-25 22:32:16 +01:00
|
|
|
public static final BlockStateInteger STAGE = BlockStateInteger.of("stage", 0, 1);
|
|
|
|
+ public static TreeType treeType; // CraftBukkit
|
|
|
|
|
|
|
|
protected BlockSapling() {
|
2015-02-26 23:41:06 +01:00
|
|
|
this.j(this.blockStateList.getBlockData().set(BlockSapling.TYPE, BlockWood.EnumLogVariant.OAK).set(BlockSapling.STAGE, Integer.valueOf(0)));
|
|
|
|
@@ -23,7 +33,30 @@
|
|
|
|
if (!world.isClientSide) {
|
2014-11-25 22:32:16 +01:00
|
|
|
super.b(world, blockposition, iblockdata, random);
|
|
|
|
if (world.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ world.captureTreeGeneration = true;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
this.grow(world, blockposition, iblockdata, random);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ world.captureTreeGeneration = false;
|
|
|
|
+ if (world.capturedBlockStates.size() > 0) {
|
|
|
|
+ TreeType treeType = BlockSapling.treeType;
|
|
|
|
+ BlockSapling.treeType = null;
|
|
|
|
+ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
|
|
+ List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone();
|
|
|
|
+ world.capturedBlockStates.clear();
|
|
|
|
+ StructureGrowEvent event = null;
|
|
|
|
+ if (treeType != null) {
|
|
|
|
+ event = new StructureGrowEvent(location, treeType, false, null, blocks);
|
|
|
|
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
|
|
|
+ }
|
|
|
|
+ if (event == null || !event.isCancelled()) {
|
|
|
|
+ for (BlockState blockstate : blocks) {
|
|
|
|
+ blockstate.update(true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -39,7 +72,17 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void e(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
|
|
|
|
- Object object = random.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true);
|
|
|
|
+ // CraftBukkit start - Turn ternary operator into if statement to set treeType
|
|
|
|
+ // Object object = random.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true);
|
|
|
|
+ Object object;
|
|
|
|
+ if (random.nextInt(10) == 0) {
|
|
|
|
+ treeType = TreeType.BIG_TREE;
|
|
|
|
+ object = new WorldGenBigTree(true);
|
|
|
|
+ } else {
|
|
|
|
+ treeType = TreeType.TREE;
|
|
|
|
+ object = new WorldGenTrees(true);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
int i = 0;
|
|
|
|
int j = 0;
|
|
|
|
boolean flag = false;
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -51,6 +94,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
for (i = 0; i >= -1; --i) {
|
|
|
|
for (j = 0; j >= -1; --j) {
|
2015-02-26 23:41:06 +01:00
|
|
|
if (this.a(world, blockposition, i, j, BlockWood.EnumLogVariant.SPRUCE)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ treeType = TreeType.MEGA_REDWOOD; // CraftBukkit
|
|
|
|
object = new WorldGenMegaTree(false, random.nextBoolean());
|
|
|
|
flag = true;
|
2015-02-26 23:41:06 +01:00
|
|
|
break label66;
|
|
|
|
@@ -61,11 +105,13 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
if (!flag) {
|
|
|
|
j = 0;
|
|
|
|
i = 0;
|
|
|
|
+ treeType = TreeType.REDWOOD; // CraftBukkit
|
|
|
|
object = new WorldGenTaiga2(true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
+ treeType = TreeType.BIRCH; // CraftBukkit
|
|
|
|
object = new WorldGenForest(true, false);
|
|
|
|
break;
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -77,6 +123,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
for (i = 0; i >= -1; --i) {
|
|
|
|
for (j = 0; j >= -1; --j) {
|
2015-02-26 23:41:06 +01:00
|
|
|
if (this.a(world, blockposition, i, j, BlockWood.EnumLogVariant.JUNGLE)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ treeType = TreeType.JUNGLE; // CraftBukkit
|
2015-02-26 23:41:06 +01:00
|
|
|
object = new WorldGenJungleTree(true, 10, 20, iblockdata1, iblockdata2);
|
2014-11-25 22:32:16 +01:00
|
|
|
flag = true;
|
2015-02-26 23:41:06 +01:00
|
|
|
break label78;
|
|
|
|
@@ -87,11 +134,13 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
if (!flag) {
|
|
|
|
j = 0;
|
|
|
|
i = 0;
|
|
|
|
+ treeType = TreeType.SMALL_JUNGLE; // CraftBukkit
|
2015-02-26 23:41:06 +01:00
|
|
|
object = new WorldGenTrees(true, 4 + random.nextInt(7), iblockdata1, iblockdata2, false);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2015-02-26 23:41:06 +01:00
|
|
|
+ treeType = TreeType.ACACIA; // CraftBukkit
|
2014-11-25 22:32:16 +01:00
|
|
|
object = new WorldGenAcaciaTree(true);
|
|
|
|
break;
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -100,6 +149,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
for (i = 0; i >= -1; --i) {
|
|
|
|
for (j = 0; j >= -1; --j) {
|
2015-02-26 23:41:06 +01:00
|
|
|
if (this.a(world, blockposition, i, j, BlockWood.EnumLogVariant.DARK_OAK)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ treeType = TreeType.DARK_OAK; // CraftBukkit
|
|
|
|
object = new WorldGenForestTree(true);
|
|
|
|
flag = true;
|
2015-02-26 23:41:06 +01:00
|
|
|
break label90;
|