Empty villager trades are valid

Fixes #3171
This commit is contained in:
Camotoy 2022-07-24 19:41:05 -04:00
parent 41273001d8
commit f4a5ccb1f9
No known key found for this signature in database
GPG Key ID: 7EEFB66FE798081F
1 changed files with 3 additions and 1 deletions

View File

@ -104,7 +104,9 @@ public class JavaMerchantOffersTranslator extends PacketTranslator<ClientboundMe
recipe.put("sell", getItemTag(session, trade.getOutput()));
// The buy count before demand and special price adjustments
recipe.putInt("buyCountA", Math.max(trade.getFirstInput().getAmount(), 0));
// The first input CAN be null as of Java 1.19.0/Bedrock 1.19.10
// Replicable item: https://gist.github.com/Camotoy/3f3f23d1f80981d1b4472bdb23bba698 from https://github.com/GeyserMC/Geyser/issues/3171
recipe.putInt("buyCountA", trade.getFirstInput() != null ? Math.max(trade.getFirstInput().getAmount(), 0) : 0);
recipe.putInt("buyCountB", trade.getSecondInput() != null ? Math.max(trade.getSecondInput().getAmount(), 0) : 0);
recipe.putInt("demand", trade.getDemand()); // Seems to have no effect