From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ben Kerllenevich <me@notom3ga.me>
Date: Thu, 18 Mar 2021 07:23:27 -0400
Subject: [PATCH] Add config for villager trading


diff --git a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
index 16933de70a23414859019e19545bfa5baa38091a..a02748bff911415d95bea344f179ad27ff9d6092 100644
--- a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
@@ -373,7 +373,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
                     return tryRide(entityhuman, enumhand); // Purpur
                 } else {
                     if (world.purpurConfig.villagerRidable && itemstack.isEmpty()) return tryRide(entityhuman, enumhand); // Purpur
-                    if (!this.world.isClientSide && !this.trades.isEmpty()) {
+                    if (!this.world.isClientSide && this.world.purpurConfig.villagerAllowTrading && !this.trades.isEmpty()) { // Purpur
                         this.h(entityhuman);
                     }
 
diff --git a/src/main/java/net/minecraft/world/entity/npc/EntityVillagerTrader.java b/src/main/java/net/minecraft/world/entity/npc/EntityVillagerTrader.java
index b84916c0c58fd208ef5547299f8db8462d1c42fe..0b6b6aa6b358759c45bbcf4a9ffa53777c8efa1d 100644
--- a/src/main/java/net/minecraft/world/entity/npc/EntityVillagerTrader.java
+++ b/src/main/java/net/minecraft/world/entity/npc/EntityVillagerTrader.java
@@ -142,7 +142,7 @@ public class EntityVillagerTrader extends EntityVillagerAbstract {
                 return tryRide(entityhuman, enumhand); // Purpur
             } else {
                 if (world.purpurConfig.villagerTraderRidable && itemstack.isEmpty()) return tryRide(entityhuman, enumhand); // Purpur
-                if (!this.world.isClientSide) {
+                if (!this.world.isClientSide && this.world.purpurConfig.villagerTraderAllowTrading) {
                     this.setTradingPlayer(entityhuman);
                     this.openTrade(entityhuman, this.getScoreboardDisplayName(), 1);
                 }
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 8bb134ee7be7ff52cda4807f7c9a393f92b8fbc1..e17bf229f8bca03f5a2c78203d1e95093ff9bac1 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -1726,6 +1726,7 @@ public class PurpurWorldConfig {
     public boolean villagerClericsFarmWarts = false;
     public boolean villagerClericFarmersThrowWarts = true;
     public double villagerMaxHealth = 20.0D;
+    public boolean villagerAllowTrading = true;
     private void villagerSettings() {
         villagerRidable = getBoolean("mobs.villager.ridable", villagerRidable);
         villagerRidableInWater = getBoolean("mobs.villager.ridable-in-water", villagerRidableInWater);
@@ -1753,6 +1754,7 @@ public class PurpurWorldConfig {
             set("mobs.villager.attributes.max_health", oldValue);
         }
         villagerMaxHealth = getDouble("mobs.villager.attributes.max_health", villagerMaxHealth);
+        villagerAllowTrading = getBoolean("mobs.villager.allow-trading", villagerAllowTrading);
     }
 
     public boolean villagerTraderRidable = false;
@@ -1760,6 +1762,7 @@ public class PurpurWorldConfig {
     public boolean villagerTraderCanBeLeashed = false;
     public boolean villagerTraderFollowEmeraldBlock = false;
     public double villagerTraderMaxHealth = 20.0D;
+    public boolean villagerTraderAllowTrading = true;
     private void villagerTraderSettings() {
         villagerTraderRidable = getBoolean("mobs.wandering_trader.ridable", villagerTraderRidable);
         villagerTraderRidableInWater = getBoolean("mobs.wandering_trader.ridable-in-water", villagerTraderRidableInWater);
@@ -1771,6 +1774,7 @@ public class PurpurWorldConfig {
             set("mobs.wandering_trader.attributes.max_health", oldValue);
         }
         villagerTraderMaxHealth = getDouble("mobs.wandering_trader.attributes.max_health", villagerTraderMaxHealth);
+        villagerTraderAllowTrading = getBoolean("mobs.wandering_trader.allow-trading", villagerTraderAllowTrading);
     }
 
     public boolean vindicatorRidable = false;
