Class BlockPredicate

java.lang.Object
com.github.darksoulq.abyssallib.world.block.BlockPredicate
All Implemented Interfaces:
Predicate<BlockInfo>

public class BlockPredicate extends Object implements Predicate<BlockInfo>
A sophisticated predicate used to evaluate and filter BlockInfo instances. This class allows for complex conditional checks against a block's identity, visual states, custom block entity properties, vanilla NBT data, and evaluation of nested predicates.
  • Field Details

    • CODEC

      public static final Codec<BlockPredicate> CODEC
      The primary codec used to serialize and deserialize entire BlockPredicate instances. Supports resolving registered predicates by their String ID or parsing full nested objects.
  • Constructor Details

    • BlockPredicate

      public BlockPredicate(net.kyori.adventure.key.Key id, List<Condition<Map.Entry<String, com.fasterxml.jackson.databind.JsonNode>>> states, List<Condition<Map.Entry<String, com.fasterxml.jackson.databind.JsonNode>>> properties, List<Condition<Map.Entry<String, com.fasterxml.jackson.databind.JsonNode>>> nbt, List<Condition<BlockPredicate>> predicates)
      Constructs a new BlockPredicate with the specified conditional rules.
      Parameters:
      id - The base block Key that must match (nullable for any block).
      states - The list of state-matching JSON data conditions.
      properties - The list of property-matching JSON data conditions.
      nbt - The list of NBT-matching JSON data conditions.
      predicates - The list of nested predicate conditions.
  • Method Details

    • builder

      public static BlockPredicate.Builder builder()
      Creates a new fluent builder instance for constructing a BlockPredicate.
      Returns:
      A new BlockPredicate.Builder instance.
    • equals

      public boolean equals(Object o)
      Compares this predicate against another object for logical equivalence.
      Overrides:
      equals in class Object
      Parameters:
      o - The object to compare.
      Returns:
      True if the object is an identical BlockPredicate.
    • hashCode

      public int hashCode()
      Generates a hash code based on the predicate's underlying conditions.
      Overrides:
      hashCode in class Object
      Returns:
      The integer hash code.
    • test

      public boolean test(BlockInfo info)
      Evaluates a BlockInfo against all configured conditions within this predicate.
      Specified by:
      test in interface Predicate<BlockInfo>
      Parameters:
      info - The BlockInfo to test.
      Returns:
      True if the block satisfies all identity, data, and nested rules; false otherwise.