summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockDragonEgg.patch
blob: af397c678219422a1e7e8df135452d53e3b767d1 (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
--- a/net/minecraft/server/BlockDragonEgg.java
+++ b/net/minecraft/server/BlockDragonEgg.java
@@ -2,6 +2,8 @@
 
 import java.util.Random;
 
+import org.bukkit.event.block.BlockFromToEvent; // CraftBukkit
+
 public class BlockDragonEgg extends Block {
 
     protected static final AxisAlignedBB a = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 1.0D, 0.9375D);
@@ -66,6 +68,18 @@
                 BlockPosition blockposition1 = blockposition.a(world.random.nextInt(16) - world.random.nextInt(16), world.random.nextInt(8) - world.random.nextInt(8), world.random.nextInt(16) - world.random.nextInt(16));
 
                 if (world.getType(blockposition1).getBlock().material == Material.AIR) {
+                    // CraftBukkit start
+                    org.bukkit.block.Block from = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+                    org.bukkit.block.Block to = world.getWorld().getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ());
+                    BlockFromToEvent event = new BlockFromToEvent(from, to);
+                    org.bukkit.Bukkit.getPluginManager().callEvent(event);
+
+                    if (event.isCancelled()) {
+                        return;
+                    }
+
+                    blockposition1 = new BlockPosition(event.getToBlock().getX(), event.getToBlock().getY(), event.getToBlock().getZ());
+                    // CraftBukkit end
                     if (world.isClientSide) {
                         for (int j = 0; j < 128; ++j) {
                             double d0 = world.random.nextDouble();