mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 14:33:56 +01:00
49 lines
2.5 KiB
Diff
49 lines
2.5 KiB
Diff
--- a/net/minecraft/server/PathfinderGoalVillagerFarm.java
|
|
+++ b/net/minecraft/server/PathfinderGoalVillagerFarm.java
|
|
@@ -40,7 +40,11 @@
|
|
Block block = iblockdata.getBlock();
|
|
|
|
if (this.f == 0 && block instanceof BlockCrops && ((BlockCrops) block).A(iblockdata)) {
|
|
- world.setAir(blockposition, true);
|
|
+ // CraftBukkit start
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.c, blockposition, Blocks.AIR, 0).isCancelled()) {
|
|
+ world.setAir(blockposition, true);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
} else if (this.f == 1 && iblockdata.getMaterial() == Material.AIR) {
|
|
InventorySubcontainer inventorysubcontainer = this.c.dm();
|
|
|
|
@@ -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.BEETROOT.getBlockData(), 3);
|
|
+ planted = Blocks.BEETROOT;
|
|
flag = true;
|
|
}
|
|
+
|
|
+ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.c, blockposition, planted, 0).isCancelled()) {
|
|
+ world.setTypeAndData(blockposition, planted.getBlockData(), 3);
|
|
+ } else {
|
|
+ flag = false;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
if (flag) {
|