From fcfa022232f28627b9aebc78a8b3ddac63ea76aa Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 30 Dec 2019 02:27:20 -0600 Subject: [PATCH] Clean up BlockOptionalMeta comment and add behavioral clarification --- .../baritone/api/utils/BlockOptionalMeta.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/api/java/baritone/api/utils/BlockOptionalMeta.java b/src/api/java/baritone/api/utils/BlockOptionalMeta.java index 451d95eb2..020df8146 100644 --- a/src/api/java/baritone/api/utils/BlockOptionalMeta.java +++ b/src/api/java/baritone/api/utils/BlockOptionalMeta.java @@ -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. + *

+ * 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)); }