summaryrefslogtreecommitdiffstats
path: root/nms-patches/PathfinderGoalVillagerFarm.patch
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2016-07-08 11:12:40 +1000
committermd_5 <git@md-5.net>2016-07-08 11:12:40 +1000
commitd7c257e120996eab1eab7d2bc5a31749ccbe274a (patch)
treebfc1583b58526fc6442e89b9d81d9e11b6986ca6 /nms-patches/PathfinderGoalVillagerFarm.patch
parenta327d9f1da49d0ede770894d83e33d10fb6c19fd (diff)
downloadcraftbukkit-d7c257e120996eab1eab7d2bc5a31749ccbe274a.tar
craftbukkit-d7c257e120996eab1eab7d2bc5a31749ccbe274a.tar.gz
craftbukkit-d7c257e120996eab1eab7d2bc5a31749ccbe274a.tar.lz
craftbukkit-d7c257e120996eab1eab7d2bc5a31749ccbe274a.tar.xz
craftbukkit-d7c257e120996eab1eab7d2bc5a31749ccbe274a.zip
SPIGOT-2490: Villager farming event
Diffstat (limited to 'nms-patches/PathfinderGoalVillagerFarm.patch')
-rw-r--r--nms-patches/PathfinderGoalVillagerFarm.patch49
1 files changed, 49 insertions, 0 deletions
diff --git a/nms-patches/PathfinderGoalVillagerFarm.patch b/nms-patches/PathfinderGoalVillagerFarm.patch
new file mode 100644
index 00000000..449a3a77
--- /dev/null
+++ b/nms-patches/PathfinderGoalVillagerFarm.patch
@@ -0,0 +1,49 @@
+--- a/net/minecraft/server/PathfinderGoalVillagerFarm.java
++++ b/net/minecraft/server/PathfinderGoalVillagerFarm.java
+@@ -48,7 +48,11 @@
+ Block block = iblockdata.getBlock();
+
+ if (this.f == 0 && block instanceof BlockCrops && ((BlockCrops) block).y(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.dj();
+
+@@ -57,19 +61,29 @@
+ boolean flag = false;
+
+ if (itemstack != null) {
++ // 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) {