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/WorldGenHugeMushroom.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/WorldGenHugeMushroom.java')
-rw-r--r-- | src/main/java/net/minecraft/server/WorldGenHugeMushroom.java | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java b/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java index 27f86747..1da757d8 100644 --- a/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java +++ b/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java @@ -1,6 +1,13 @@ package net.minecraft.server; import java.util.Random; +// Craftbukkit start +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 WorldGenHugeMushroom extends WorldGenerator { @@ -12,7 +19,13 @@ public class WorldGenHugeMushroom extends WorldGenerator { public WorldGenHugeMushroom() {} + // CraftBukkit start - delegate to grow() public boolean a(World world, Random random, int i, int j, int k) { + return grow(world, random, i, j, k, null, null, null); + } + + public boolean grow(World world, Random random, int i, int j, int k, StructureGrowEvent event, ItemStack itemstack, CraftWorld bukkitWorld) { + // CraftBukkit end int l = random.nextInt(2); if (this.a >= 0) { @@ -58,7 +71,15 @@ public class WorldGenHugeMushroom extends WorldGenerator { } else if (!Block.BROWN_MUSHROOM.canPlace(world, i, j, k)) { return false; } else { - 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 int j2 = j + i1; if (l == 1) { @@ -138,7 +159,16 @@ public class WorldGenHugeMushroom extends WorldGenerator { } if ((l2 != 0 || j >= j + i1 - 1) && !Block.o[world.getTypeId(i2, k1, k2)]) { - world.setRawTypeIdAndData(i2, k1, k2, Block.BIG_MUSHROOM_1.id + l, l2); + // Craftbukkit start + if (event == null) { + world.setRawTypeIdAndData(i2, k1, k2, Block.BIG_MUSHROOM_1.id + l, l2); + } else { + BlockState state = bukkitWorld.getBlockAt(i2, k1, k2).getState(); + state.setTypeId(Block.BIG_MUSHROOM_1.id + l); + state.setData(new MaterialData(Block.BIG_MUSHROOM_1.id + l, (byte) l2)); + event.getBlocks().add(state); + } + // Craftbukkit end } } } @@ -147,10 +177,31 @@ public class WorldGenHugeMushroom extends WorldGenerator { for (k1 = 0; k1 < i1; ++k1) { l1 = world.getTypeId(i, j + k1, k); if (!Block.o[l1]) { - world.setRawTypeIdAndData(i, j + k1, k, Block.BIG_MUSHROOM_1.id + l, 10); + // Craftbukkit start + if (event == null) { + world.setRawTypeIdAndData(i, j + k1, k, Block.BIG_MUSHROOM_1.id + l, 10); + } else { + BlockState state = bukkitWorld.getBlockAt(i, j + k1, k).getState(); + state.setTypeId(Block.BIG_MUSHROOM_1.id + l); + state.setData(new MaterialData(Block.BIG_MUSHROOM_1.id + l, (byte) 10)); + event.getBlocks().add(state); + } + // 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; } } |