summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/BlockMushroom.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/minecraft/server/BlockMushroom.java')
-rw-r--r--src/main/java/net/minecraft/server/BlockMushroom.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/BlockMushroom.java b/src/main/java/net/minecraft/server/BlockMushroom.java
new file mode 100644
index 00000000..b3381425
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockMushroom.java
@@ -0,0 +1,60 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.Server;
+import org.bukkit.block.BlockState;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.event.block.BlockSpreadEvent;
+// CraftBukkit end
+
+public class BlockMushroom extends BlockFlower {
+
+ protected BlockMushroom(int i, int j) {
+ super(i, j);
+ float f = 0.2F;
+
+ this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
+ this.a(true);
+ }
+
+ public void a(World world, int i, int j, int k, Random random) {
+ if (random.nextInt(100) == 0) {
+ int l = i + random.nextInt(3) - 1;
+ int i1 = j + random.nextInt(2) - random.nextInt(2);
+ int j1 = k + random.nextInt(3) - 1;
+
+ if (world.isEmpty(l, i1, j1) && this.f(world, l, i1, j1)) {
+ int k1 = i + (random.nextInt(3) - 1);
+
+ k1 = k + (random.nextInt(3) - 1);
+ if (world.isEmpty(l, i1, j1) && this.f(world, l, i1, j1)) {
+ // CraftBukkit start
+ Server server = world.getServer();
+ CraftWorld craftworld = world.getWorld();
+ BlockState blockState = craftworld.getBlockAt(l, i1, j1).getState();
+ blockState.setTypeId(this.id);
+
+ BlockSpreadEvent event = new BlockSpreadEvent(craftworld.getBlockAt(l, i1, j1), craftworld.getBlockAt(i, j, k), blockState);
+
+ server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ blockState.update(true);
+ }
+ // CraftBukkit end
+ }
+ }
+ }
+ }
+
+ protected boolean c(int i) {
+ return Block.o[i];
+ }
+
+ public boolean f(World world, int i, int j, int k) {
+ return j >= 0 && j < 128 ? world.j(i, j, k) < 13 && this.c(world.getTypeId(i, j - 1, k)) : false;
+ }
+}