Clean up BlockOptionalMeta comment and add behavioral clarification

This commit is contained in:
Brady 2019-12-30 02:27:20 -06:00
parent 220ee30d35
commit fcfa022232
No known key found for this signature in database
GPG Key ID: 73A788379A197567

View File

@ -188,13 +188,20 @@ public final class BlockOptionalMeta {
return (C) value;
}
/**
* Normalizes the specified blockstate by setting meta-affecting properties which
* are not being targeted by the meta parameter to their default values.
* <p>
* For example, block variant/color is the primary target for the meta value, so properties
* such as rotation/facing direction will be set to default values in order to nullify
* the effect that they have on the state's meta value.
*
* @param state The state to normalize
* @return The normalized block state
*/
public static IBlockState normalize(IBlockState state) {
IBlockState newState = state;
// TODO: Can the state not be normalized by simply doing...?
// return state.getBlock().getDefaultState();
// ???
for (IProperty<?> property : state.getProperties().keySet()) {
Class<?> valueClass = property.getValueClass();
if (normalizations.containsKey(property)) {
@ -224,6 +231,15 @@ public final class BlockOptionalMeta {
return newState;
}
/**
* Evaluate the target meta value for the specified state. The target meta value is
* most often that which is influenced by the variant/color property of the block state.
*
* @see #normalize(IBlockState)
*
* @param state The state to check
* @return The target meta of the state
*/
public static int stateMeta(IBlockState state) {
return state.getBlock().getMetaFromState(normalize(state));
}