How to get block variant?

But the Data API way, won’t necessarily work for modded blocks either.

The “variant=diorite” is an inbuilt Mojang concept into the block, which in Sponge is called a trait.

What you really want, is a way for a block to match a user inputtable string right? like in a config?

So you could either test against BlockTypes or BlockStates. However, BlockStates are difficult to work with, as some of their traits that distinguish block states are useless for some uses, take redstone power for a jobs plugin for example. So what we need, is a serializable Predicate Something that can test blocks to see if they match (similar to your regex idea) and be easy to input by users.

Blood suggested that we use the old meta values that blocks had, but all that does is restrict you to dealing with specific blockstates, and you would still need to create a set of blockstates that are aliased under another name, e.g. Leaves would cover blocktypes leaves and leaves2…

The other idea blood had, was that the blockstates be dumped to a file as strings, so it was at least easy to copy them and refer to them in config files, in order to create these sets, This is a somewhat better idea and would be the simplest solution that seems feasible.

However I propose another solution, slightly more complex, but certainly more flexible and easy to use for more advanced tests, resulting in less work for server admins that can understand the concept.

3 Likes