Paper/nms-patches/PathfinderGoalVillagerFarm.patch

49 lines
2.5 KiB
Diff
Raw Normal View History

2016-07-08 03:12:40 +02:00
--- a/net/minecraft/server/PathfinderGoalVillagerFarm.java
+++ b/net/minecraft/server/PathfinderGoalVillagerFarm.java
2016-11-17 02:41:03 +01:00
@@ -40,7 +40,11 @@
2016-07-08 03:12:40 +02:00
Block block = iblockdata.getBlock();
2018-07-15 02:00:00 +02:00
if (this.i == 0 && block instanceof BlockCrops && ((BlockCrops) block).w(iblockdata)) {
2016-07-08 03:12:40 +02:00
- world.setAir(blockposition, true);
+ // CraftBukkit start
2018-07-15 02:00:00 +02:00
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
2016-07-08 03:12:40 +02:00
+ world.setAir(blockposition, true);
+ }
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
} else if (this.i == 1 && iblockdata.isAir()) {
InventorySubcontainer inventorysubcontainer = this.f.dD();
2016-07-08 03:12:40 +02:00
2016-11-17 02:41:03 +01:00
@@ -49,19 +53,28 @@
2016-07-08 03:12:40 +02:00
boolean flag = false;
2016-11-17 02:41:03 +01:00
if (!itemstack.isEmpty()) {
2016-07-08 03:12:40 +02:00
+ // 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) {
2018-07-15 02:00:00 +02:00
- world.setTypeAndData(blockposition, Blocks.BEETROOTS.getBlockData(), 3);
+ planted = Blocks.BEETROOTS;
2016-07-08 03:12:40 +02:00
flag = true;
}
+
2018-07-15 02:00:00 +02:00
+ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, blockposition, planted.getBlockData()).isCancelled()) {
2016-07-08 03:12:40 +02:00
+ world.setTypeAndData(blockposition, planted.getBlockData(), 3);
+ } else {
+ flag = false;
+ }
+ // CraftBukkit end
}
if (flag) {