Record Class BlockPredicate

java.lang.Object
java.lang.Record
net.minestom.server.instance.block.predicate.BlockPredicate
Record Components:
blocks - The block names/tags to match.
state - The block properties to match.
nbt - The block nbt to match.
All Implemented Interfaces:
Predicate<Block>

public record BlockPredicate(@Nullable BlockTypeFilter blocks, @Nullable PropertiesPredicate state, @Nullable net.kyori.adventure.nbt.CompoundBinaryTag nbt) extends Record implements Predicate<Block>

A predicate to filter blocks based on their name, properties, and/or nbt.

Note: Inline with vanilla, providing none of the filters will match any block.

Note: To match the vanilla behavior of comparing block NBT, the NBT predicate will ONLY match data which would be sent to the client eg with BlockHandler.getBlockEntityTags(). This is relevant because this structure is used for matching adventure mode blocks and must line up with client prediction.

  • Field Details

  • Constructor Details

    • BlockPredicate

      public BlockPredicate(@NotNull @NotNull BlockTypeFilter blocks)
    • BlockPredicate

      public BlockPredicate(@NotNull @NotNull Block... blocks)
    • BlockPredicate

      public BlockPredicate(@NotNull @NotNull PropertiesPredicate state)
    • BlockPredicate

      public BlockPredicate(@NotNull @NotNull net.kyori.adventure.nbt.CompoundBinaryTag nbt)
    • BlockPredicate

      public BlockPredicate(@Nullable @Nullable BlockTypeFilter blocks, @Nullable @Nullable PropertiesPredicate state, @Nullable @Nullable net.kyori.adventure.nbt.CompoundBinaryTag nbt)
      Creates an instance of a BlockPredicate record class.
      Parameters:
      blocks - the value for the blocks record component
      state - the value for the state record component
      nbt - the value for the nbt record component
  • Method Details

    • test

      public boolean test(@NotNull @NotNull Block block)
      Specified by:
      test in interface Predicate<Block>
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • blocks

      @Nullable public @Nullable BlockTypeFilter blocks()
      Returns the value of the blocks record component.
      Returns:
      the value of the blocks record component
    • state

      @Nullable public @Nullable PropertiesPredicate state()
      Returns the value of the state record component.
      Returns:
      the value of the state record component
    • nbt

      @Nullable public @Nullable net.kyori.adventure.nbt.CompoundBinaryTag nbt()
      Returns the value of the nbt record component.
      Returns:
      the value of the nbt record component