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

Effect amplifier is read/written as byte from NBT despite being stored as an integer

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Resolution: Unresolved
    • Minecraft 1.12, Minecraft 1.12.1 Pre-Release 1, Minecraft 1.12.1, Minecraft 17w50a, Minecraft 1.13.2, Minecraft 19w04b, 1.16.4, 20w46a, 21w06a, 21w16a, 21w17a, 1.17, 1.17.1 Pre-release 2, 1.17.1, 21w44a, 1.18.1, 1.18.2
    • None
    • Confirmed
    • (Unassigned)

    Description

      The bug

      Effect amplifiers are read as byte (-128 to 127) instead of as an integer (-2,147,483,648 to 2,147,483,647) from NBT.

      How to reproduce

      1. Give yourself jump boost with an amplifier higher than 127 using /effect
        /effect give @s jump_boost 100 128
        
      2. Try to jump
        → You cannot jump (see also MC-90198)
      3. Reopen the world
        → You now have jump boost with an amplifier of -128 when read (though will be considered 0 when an amplifier obtained via NBT is less than 0)

      Code analysis

      Based on 1.12 decompiled using MCP 9.40 PRE 1

      The methods net.minecraft.potion.PotionEffect.readCustomPotionEffectFromNBT(NBTTagCompound) and net.minecraft.potion.PotionEffect.writeCustomPotionEffectToNBT(NBTTagCompound) reads/writes the amplifier as a byte, while it is stored in-memory as an integer.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              marcono1234 [Mod] Marcono1234
              Votes:
              10 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                CHK: