diff options
author | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-12-09 16:11:56 +0000 |
---|---|---|
committer | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-12-09 16:11:56 +0000 |
commit | 5e43c61fad9c6620b20518b120ac0448387f2ee5 (patch) | |
tree | e35d5a57a4a52f463737f503540c80c31e89c263 /src/main/java/net/minecraft/server/WorldGenTaiga2.java | |
parent | 076460b419586ff5a79e68b700eb6a0ab1aa5994 (diff) | |
download | craftbukkit-5e43c61fad9c6620b20518b120ac0448387f2ee5.tar craftbukkit-5e43c61fad9c6620b20518b120ac0448387f2ee5.tar.gz craftbukkit-5e43c61fad9c6620b20518b120ac0448387f2ee5.tar.lz craftbukkit-5e43c61fad9c6620b20518b120ac0448387f2ee5.tar.xz craftbukkit-5e43c61fad9c6620b20518b120ac0448387f2ee5.zip |
Implemented onStructureGrow event, thanks to md-5.
Diffstat (limited to 'src/main/java/net/minecraft/server/WorldGenTaiga2.java')
-rw-r--r-- | src/main/java/net/minecraft/server/WorldGenTaiga2.java | 59 |
1 files changed, 52 insertions, 7 deletions
diff --git a/src/main/java/net/minecraft/server/WorldGenTaiga2.java b/src/main/java/net/minecraft/server/WorldGenTaiga2.java index b6cf4555..c20ffc01 100644 --- a/src/main/java/net/minecraft/server/WorldGenTaiga2.java +++ b/src/main/java/net/minecraft/server/WorldGenTaiga2.java @@ -2,7 +2,14 @@ package net.minecraft.server; import java.util.Random; -import org.bukkit.BlockChangeDelegate; // CraftBukkit +// 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 public class WorldGenTaiga2 extends WorldGenerator { @@ -16,10 +23,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); + return this.generate((BlockChangeDelegate) world, random, i, j, k, null, null, world.getWorld()); } - public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k) { + public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k, StructureGrowEvent event, ItemStack itemstack, CraftWorld bukkitWorld) { // CraftBukkit end int l = random.nextInt(4) + 6; int i1 = 1 + random.nextInt(2); @@ -61,7 +68,15 @@ 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 - world.setRawTypeId(i, j - 1, k, Block.DIRT.id); + // 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 k2 = random.nextInt(2); i2 = 1; byte b0 = 0; @@ -79,7 +94,16 @@ 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)]) { - this.a(world, i3, j3, l3, Block.LEAVES.id, 1); + // Craftbukkit start + if (event == null) { + this.a(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 } } } @@ -101,10 +125,31 @@ 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) { - this.a(world, i, j + j3, k, Block.LOG.id, 1); + // Craftbukkit start + if (event == null) { + this.a(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 } } - + // Craftbukkit start + if (event != null) { + Bukkit.getPluginManager().callEvent(event); + if (!event.isCancelled()) { + for (BlockState state : event.getBlocks()) { + state.update(true); + } + if (event.isFromBonemeal() && itemstack != null) { + --itemstack.count; + } + } + } + // Craftbukkit end return true; } else { return false; |