summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockStem.patch
blob: 89d850bf1f1aa1fb7f41bf59f37239d5c25e3add (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--- a/net/minecraft/server/BlockStem.java
+++ b/net/minecraft/server/BlockStem.java
@@ -3,6 +3,8 @@
 import java.util.Random;
 import javax.annotation.Nullable;
 
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
 public class BlockStem extends BlockPlant implements IBlockFragilePlantElement {
 
     public static final BlockStateInteger AGE = BlockProperties.W;
@@ -33,14 +35,18 @@
 
                 if (i < 7) {
                     iblockdata = (IBlockData) iblockdata.set(BlockStem.AGE, i + 1);
-                    world.setTypeAndData(blockposition, iblockdata, 2);
+                    CraftEventFactory.handleBlockGrowEvent(world, blockposition, iblockdata, 2); // CraftBukkit
                 } else {
                     EnumDirection enumdirection = EnumDirection.EnumDirectionLimit.HORIZONTAL.a(random);
                     BlockPosition blockposition1 = blockposition.shift(enumdirection);
                     Block block = world.getType(blockposition1.down()).getBlock();
 
                     if (world.getType(blockposition1).isAir() && (block == Blocks.FARMLAND || block == Blocks.DIRT || block == Blocks.COARSE_DIRT || block == Blocks.PODZOL || block == Blocks.GRASS_BLOCK)) {
-                        world.setTypeUpdate(blockposition1, this.blockFruit.getBlockData());
+                        // CraftBukkit start
+                        if (!CraftEventFactory.handleBlockGrowEvent(world, blockposition1, this.blockFruit.getBlockData())) {
+                            return;
+                        }
+                        // CraftBukkit end
                         world.setTypeUpdate(blockposition, (IBlockData) this.blockFruit.e().getBlockData().set(BlockFacingHorizontal.FACING, enumdirection));
                     }
                 }
@@ -94,7 +100,7 @@
         int i = Math.min(7, (Integer) iblockdata.get(BlockStem.AGE) + MathHelper.nextInt(world.random, 2, 5));
         IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockStem.AGE, i);
 
-        world.setTypeAndData(blockposition, iblockdata1, 2);
+        CraftEventFactory.handleBlockGrowEvent(world, blockposition, iblockdata1, 2); // CraftBukkit
         if (i == 7) {
             iblockdata1.a(world, blockposition, world.random);
         }