summaryrefslogtreecommitdiffstats
path: root/nms-patches/PathfinderGoalEatTile.patch
blob: 525d282b6f975ae217949c7c58da3027492c4da1 (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
--- /home/matt/mc-dev-private//net/minecraft/server/PathfinderGoalEatTile.java	2015-02-26 22:40:22.943608136 +0000
+++ src/main/java/net/minecraft/server/PathfinderGoalEatTile.java	2015-02-26 22:40:22.943608136 +0000
@@ -3,6 +3,11 @@
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
 
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.Material;
+// CraftBukkit end
+
 public class PathfinderGoalEatTile extends PathfinderGoal {
 
     private static final Predicate<IBlockData> b = BlockStatePredicate.a((Block) Blocks.TALLGRASS).a(BlockLongGrass.TYPE, Predicates.equalTo(BlockLongGrass.EnumTallGrassType.GRASS));
@@ -50,7 +55,8 @@
             BlockPosition blockposition = new BlockPosition(this.c.locX, this.c.locY, this.c.locZ);
 
             if (PathfinderGoalEatTile.b.apply(this.d.getType(blockposition))) {
-                if (this.d.getGameRules().getBoolean("mobGriefing")) {
+                // CraftBukkit
+                if (!CraftEventFactory.callEntityChangeBlockEvent(this.c, this.c.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Material.AIR, !this.d.getGameRules().getBoolean("mobGriefing")).isCancelled()) {
                     this.d.setAir(blockposition, false);
                 }
 
@@ -59,7 +65,8 @@
                 BlockPosition blockposition1 = blockposition.down();
 
                 if (this.d.getType(blockposition1).getBlock() == Blocks.GRASS) {
-                    if (this.d.getGameRules().getBoolean("mobGriefing")) {
+                    // CraftBukkit
+                    if (!CraftEventFactory.callEntityChangeBlockEvent(this.c, this.c.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Material.AIR, !this.d.getGameRules().getBoolean("mobGriefing")).isCancelled()) {
                         this.d.triggerEffect(2001, blockposition1, Block.getId(Blocks.GRASS));
                         this.d.setTypeAndData(blockposition1, Blocks.DIRT.getBlockData(), 2);
                     }