summaryrefslogtreecommitdiffstats
path: root/src/main/java/net
diff options
context:
space:
mode:
authorWizjany <wizjany@gmail.com>2011-09-16 15:45:05 -0400
committerDinnerbone <dinnerbone@dinnerbone.com>2011-09-25 01:54:38 +0100
commit3c7a843944e4dacaeda0f1dd6122d3ee7abdf6e1 (patch)
tree2a26deae2840d70bf428db9a43a955c07027d36c /src/main/java/net
parentf389ffd3ca009423b64b44017f9664456231e5e3 (diff)
downloadcraftbukkit-3c7a843944e4dacaeda0f1dd6122d3ee7abdf6e1.tar
craftbukkit-3c7a843944e4dacaeda0f1dd6122d3ee7abdf6e1.tar.gz
craftbukkit-3c7a843944e4dacaeda0f1dd6122d3ee7abdf6e1.tar.lz
craftbukkit-3c7a843944e4dacaeda0f1dd6122d3ee7abdf6e1.tar.xz
craftbukkit-3c7a843944e4dacaeda0f1dd6122d3ee7abdf6e1.zip
Made grass throw a BlockSpread event when growing and a BlockFade event when receding.
Diffstat (limited to 'src/main/java/net')
-rw-r--r--src/main/java/net/minecraft/server/BlockGrass.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/BlockGrass.java b/src/main/java/net/minecraft/server/BlockGrass.java
new file mode 100644
index 00000000..5868eadb
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockGrass.java
@@ -0,0 +1,67 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+// CraftBukkit start
+import org.bukkit.event.block.BlockSpreadEvent;
+import org.bukkit.event.block.BlockFadeEvent;
+//CraftBukkit end
+
+public class BlockGrass extends Block {
+
+ protected BlockGrass(int i) {
+ super(i, Material.GRASS);
+ this.textureId = 3;
+ this.a(true);
+ }
+
+ public int a(int i, int j) {
+ return i == 1 ? 0 : (i == 0 ? 2 : 3);
+ }
+
+ public void a(World world, int i, int j, int k, Random random) {
+ if (!world.isStatic) {
+ if (world.getLightLevel(i, j + 1, k) < 4 && Block.q[world.getTypeId(i, j + 1, k)] > 2) {
+ if (random.nextInt(4) != 0) {
+ return;
+ }
+ // CraftBukkit start
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.block.BlockState blockState = bworld.getBlockAt(i, j, k).getState();
+ blockState.setTypeId(Block.DIRT.id);
+
+ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ blockState.update(true);
+ }
+ // CraftBukkit end
+ } else if (world.getLightLevel(i, j + 1, k) >= 9) {
+ int l = i + random.nextInt(3) - 1;
+ int i1 = j + random.nextInt(5) - 3;
+ int j1 = k + random.nextInt(3) - 1;
+ int k1 = world.getTypeId(l, i1 + 1, j1);
+
+ if (world.getTypeId(l, i1, j1) == Block.DIRT.id && world.getLightLevel(l, i1 + 1, j1) >= 4 && Block.q[k1] <= 2) {
+ // CraftBukkit start
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.block.BlockState blockState = bworld.getBlockAt(l, i1, j1).getState();
+ blockState.setTypeId(this.id);
+
+ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState);
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ blockState.update(true);
+ }
+ // CraftBukkit end
+ }
+ }
+ }
+ }
+
+ public int a(int i, Random random) {
+ return Block.DIRT.a(0, random);
+ }
+}