GravityAffected property set to false on sand BlockType?

Hi,

I meet some difficulties to found all block/blockstate affected by gravity.

Using GravityAffected property return me a false value even using BlockType or BlockState.

BlockTypes :

final Collection<BlockType> blocks = Sponge.getRegistry().getAllOf(BlockType.class);
        blocks.parallelStream().filter(block -> {
            final Optional<GravityAffectedProperty> optProp = block.getProperty(GravityAffectedProperty.class);
            return optProp.isPresent() && optProp.get().getValue().booleanValue();
        })

BlockStates :

blocks.parallelStream().map(blockType -> blockType.getAllBlockStates()).flatMap(l -> l.stream()).filter(blockState -> {
            final Optional<GravityAffectedProperty> optProp = blockState.getProperty(GravityAffectedProperty.class);
            return optProp.isPresent() && optProp.get().getValue().booleanValue();
        }).collect(Collectors.toList());

Returns me an empty list. I use intelliJ inspector, and indeed, that property is false, even for sand.
Do you have any clue of how could I proceed ?

In Forge, I think I did an instanceof FallingBlock test on BlockType

I’ve just found BlockTypes.GRAVEL.getClass().getSuperClass() == net.minecraft.block.BlockFalling
So I can use instanceof, but I should use minecraft native classes. Do you have any alternative ?

The GravetyAffectedProperty is for Entities I belive.

As it stands currently I do belive that there is no way to check using Sponge. Using NMS there is

I’ve just verified, GravityAffectedProperty is for blocks but it might be not implemented yet, idk.

I found GravityAffectedPropertyStore in SpongeCommon, and it’s looks like implemented using an isAssignableFrom on BlockFalling class. I don’t know how you handle it internaly, I wish use the sponge API as much as possible. I would help If you are looking for a pull request, howerver I need some guideline or example on similar implemented property :slight_smile:

Turns out, it’s a bug. It’s doing the type check on the BlockState instead of the BlockType. I’ll fix that.

1 Like

Sorry it took me so long to get to this. I just pushed a fix for it. It should be available for download in a few minutes.

1 Like