CraftBukkit/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch
2021-06-11 15:00:00 +10:00

34 lines
1.8 KiB
Diff

--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java
@@ -12,6 +12,10 @@
import net.minecraft.world.level.block.state.predicate.BlockStatePredicate;
import net.minecraft.world.level.gameevent.GameEvent;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class PathfinderGoalEatTile extends PathfinderGoal {
private static final int EAT_ANIMATION_TICKS = 40;
@@ -65,7 +69,8 @@
BlockPosition blockposition = this.mob.getChunkCoordinates();
if (PathfinderGoalEatTile.IS_TALL_GRASS.test(this.level.getType(blockposition))) {
- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ // CraftBukkit
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.getBlockData(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) {
this.level.b(blockposition, false);
}
@@ -75,7 +80,8 @@
BlockPosition blockposition1 = blockposition.down();
if (this.level.getType(blockposition1).a(Blocks.GRASS_BLOCK)) {
- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ // CraftBukkit
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.getBlockData(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) {
this.level.triggerEffect(2001, blockposition1, Block.getCombinedId(Blocks.GRASS_BLOCK.getBlockData()));
this.level.setTypeAndData(blockposition1, Blocks.DIRT.getBlockData(), 2);
}