From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <blake.galbreath@gmail.com>
Date: Tue, 8 Dec 2020 20:14:20 -0600
Subject: [PATCH] Fix curing zombie villager discount exploit

This fixes the exploit used to gain absurd trading discounts with infecting
and curing a villager on repeat by simply resetting the relevant part of
the reputation when it is cured.

diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
         fixClimbingBypassingCrammingRule = getBoolean("fix-climbing-bypassing-cramming-rule", fixClimbingBypassingCrammingRule);
     }
 
+    public boolean fixCuringZombieVillagerDiscountExploit = true;
+    private void fixCuringExploit() {
+        fixCuringZombieVillagerDiscountExploit = getBoolean("game-mechanics.fix-curing-zombie-villager-discount-exploit", fixCuringZombieVillagerDiscountExploit);
+    }
+
     public short keepLoadedRange;
     private void keepLoadedRange() {
         keepLoadedRange = (short) (getInt("keep-spawn-loaded-range", Math.min(spigotConfig.viewDistance, 10)) * 16);
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -0,0 +0,0 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
     @Override
     public void onReputationEventFrom(ReputationEventType interaction, Entity entity) {
         if (interaction == ReputationEventType.ZOMBIE_VILLAGER_CURED) {
+            // Paper start - fix MC-181190
+            if (level.paperConfig.fixCuringZombieVillagerDiscountExploit) {
+                final GossipContainer.EntityGossips playerReputation = this.getReputation().getReputations().get(entity.getUUID());
+                if (playerReputation != null) {
+                    playerReputation.remove(GossipType.MAJOR_POSITIVE);
+                    playerReputation.remove(GossipType.MINOR_POSITIVE);
+                }
+            }
+            // Paper end
             this.gossips.add(entity.getUUID(), GossipType.MAJOR_POSITIVE, 20);
             this.gossips.add(entity.getUUID(), GossipType.MINOR_POSITIVE, 25);
         } else if (interaction == ReputationEventType.TRADE) {
