Files
Purpur/patches/server/0258-Configurable-minimum-demand-for-trades.patch
BillyGalbreath 47dc2e92f5 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@55a16d8 Fix Varint21FrameDecoder cached length buf usage
PaperMC/Paper@e6e37ba Add api to resolve components (#7648)
PaperMC/Paper@7168438 [ci skip] Rework workflows to support optional paperclip build (#8583)
PaperMC/Paper@da230d5 More vanilla friendly methods to update trades (#8478)
PaperMC/Paper@8aff07a Add /paper dumplisteners command (#8507)
PaperMC/Paper@b8919a7 pr command action fixes (#8591)
PaperMC/Paper@185fa48 Fix chest relooting mechanics (#8580)
PaperMC/Paper@b4beac0 Fixes potential issues arising from optimizing getPlayerByUUID (#8585)
PaperMC/Paper@f637b1a Fix async entity add due to fungus trees (#7626)
PaperMC/Paper@414ea80 ItemStack damage API (#7801)
PaperMC/Paper@d98c370 Add displayName methods for advancements (#8584)
PaperMC/Paper@44bb599 Add Tick TemporalUnit (#5445)
PaperMC/Paper@9f7eef8 Friction API (#6611)
PaperMC/Paper@4048d3e Allow using degrees for ArmorStand rotations (#7847)
PaperMC/Paper@f59c802 Schoolable Fish API (#7089)
PaperMC/Paper@21b964a Added ability to control player's insomnia and phantoms spawning (#6500)
PaperMC/Paper@f1583fc Add `/paper dumplisteners tofile` and increase detail of command output (#8592)
2022-11-26 18:48:36 -06:00

62 lines
3.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Totorewa <76272501+totorewa@users.noreply.github.com>
Date: Fri, 7 Jan 2022 21:34:57 +1300
Subject: [PATCH] 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.
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 1d3e10d7cd27257e8fd83c3e882b05b9d4374c56..302c9b2c063013d8cbd01103e305f16d12f87d51 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -534,7 +534,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
while (iterator.hasNext()) {
MerchantOffer merchantrecipe = (MerchantOffer) iterator.next();
- merchantrecipe.updateDemand();
+ merchantrecipe.updateDemand(this.level.purpurConfig.villagerMinimumDemand); // Purpur
}
}
diff --git a/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java b/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java
index 8a9a701baabdaf066cd9b28c05430f673fcafb4e..17cc3237c7fc8ceda136b2371fabf6f004a991aa 100644
--- a/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java
+++ b/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java
@@ -132,7 +132,12 @@ public class MerchantOffer {
}
public void updateDemand() {
- this.demand = Math.max(0, this.demand + this.uses - (this.maxUses - this.uses)); // Paper
+ // Purpur start
+ this.updateDemand(0);
+ }
+ public void updateDemand(int minimumDemand) {
+ this.demand = Math.max(minimumDemand, this.demand + this.uses - (this.maxUses - this.uses));
+ // Purpur end
}
public ItemStack assemble() {
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index 6d576d08dc39f09e2d941dd6e715199154337786..07e61dbb279740711ac0ba624865a207c55118f0 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -2656,6 +2656,7 @@ public class PurpurWorldConfig {
public boolean villagerTakeDamageFromWater = false;
public boolean villagerAllowTrading = true;
public boolean villagerAlwaysDropExp = false;
+ public int villagerMinimumDemand = 0;
private void villagerSettings() {
villagerRidable = getBoolean("mobs.villager.ridable", villagerRidable);
villagerRidableInWater = getBoolean("mobs.villager.ridable-in-water", villagerRidableInWater);
@@ -2678,6 +2679,7 @@ public class PurpurWorldConfig {
villagerTakeDamageFromWater = getBoolean("mobs.villager.takes-damage-from-water", villagerTakeDamageFromWater);
villagerAllowTrading = getBoolean("mobs.villager.allow-trading", villagerAllowTrading);
villagerAlwaysDropExp = getBoolean("mobs.villager.always-drop-exp", villagerAlwaysDropExp);
+ villagerMinimumDemand = getInt("mobs.villager.minimum-demand", villagerMinimumDemand);
}
public boolean vindicatorRidable = false;