summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntitySilverfish.patch
blob: 10e635b55b66c8a0c8f60dd2747cc7021e1662f8 (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
--- a/net/minecraft/server/EntitySilverfish.java
+++ b/net/minecraft/server/EntitySilverfish.java
@@ -149,6 +149,11 @@
                 IBlockData iblockdata = world.getType(blockposition);
 
                 if (BlockMonsterEggs.i(iblockdata)) {
+                    // CraftBukkit start
+                    if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.MONSTER_EGG, Block.getId(BlockMonsterEggs.getById(iblockdata.getBlock().toLegacyData(iblockdata)))).isCancelled()) {
+                        return;
+                    }
+                    // CraftBukkit end
                     world.setTypeAndData(blockposition, Blocks.MONSTER_EGG.getBlockData().set(BlockMonsterEggs.VARIANT, BlockMonsterEggs.EnumMonsterEggVarient.a(iblockdata)), 3);
                     this.silverfish.doSpawnEffect();
                     this.silverfish.die();
@@ -192,6 +197,11 @@
                             IBlockData iblockdata = world.getType(blockposition1);
 
                             if (iblockdata.getBlock() == Blocks.MONSTER_EGG) {
+                                // CraftBukkit start
+                                if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), Blocks.AIR, 0).isCancelled()) {
+                                    continue;
+                                }
+                                // CraftBukkit end
                                 if (world.getGameRules().getBoolean("mobGriefing")) {
                                     world.setAir(blockposition1, true);
                                 } else {