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?
Flibio
May 21, 2016, 10:47pm
5
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 BlockType
s though.
Properties are implemented. Try on the block state: BlockTypes.GLASS.getDefaultState().getProperty(...)
Flibio
May 22, 2016, 12:19am
7
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 Location
s, rather than on BlockType
s or their BlockState
s.
Made a pull request for this here:
SpongePowered:master
← ZephireNZ:fix/properties
opened 05:05AM - 22 May 16 UTC
Flibio
May 22, 2016, 11:43am
10
@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