Spongeapi: StateMatcher can't be created without any traits

Created on 3 May 2017  路  3Comments  路  Source: SpongePowered/SpongeAPI

BlockState.StateMatcher doesn't check if the traits for the StateMatcher is empty. Found this while writing a config serializer and deserializer for StateMatcher.

The fix should be trivial.
https://github.com/SpongePowered/SpongeAPI/blob/a4aaeec0007ebd9c3570e41382454e81f875e0a1/src/main/java/org/spongepowered/api/block/BlockState.java#L289

bug

Most helpful comment

You can open an issue about that. If anything, we could consider making it DataSerializable since that is how we expose serialization.

All 3 comments

For me it looks like the actual problem is that it is creating the array with one element less than required, it should just create the array using this.traits.size().

Guess I looked too long at it :P. Would it also be an idea to expose the inner fields in the matcher to allow for easier serialization (have to use reflection at the moment)?

You can open an issue about that. If anything, we could consider making it DataSerializable since that is how we expose serialization.

Was this page helpful?
0 / 5 - 0 ratings