-
Bug
-
Resolution: Fixed
-
1.19.1, 1.19.2
-
None
-
Confirmed
-
Crash
-
Important
Steps to Reproduce
Execute the following command several times during the daytime: /summon minecraft:villager ~ ~ ~ {Gossips: [{Target: [I; 438831016, 1755662668, -1977558996, -1156852131], Type: "trading", Value: 0}]}
Observed Behavior
Crash occurs
Code analysis
Yarn 1.19.1
In VillagerGossips#pickGossips the nextInt method is called with the sum of the absolute value of all gossip values of a villager. If a villager has a gossip of value 0 only, the sum is 0, causing the crash since nextInt expects a positive integer. There should be an early-return in case the sum is 0. This does not affect villagers without gossips because of the early-return a few lines above, which means this cannot be triggered in survival since no action produces a gossip of value 0.