summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockVine.patch
blob: 88ed44192d9e680deb4e3b8c1a793b54a0432458 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
--- /home/matt/mc-dev-private//net/minecraft/server/BlockVine.java	2015-02-26 22:40:22.283608143 +0000
+++ src/main/java/net/minecraft/server/BlockVine.java	2015-02-26 22:40:22.287608143 +0000
@@ -3,6 +3,8 @@
 import java.util.Iterator;
 import java.util.Random;
 
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
 public class BlockVine extends Block {
 
     public static final BlockStateBoolean UP = BlockStateBoolean.of("up");
@@ -199,7 +201,13 @@
                         }
 
                         if (((Boolean) iblockdata1.get(BlockVine.NORTH)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.EAST)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.SOUTH)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.WEST)).booleanValue()) {
-                            world.setTypeAndData(blockposition.up(), iblockdata1, 2);
+                            // CraftBukkit start - Call BlockSpreadEvent
+                            // world.setTypeAndData(blockposition.up(), iblockdata1, 2);
+                            BlockPosition target = blockposition.up();
+                            org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+                            org.bukkit.block.Block block = world.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ());
+                            CraftEventFactory.handleBlockSpreadEvent(block, source, this, toLegacyData(iblockdata1));
+                            // CraftBukkit end
                         }
 
                     }
@@ -219,17 +227,29 @@
                                 BlockPosition blockposition2 = blockposition1.shift(enumdirection1);
                                 BlockPosition blockposition3 = blockposition1.shift(enumdirection2);
 
+                                // CraftBukkit start - Call BlockSpreadEvent
+                                org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+                                org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ());
+
                                 if (flag1 && this.c(world.getType(blockposition2).getBlock())) {
-                                    world.setTypeAndData(blockposition1, this.getBlockData().set(a(enumdirection1), Boolean.valueOf(true)), 2);
+                                    // world.setTypeAndData(blockposition1, this.getBlockData().set(a(enumdirection1), Boolean.valueOf(true)), 2);
+                                    CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(a(enumdirection1), Boolean.valueOf(true))));
                                 } else if (flag2 && this.c(world.getType(blockposition3).getBlock())) {
-                                    world.setTypeAndData(blockposition1, this.getBlockData().set(a(enumdirection2), Boolean.valueOf(true)), 2);
+                                    // world.setTypeAndData(blockposition1, this.getBlockData().set(a(enumdirection2), Boolean.valueOf(true)), 2);
+                                    CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(a(enumdirection2), Boolean.valueOf(true))));
                                 } else if (flag1 && world.isEmpty(blockposition2) && this.c(world.getType(blockposition.shift(enumdirection1)).getBlock())) {
-                                    world.setTypeAndData(blockposition2, this.getBlockData().set(a(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+                                    // world.setTypeAndData(blockposition2, this.getBlockData().set(a(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+                                    bukkitBlock = world.getWorld().getBlockAt(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ());
+                                    CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(a(enumdirection.opposite()), Boolean.valueOf(true))));
                                 } else if (flag2 && world.isEmpty(blockposition3) && this.c(world.getType(blockposition.shift(enumdirection2)).getBlock())) {
-                                    world.setTypeAndData(blockposition3, this.getBlockData().set(a(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+                                    // world.setTypeAndData(blockposition3, this.getBlockData().set(a(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+                                    bukkitBlock = world.getWorld().getBlockAt(blockposition3.getX(), blockposition3.getY(), blockposition3.getZ());
+                                    CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(a(enumdirection.opposite()), Boolean.valueOf(true))));
                                 } else if (this.c(world.getType(blockposition1.up()).getBlock())) {
-                                    world.setTypeAndData(blockposition1, this.getBlockData(), 2);
+                                    // world.setTypeAndData(blockposition1, this.getBlockData(), 2);
+                                    CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData()));
                                 }
+                                // CraftBukkit end
                             } else if (block.material.k() && block.d()) {
                                 world.setTypeAndData(blockposition, iblockdata.set(a(enumdirection), Boolean.valueOf(true)), 2);
                             }
@@ -256,7 +276,12 @@
                                 }
 
                                 if (((Boolean) iblockdata3.get(BlockVine.NORTH)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.EAST)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.SOUTH)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.WEST)).booleanValue()) {
-                                    world.setTypeAndData(blockposition1, iblockdata3, 2);
+                                    // CraftBukkit start - Call BlockSpreadEvent
+                                    // world.setTypeAndData(blockposition1, iblockdata3, 2);
+                                    org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+                                    org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ());
+                                    CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(iblockdata3));
+                                    // CraftBukkit end
                                 }
                             } else if (block1 == this) {
                                 iblockdata3 = iblockdata2;