Fix villager trading demand - MC-163962
Prevent demand from going negative and tending to negative infinity
This commit is contained in:
@@ -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) {
|
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.baseCostA = firstBuyItem;
|
||||||
this.costB = secondBuyItem;
|
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 @@
|
@@ -185,7 +199,11 @@
|
||||||
if (!this.satisfiedBy(firstBuyStack, secondBuyStack)) {
|
if (!this.satisfiedBy(firstBuyStack, secondBuyStack)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user