From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ben Kerllenevich <ben@omega24.dev>
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/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
index 98411df8a36e29b818e990b3c1aa4e30417c87ca..581c1fc648eb281e15296b6640dfe7297db9555e 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -383,7 +383,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
                     return tryRide(player, hand); // Purpur
                 } else {
                     if (level.purpurConfig.villagerRidable && itemstack.isEmpty()) return tryRide(player, hand); // Purpur
-                    if (!this.level.isClientSide && !this.offers.isEmpty()) {
+                    if (this.level.purpurConfig.villagerAllowTrading && !this.offers.isEmpty()) { // Purpur
                         this.startTrading(player);
                     }
 
diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
index c48935d35a6141c41db22e3ec172d5994fd317a2..fa4644c11cbb252734a6f5dc21c861d2c7309ffd 100644
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
@@ -140,7 +140,7 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
                 return tryRide(player, hand); // Purpur
             } else {
                 if (level.purpurConfig.wanderingTraderRidable && itemstack.isEmpty()) return tryRide(player, hand); // Purpur
-                if (!this.level.isClientSide) {
+                if (this.level.purpurConfig.wanderingTraderAllowTrading) { // Purpur
                     this.setTradingPlayer(player);
                     this.openTradingScreen(player, this.getDisplayName(), 1);
                 }
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index cbf2c803de7b256550c748eba8c110e3f6c61edb..e6a317143896dec02be183b4726fcddaf5826a8f 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -1844,6 +1844,7 @@ public class PurpurWorldConfig {
     public boolean villagerClericsFarmWarts = false;
     public boolean villagerClericFarmersThrowWarts = true;
     public boolean villagerBypassMobGriefing = false;
+    public boolean villagerAllowTrading = true;
     private void villagerSettings() {
         villagerRidable = getBoolean("mobs.villager.ridable", villagerRidable);
         villagerRidableInWater = getBoolean("mobs.villager.ridable-in-water", villagerRidableInWater);
@@ -1871,6 +1872,7 @@ public class PurpurWorldConfig {
         villagerClericsFarmWarts = getBoolean("mobs.villager.clerics-farm-warts", villagerClericsFarmWarts);
         villagerClericFarmersThrowWarts = getBoolean("mobs.villager.cleric-wart-farmers-throw-warts-at-villagers", villagerClericFarmersThrowWarts);
         villagerBypassMobGriefing = getBoolean("mobs.villager.bypass-mob-griefing", villagerBypassMobGriefing);
+        villagerAllowTrading = getBoolean("mobs.villager.allow-trading", villagerAllowTrading);
     }
 
     public boolean vindicatorRidable = false;
@@ -1894,6 +1896,7 @@ public class PurpurWorldConfig {
     public double wanderingTraderMaxHealth = 20.0D;
     public boolean wanderingTraderFollowEmeraldBlock = false;
     public boolean wanderingTraderCanBeLeashed = false;
+    public boolean wanderingTraderAllowTrading = true;
     private void wanderingTraderSettings() {
         wanderingTraderRidable = getBoolean("mobs.wandering_trader.ridable", wanderingTraderRidable);
         wanderingTraderRidableInWater = getBoolean("mobs.wandering_trader.ridable-in-water", wanderingTraderRidableInWater);
@@ -1905,6 +1908,7 @@ public class PurpurWorldConfig {
         wanderingTraderMaxHealth = getDouble("mobs.wandering_trader.attributes.max_health", wanderingTraderMaxHealth);
         wanderingTraderFollowEmeraldBlock = getBoolean("mobs.wandering_trader.follow-emerald-blocks", wanderingTraderFollowEmeraldBlock);
         wanderingTraderCanBeLeashed = getBoolean("mobs.wandering_trader.can-be-leashed", wanderingTraderCanBeLeashed);
+        wanderingTraderAllowTrading = getBoolean("mobs.wandering_trader.allow-trading", wanderingTraderAllowTrading);
     }
 
     public boolean witchRidable = false;
