Getting properties of a block type fails

Hello, I am trying to check if a block type is a solid block. Whenever I try to do this, the optional is not present. Here is the code I am using:

BlockTypes.GLASS.getProperty(SolidCubeProperty.class).isPresent();

Note: Using BlockTypes.GLASS is temporary and just for testing. It will be replaced by a variable.

Does anyone know what I am doing wrong?

I think that should work, I assume if it isn’t present that means it’s false and even if it is, it might not be true. The JDocs for SolidCubeProperty show that it only applies to blocks that can have torches placed on their sides, so glass will still not have it.

Have you tried it with BlockTypes.STONE?

If an optional has a value isPresent() will return true, no matter if the value the optional contains is true or false. (Example)

I have also tried with other solid blocks such as bedrock and the optional is still not present.

It’s possible the property isn’t fully implemented. Can anyone confirm? Have you tried other types of block properties?

That is what I was thinking; however, the property works on a location. Maybe the property is not applicable to a BlockType? It seems like it should work on BlockTypes though.

Properties are implemented. Try on the block state: BlockTypes.GLASS.getDefaultState().getProperty(...)

Thanks, but unfortunately that still did not work.

Just looked at the implementation.

Looks like it is implemented, but incorrectly. It’s currently only implemented to work on Locations, rather than on BlockTypes or their BlockStates.

Made a pull request for this here:

@ZephireNZ Thanks for taking the time to fix this!

@Flibio ny changes are now in Sponge. They’re already in SpongeForge, SpongeVanilla will too once they update.

1 Like