From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Fri, 24 Apr 2020 09:37:29 -0500
Subject: [PATCH] Villagers farming can bypass mob-griefing gamerule


diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
index bd998ea93d7e8748b0a938f0a76b4ccf388c7b27..42c70a6c2972ac38e889a6d42fe2d7d4f6017d57 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
@@ -38,7 +38,7 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
     }
 
     protected boolean a(WorldServer worldserver, EntityVillager entityvillager) {
-        if (!worldserver.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
+        if (!worldserver.getGameRules().getBoolean(GameRules.MOB_GRIEFING) && !worldserver.purpurConfig.villagerFarmingBypassMobGriefing) { // Purpur
             return false;
         } else if (entityvillager.getVillagerData().getProfession() != VillagerProfession.FARMER) {
             return false;
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 29cab794e485b8e07b9e56f8cfb917934364121b..c51628f1f30bcd0206fc2b04ed83aca4ab7fd51a 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -285,9 +285,11 @@ public class PurpurWorldConfig {
 
     public int villagerBrainTicks = 1;
     public boolean villagerUseBrainTicksOnlyWhenLagging = true;
+    public boolean villagerFarmingBypassMobGriefing = false;
     private void villagerSettings() {
         villagerBrainTicks = getInt("mobs.villager.brain-ticks", villagerBrainTicks);
         villagerUseBrainTicksOnlyWhenLagging = getBoolean("mobs.villager.use-brain-ticks-only-when-lagging", villagerUseBrainTicksOnlyWhenLagging);
+        villagerFarmingBypassMobGriefing = getBoolean("mobs.villager.bypass-mob-griefing", villagerFarmingBypassMobGriefing);
     }
 
     public boolean witherSkeletonTakesWitherDamage = false;
