mojira.dev
MC-44282

/give, /summon, /setblock "CustomPotionEffects" tag Applies 'integer' instead of 'byte'

The "CustomPotionEffects" tag contains the following:

byte | Id
byte | Amplifier
int | Duration
byte | Ambient

Via: http://minecraft.gamepedia.com/Player.dat_format#Potion_Effects

However, when using the /give, /summon, or /setblock commands that includes a potion using the "CustomPotionEffects" tag, all of the above 'byte' tags are incorrectly set to 'integer' on the item or entity. This can cause complications when attempting to apply the effect to a mob or player, notably the Amplifier.

This can be observed using the following command and checking its NBT data:

/give @p potion 1 16450 {CustomPotionEffects:[{Id:1,Amplifier:0,Duration:20,Ambient:1}]}
/give @p potion 1 16450 {CustomPotionEffects:[{Id:1,Amplifier:0,Duration:20,Ambient:1}]}

or

/summon ThrownPotion ~ ~20 ~ {Potion:{id:373,Damage:16450,tag:{CustomPotionEffects:[{Id:1,Amplifier:0,Duration:20,Ambient:1}]}}}
/summon ThrownPotion ~ ~20 ~ {Potion:{id:373,Damage:16450,tag:{CustomPotionEffects:[{Id:1,Amplifier:0,Duration:20,Ambient:1}]}}}

or

/setblock ~ ~1 ~ chest 0 replace {Items:[{id:373,Damage:16450,Count:1,Slot:0,tag:{CustomPotionEffects:[{Id:1,Amplifier:0,Duration:20,Ambient:1}]}}]}
/setblock ~ ~1 ~ chest 0 replace {Items:[{id:373,Damage:16450,Count:1,Slot:0,tag:{CustomPotionEffects:[{Id:1,Amplifier:0,Duration:20,Ambient:1}]}}]}

To confirm that the tag-types should be byte where listed, the /effect command can be used, which does apply the correct tag-types (save for Ambient, which it cannot apply):

/effect @p 1 100 0
/effect @p 1 100 0

For beacons, all tags are applied correctly, including the Ambient tag. Quick command to construct a minimal beacon pyramid for observation (in the north direction):

/summon FallingSand ~ ~1 ~-3 {TileID:138,TileEntityData:{Primary:1},Time:1,Motion:[0.0,0.25,0.0],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[0.15,0.0,0.0],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[0.0,0.0,0.15],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[-0.15,0.0,0.0],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[0.0,0.0,-0.15],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[0.15,0.0,0.15],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[-0.15,0.0,0.15],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[-0.15,0.0,-0.15],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[0.15,0.0,-0.15],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[0.0,0.0,0.0]}}}}}}}}}}}}}}}}}}}
/summon FallingSand ~ ~1 ~-3 {TileID:138,TileEntityData:{Primary:1},Time:1,Motion:[0.0,0.25,0.0],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[0.15,0.0,0.0],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[0.0,0.0,0.15],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[-0.15,0.0,0.0],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[0.0,0.0,-0.15],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[0.15,0.0,0.15],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[-0.15,0.0,0.15],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[-0.15,0.0,-0.15],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[0.15,0.0,-0.15],Riding:{id:FallingSand,Riding:{id:FallingSand,TileID:42,Time:1,Motion:[0.0,0.0,0.0]}}}}}}}}}}}}}}}}}}}

Relates slightly to https://mojang.atlassian.net/browse/MC-35127 except that one involves an always incorrect tag-type (not necessarily through commands), while the CustomPotionEffects tag-types are incorrectly applied through dataTags.

Comments 3

Try doing something like #b, rather than just #, I think that should make it a byte.

Good idea. Tried it, and unfortunately the tag-type turns into a string.

Actually, Ezekiel was correct. You must represent Ambient and ShowParticles as bytes because they are parsed as Booleans when ActiveEffects deserializes them. To achieve this, use "Ambient:1b" or "Ambient:true" and likewise "ShowParticles:0b" or "ShowParticles:false" (without quotes, of course!). I haven't gotten a String tag from doing either.

Using the correct tag types is good practice; the game is only lenient with regards to Byte/Short/Integer (and possibly Double/Float) when it needs to resolve a Number (this is why it never failed to interpret Id correctly, despite saving it incorrectly). As demonstrated here, it fails to deserialize Integer to Byte when it wants to resolve Boolean - and with good reason, honestly.

You should clean up this ticket, as the heart of your issue wasn't even formatting. The following behaves correctly:

/give @p minecraft:potion 1 100 {CustomPotionEffects:[{Id:1b,Amplifier:0b,ShowParticles:0b,Duration:100000}]}
/give @p minecraft:potion 1 100 {CustomPotionEffects:[{Id:1b,Amplifier:0b,ShowParticles:0b,Duration:100000}]}

If you give the correct formatting to your examples, they will save correctly. However, they will still fail for another reason: splash potions fail to acknowledge the Amplifier and Ambient tags. You should either make a new ticket for that and allow this one to be closed, or change this ticket to that. Normal potions acknowledge Amplifier and Ambient just fine, but splash potions do not.

Skylinerw

(Unassigned)

Unconfirmed

/give, /setblock, /summon, CustomPotionEffects, NBT, byte, dataTag, integer

Minecraft 1.7.4, Minecraft 14w04b, Minecraft 14w05b, Minecraft 14w06a, Minecraft 14w06b

Retrieved