summaryrefslogtreecommitdiffstats
path: root/nms-patches/PathfinderGoalEatTile.patch
blob: ecefdb1899aab821f14bbe903f85b90af61fc993 (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
--- a/net/minecraft/server/PathfinderGoalEatTile.java
+++ b/net/minecraft/server/PathfinderGoalEatTile.java
@@ -2,6 +2,10 @@
 
 import java.util.function.Predicate;
 
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
 public class PathfinderGoalEatTile extends PathfinderGoal {
 
     private static final Predicate<IBlockData> a = BlockStatePredicate.a(Blocks.GRASS);
@@ -49,7 +53,8 @@
             BlockPosition blockposition = new BlockPosition(this.b.locX, this.b.locY, this.b.locZ);
 
             if (PathfinderGoalEatTile.a.test(this.c.getType(blockposition))) {
-                if (this.c.getGameRules().getBoolean("mobGriefing")) {
+                // CraftBukkit
+                if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean("mobGriefing")).isCancelled()) {
                     this.c.setAir(blockposition, false);
                 }
 
@@ -58,7 +63,8 @@
                 BlockPosition blockposition1 = blockposition.down();
 
                 if (this.c.getType(blockposition1).getBlock() == Blocks.GRASS_BLOCK) {
-                    if (this.c.getGameRules().getBoolean("mobGriefing")) {
+                    // CraftBukkit
+                    if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean("mobGriefing")).isCancelled()) {
                         this.c.triggerEffect(2001, blockposition1, Block.getCombinedId(Blocks.GRASS_BLOCK.getBlockData()));
                         this.c.setTypeAndData(blockposition1, Blocks.DIRT.getBlockData(), 2);
                     }