Expected behavior
FireworkMeta#get/setPower methods respect Vanilla bounds on the power.
Observed/Actual behavior
FireworkMeta#setPower restricts the to >= 0 and < 128 when a value of
Steps/models to reproduce
To produce the error linked below, just serialize and then deserialize the itemstack you get from /give @p minecraft:fireworks 1 0 {Fireworks:{Flight:128,Explosions:[]}}
Plugin and Datapack List
just my test plugin
Paper version
This server is running Paper version git-Paper-"41263d9" (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT) (Git: 41263d9)
You are running the latest version
Previous version: git-Paper-"cccb5d8" (MC: 1.18.1)
Other
Mentioned in #7409, but should have its own issue because there's a discussion to be had about the correct fix.
Issue
Minecraft uses the byte nbt tag to store the firework rocket's power (or flight) which produces values of between -128 and 127 (inclusive). In the ctor for CraftMetaFirework, that value is converted to an unsigned int with
this.power = 0xff & fireworks.getByte(FLIGHT.NBT);
which will produce values between 0 and 255 (inclusive).
That value is then returned by FireworkMeta#getPower.
When the itemmeta is serialized with craftbukkit's api serialization for metas, that 0-255 value is stored, but when it's deserialized
this happens. (from @Phoenix616)
Possible solutions
Allow values between 0 and 255 to be passed into setPower and note that values > 127 will be turned into negative numbers.
OR
Keep the validations and just in fix the problem in deserialization.
Either one I think requires some note in the javadocs that getPower can return between 0 and 255 not 0-127 that might be inferred from the javadocs on setPower
Expected behavior
FireworkMeta#get/setPower methods respect Vanilla bounds on the power.
Observed/Actual behavior
FireworkMeta#setPowerrestricts the to >= 0 and < 128 when a value ofSteps/models to reproduce
To produce the error linked below, just serialize and then deserialize the itemstack you get from
/give @p minecraft:fireworks 1 0 {Fireworks:{Flight:128,Explosions:[]}}Plugin and Datapack List
just my test plugin
Paper version
This server is running Paper version git-Paper-"41263d9" (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT) (Git: 41263d9)
You are running the latest version
Previous version: git-Paper-"cccb5d8" (MC: 1.18.1)
Other
Mentioned in #7409, but should have its own issue because there's a discussion to be had about the correct fix.
Issue
Minecraft uses the byte nbt tag to store the firework rocket's power (or flight) which produces values of between -128 and 127 (inclusive). In the ctor for CraftMetaFirework, that value is converted to an unsigned int with
which will produce values between 0 and 255 (inclusive).
That value is then returned by
FireworkMeta#getPower.When the itemmeta is serialized with craftbukkit's api serialization for metas, that 0-255 value is stored, but when it's deserialized
this happens. (from @Phoenix616)
Possible solutions
Allow values between 0 and 255 to be passed into setPower and note that values > 127 will be turned into negative numbers.
OR
Keep the validations and just in fix the problem in deserialization.
Either one I think requires some note in the javadocs that getPower can return between 0 and 255 not 0-127 that might be inferred from the javadocs on setPower