Class NbtPathExpressionParseHandlerBooleanLogicalAdapter

java.lang.Object
org.cyclops.cyclopscore.nbt.path.parse.NbtPathExpressionParseHandlerBooleanLogicalAdapter
All Implemented Interfaces:
INbtPathExpressionParseHandler
Direct Known Subclasses:
NbtPathExpressionParseHandlerBooleanLogicalAnd, NbtPathExpressionParseHandlerBooleanLogicalOr

public abstract class NbtPathExpressionParseHandlerBooleanLogicalAdapter extends Object implements INbtPathExpressionParseHandler
  • Constructor Details

    • NbtPathExpressionParseHandlerBooleanLogicalAdapter

      protected NbtPathExpressionParseHandlerBooleanLogicalAdapter(String relation)
  • Method Details

    • getLogicalValue

      protected abstract boolean getLogicalValue(boolean left, Supplier<Boolean> right)
    • isTruthy

      public static boolean isTruthy(net.minecraft.nbt.Tag tag)
      Determine if a tag is truthy. ByteTag with value 1 is true, 0 is false. Any other non-null tag is considered true. This follows the same logic as INbtPathExpression.test(Tag).
      Parameters:
      tag - The tag to check
      Returns:
      true if the tag is truthy, false otherwise
    • findExpressionEnd

      public static int findExpressionEnd(String expression, int start)
      Find the end position of an expression, stopping at logical operators or closing parenthesis. This method is shared by logical operator handlers to identify expression boundaries.
      Parameters:
      expression - The full expression string
      start - The starting position to search from
      Returns:
      The position where the expression ends
    • handlePrefixOf

      @Nullable public INbtPathExpressionParseHandler.HandleResult handlePrefixOf(String nbtPathExpression, int pos)
      Description copied from interface: INbtPathExpressionParseHandler
      Try to create an expression from the given position in the given expression.
      Specified by:
      handlePrefixOf in interface INbtPathExpressionParseHandler
      Parameters:
      nbtPathExpression - A string representation of an NBT path expression.
      pos - The position in the string to start from.
      Returns:
      The handler result.