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

Loot Tables: "multiply_total" has broken %.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • None
    • Minecraft 1.12.2
    • Unconfirmed

      I noticed the attributes which modify the health aren't the same.
      For example, in a "give" command, we use an attribute to modify total health to -90%.
      For this, I use "Operation:2".
      Command:
      /give @p minecraft:diamond_sword 1 0 {AttributeModifiers:[

      {AttributeName:"generic.maxHealth",Name:"generic.maxHealth",Amount:-0.9,Operation:2,UUIDLeast:107814,UUIDMost:884287,Slot:"mainhand"}

      ]}

      Default world. No other commands. When I hold this sword, my hearts are reduced from 10 to 1, which makes sense. (10-90%=1)

      Now to the problem part:
      With loot tables we create the same diamond sword with -90% health attribute.
      For this we create a new loot table. (DOWNLOAD the .zip and place into your world in /data)
      However instead of "Operation:2", it uses the "multiply_total", and we add the amount -0.9.

      Ingame, when we hold the sword the health is supposed to be 1 heart. (10-90%=1)
      HOWEVER, it shows 2 hearts.

      PROBLEM: It shows 2 hearts, bcs the code likes for some reason to change your amout you enter to a really close one. Example here: I entered "-0.9" and when the loot was generated, the item had an amout of "-0.899999..." (Look at the SCREENSHOT here.)

      This was a test, basicly the generated items wont take the numbers entered 1:1, eventhough it is clearly defined in the loot table. The true, generated number is always a really close one to the entered number, which can mess things up.

      Pool:

      {
          "pools": [
              {
                  "rolls": 1,
                  "entries": [
                      {
                          "type": "item",
                          "weight": 1,
                          "name": "minecraft:diamond_sword",
                          "functions": [
                              {
                                  "function": "set_attributes",
                                  "modifiers": [
                                      {
                                          "attribute": "generic.maxHealth",
                                          "operation": "multiply_total",
                                          "amount": -0.9,
                                          "name": "Health",
                                          "slot": "mainhand"
                                      }
                                  ]
                              }
                          ]
                      }
                  ]
              }
          ]
      }
      

      I hope I explained it somehow clear enough to understand.

        1. loot_tables.zip
          0.9 kB
        2. screenshot.png
          screenshot.png
          1.11 MB

            Unassigned Unassigned
            Nefashus Eric
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: