Configurable minimum demand for trades

Addresses MC-163962 where villager demand decreases indefinitely. Paper adds a patch to fix this by preventing demand from going below zero. This patch adds a config option to allow the minimum demand to instead be configurable.
This commit is contained in:
Totorewa
2025-01-12 14:25:36 -08:00
committed by granny
parent f551cb43d0
commit d01b838fb6
4 changed files with 27 additions and 61 deletions

View File

@@ -22,6 +22,15 @@
this.startTrading(player);
}
@@ -503,7 +_,7 @@
private void updateDemand() {
for (MerchantOffer merchantOffer : this.getOffers()) {
- merchantOffer.updateDemand();
+ merchantOffer.updateDemand(this.level().purpurConfig.villagerMinimumDemand); // Purpur - Configurable minimum demand for trades
}
}
@@ -707,7 +_,7 @@
@Override

View File

@@ -0,0 +1,16 @@
--- a/net/minecraft/world/item/trading/MerchantOffer.java
+++ b/net/minecraft/world/item/trading/MerchantOffer.java
@@ -143,7 +_,12 @@
}
public void updateDemand() {
- this.demand = Math.max(0, this.demand + this.uses - (this.maxUses - this.uses)); // Paper - Fix MC-163962
+ // Purpur start - Configurable minimum demand for trades
+ this.updateDemand(0);
+ }
+ public void updateDemand(int minimumDemand) {
+ this.demand = Math.max(minimumDemand, this.demand + this.uses - (this.maxUses - this.uses)); // Paper - Fix MC-163962
+ // Purpur end - Configurable minimum demand for trades
}
public ItemStack assemble() {