Fix villager trading demand - MC-163962

Prevent demand from going negative and tending to negative infinity
This commit is contained in:
chickeneer 2020-06-05 20:02:04 -05:00
parent 37b20cd3d4
commit 2898b4a7eb

View File

@ -29,6 +29,15 @@
private MerchantOffer(ItemCost firstBuyItem, Optional<ItemCost> secondBuyItem, ItemStack sellItem, int uses, int maxUses, boolean rewardingPlayerExperience, int specialPrice, int demandBonus, float priceMultiplier, int merchantExperience) {
this.baseCostA = firstBuyItem;
this.costB = secondBuyItem;
@@ -110,7 +124,7 @@
}
public void updateDemand() {
- this.demand = this.demand + this.uses - (this.maxUses - this.uses);
+ this.demand = Math.max(0, this.demand + this.uses - (this.maxUses - this.uses)); // Paper - Fix MC-163962
}
public ItemStack assemble() {
@@ -185,7 +199,11 @@
if (!this.satisfiedBy(firstBuyStack, secondBuyStack)) {
return false;