summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockMycel.patch
blob: 911d1312cf95b686e12769ba49dff75671f188e3 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
--- ../work/decompile-8eb82bde//net/minecraft/server/BlockMycel.java	2014-11-28 17:43:42.925707439 +0000
+++ src/main/java/net/minecraft/server/BlockMycel.java	2014-11-28 17:38:20.000000000 +0000
@@ -2,6 +2,13 @@
 
 import java.util.Random;
 
+// CraftBukkit start
+import org.bukkit.block.BlockState;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.event.block.BlockFadeEvent;
+import org.bukkit.event.block.BlockSpreadEvent;
+// CraftBukkit end
+
 public class BlockMycel extends Block {
 
     public static final BlockStateBoolean SNOWY = BlockStateBoolean.of("snowy");
@@ -22,7 +29,19 @@
     public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
         if (!world.isStatic) {
             if (world.getLightLevel(blockposition.up()) < 4 && world.getType(blockposition.up()).getBlock().n() > 2) {
-                world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData().set(BlockDirt.VARIANT, EnumDirtVariant.DIRT));
+                // CraftBukkit start
+                // world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData().set(BlockDirt.VARIANT, EnumDirtVariant.DIRT));                
+                org.bukkit.World bworld = world.getWorld();
+                BlockState blockState = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()).getState();
+                blockState.setType(CraftMagicNumbers.getMaterial(Blocks.DIRT));
+
+                BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
+                world.getServer().getPluginManager().callEvent(event);
+
+                if (!event.isCancelled()) {
+                    blockState.update(true);
+                }
+                // CraftBukkit end
             } else {
                 if (world.getLightLevel(blockposition.up()) >= 9) {
                     for (int i = 0; i < 4; ++i) {
@@ -31,7 +50,19 @@
                         Block block = world.getType(blockposition1.up()).getBlock();
 
                         if (iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && block.n() <= 2) {
-                            world.setTypeUpdate(blockposition1, this.getBlockData());
+                            // CraftBukkit start
+                            // world.setTypeUpdate(blockposition1, this.getBlockData());
+                            org.bukkit.World bworld = world.getWorld();
+                            BlockState blockState = bworld.getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).getState();
+                            blockState.setType(CraftMagicNumbers.getMaterial(this));
+
+                            BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), blockState);
+                            world.getServer().getPluginManager().callEvent(event);
+
+                            if (!event.isCancelled()) {
+                                blockState.update(true);
+                            }
+                            // CraftBukkit end
                         }
                     }
                 }