Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-254774

Crash when a villager with a gossip of value 0 shares gossips

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 22w42a
    • 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.

            Fantastime [Mojang] Maxime Lebrot
            apple502j apple502j
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: