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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
--- a/net/minecraft/server/PathfinderGoalVillagerFarm.java
+++ b/net/minecraft/server/PathfinderGoalVillagerFarm.java
@@ -40,7 +40,11 @@
Block block = iblockdata.getBlock();
if (this.i == 0 && block instanceof BlockCrops && ((BlockCrops) block).w(iblockdata)) {
- world.setAir(blockposition, true);
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ world.setAir(blockposition, true);
+ }
+ // CraftBukkit end
} else if (this.i == 1 && iblockdata.isAir()) {
InventorySubcontainer inventorysubcontainer = this.f.dD();
@@ -49,19 +53,28 @@
boolean flag = false;
if (!itemstack.isEmpty()) {
+ // CraftBukkit start
+ Block planted = null;
if (itemstack.getItem() == Items.WHEAT_SEEDS) {
- world.setTypeAndData(blockposition, Blocks.WHEAT.getBlockData(), 3);
+ planted = Blocks.WHEAT;
flag = true;
} else if (itemstack.getItem() == Items.POTATO) {
- world.setTypeAndData(blockposition, Blocks.POTATOES.getBlockData(), 3);
+ planted = Blocks.POTATOES;
flag = true;
} else if (itemstack.getItem() == Items.CARROT) {
- world.setTypeAndData(blockposition, Blocks.CARROTS.getBlockData(), 3);
+ planted = Blocks.CARROTS;
flag = true;
} else if (itemstack.getItem() == Items.BEETROOT_SEEDS) {
- world.setTypeAndData(blockposition, Blocks.BEETROOTS.getBlockData(), 3);
+ planted = Blocks.BEETROOTS;
flag = true;
}
+
+ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, blockposition, planted.getBlockData()).isCancelled()) {
+ world.setTypeAndData(blockposition, planted.getBlockData(), 3);
+ } else {
+ flag = false;
+ }
+ // CraftBukkit end
}
if (flag) {
|