mojira.dev
MC-118857

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

The bug

Effect amplifiers are read/written as byte (-128 to 127) from/to NBT instead of an integer (-2,147,483,648 to 2,147,483,647) which is how it is stored in memory. This causes a change is behavior when the effect is reloaded from NBT is the amplifier is above 127.

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.

Related issues

Attachments

Comments

migrated
[media][media]
bemoty

Can confirm for MC 1.12.1. I thought effects with a level over 4 aren't supported though?

Avoma

Can confirm in 21w06a.

Avoma

Can confirm in 21w16a.

Avoma

Can confirm in 21w17a.

Avoma

Can confirm in 1.17.

Doc

Confirm in 1.17.1 PRE1 and PRE2

ampolive

Can confirm in 1.17.1.

ampolive

Can confirm in 21w44a.

Avoma

Can confirm in 1.18.1.

Avoma

Can confirm in 1.18.2.

Avoma

Can confirm in 1.19.2.

migrated

Confirmed for 1.19.2; interestingly, 1.19 changed the potion ID to use an int (string would've been better), but not the amplifier.

IllogicalSong

Affects haste as well, level 128 causes weird issues, haste won't apply unless you are using the correct tool

[media]
Moesh

This is a feature request.

migrated

How so? It literally causes a changing of behavior of effects on logging out and back in when the amplifier is over 127. While yes, it's an unsupported amplifier, this does make them extremely unreliable to use.

A highly similar issue with enchantment levels was deemed valid and fixed: MC-131290.

migrated

@unknown, seeing as you haven't touched this report since May 2022, would it be OK if I became the reporter? I'll keep this updated accordingly.

[MOD] Greymagic27

@unknown please do not spam old issues with feedback. Please send this to the feedback site or discord server.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

migrated

gegy

Confirmed

Platform

Low

Entities, Networking

effect, effect-amplifier, nbt

Minecraft 1.12, Minecraft 1.12.1 Pre-Release 1, Minecraft 1.12.1, Minecraft 17w50a, Minecraft 1.13.2, ..., 1.19.4, 1.20 Pre-release 6, 1.20.1, 1.20.4, 23w51b

24w05b

Retrieved