Mojira Archive
MCM-1779

Float entity properties break when the range or default value that's specified does not have decimal places

Partner Rank: 3

Partner Team Reporting: Spark Universe

Verification Build: 1.21.0.23

Summary: Float entity properties break when the range or default value that's specified does not have decimal places

Impact: Breaks our production pipeline and requires workarounds

Repro Steps:

  1. Create an entity with an entity property like this:
"properties": {
    "spark:foo": {
        "type": "float",
        "client_sync": true,
        "default": 0,
        "range": [0, 1]
    }
}
  1. Load the entity into the game

Repro Rate: 10/10

Observed Results: The entity fails to load its properties with the following content log error:

minecraft:entity | description | Error loading property 'spark:foo': 'default' value does not match the specified type 'float'
minecraft:entity | description | Error loading property spark:foo
minecraft:entity | description | Error loading Actor Properties

Expected Results: The entity should load correctly.
JSON is not supposed to differentiate between 0 and 0.0. As a format, it only has the type "number", not float, int, signed int etc.
The value 0 written as 0 should be read as the correct type, like it is in every other file in add-ons.

Screenshots / Videos Attached: None

Regression Builds: Never worked

Notes: This is not much of an issue when writing the files by hand. But it becomes an issue when the file is handled by tools and recompiled, which is the case several times in our production pipeline. The .0 at the end of numbers gets lost in that step, similar to comments and indentation.
As a workaround, we have to write our floats as something like 0.0001, which is very hacky.

Unresolved

Jannis T

2024-05-07, 07:48 PM

2024-09-10, 01:12 PM

1

1

Future Release

-