Uploaded image for project: 'Minecraft (Bedrock codebase)'
  1. Minecraft (Bedrock codebase)
  2. MCPE-180074

"minecraft:damage" component value uses signed 16-bit integer

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 1.20.80.23 Preview
    • None
    • Unconfirmed
    • Windows

      According to the [official docs|https://learn.microsoft.com/en-us/minecraft/creator/reference/content/itemreference/examples/itemcomponents/minecraft_damage?view=minecraft-bedrock-stable] the "minecraft:damage" component supports an integer type. However, upon further testing, it seems to be using a signed 16-bit integer. This causes certain ranges of values to appear as negative which causes the Bedrock Engine to think the value is a negative number, even if the value is a positive number.

      This occurs due to the 2's complements for 16-bit integer. The negative ranges formula is, inclusive beginning and exclusive ending where x can be any arbitrary number.

      [256*(256x+128), 256*(256(x+1)))

      As an example, if x is 0, the range for negative values are [32768, 65536) which the below reproduction method below supports

      Reproduce:

      • Download the attached pack below
      • Import the pack into Preview 1.20.80.23
      • Enable the Content Log GUI by going to Settings > Creator > Enable Content Log GUI
      • Give yourself the following items:
        • mojira:damage_32767
        • mojira:damage_32768
        • mojira:damage_32769
        • mojira:damage_65536
      • Open your inventory and hover over the items

      Expected Result:

      • mojira:damage_32767 should have a "+255 attack damage" tooltip due to a related bug(MCPE-180073)
      • mojira:damage_32768 should have no "attack damage" tooltip due to a related bug(MCPE-180073)
      • mojira:damage_32769 should have a "+1 attack damage" tooltip due to a related bug(MCPE-180073)
      • mojira:damage_32769 should have no "attack damage" tooltip due to a related bug(MCPE-180073)

      Actual Result:

      • mojira:damage_32767 has a "+255 attack damage" tooltip. The item does parse correctly.
      • mojira:damage_32768 throws a content log error. The item does not parse correctly thus rendering the item broken.
      • mojira:damage_32769 throws a content log error. The item does not parse correctly thus rendering the item broken.
      • mojira:damage_65536 has no "attack damage" tooltip. The item does parse correctly.
      • For the items that do not parse correctly, a message in the Content Log should appear matching the screenshot attached below

        1. mojira.mcpack
          2 kB
          SmokeyStack
        2. Screenshot 2024-03-26 172706.png
          385 kB
          SmokeyStack

            SmokeyStack SmokeyStack
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: