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.
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 Summary
Modifier and TypeFieldDescriptionstatic final BlockPredicate
Matches all blocks.static final BinaryTagSerializer
<BlockPredicate> static final NetworkBuffer.Type
<BlockPredicate> static final BlockPredicate
Matches no blocks. -
Constructor Summary
ConstructorDescriptionBlockPredicate
(@NotNull net.kyori.adventure.nbt.CompoundBinaryTag nbt) BlockPredicate
(@NotNull Block... blocks) BlockPredicate
(@NotNull BlockTypeFilter blocks) BlockPredicate
(@NotNull PropertiesPredicate state) BlockPredicate
(@Nullable BlockTypeFilter blocks, @Nullable PropertiesPredicate state, @Nullable net.kyori.adventure.nbt.CompoundBinaryTag nbt) Creates an instance of aBlockPredicate
record class. -
Method Summary
Modifier and TypeMethodDescription@Nullable BlockTypeFilter
blocks()
Returns the value of theblocks
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.@Nullable net.kyori.adventure.nbt.CompoundBinaryTag
nbt()
Returns the value of thenbt
record component.@Nullable PropertiesPredicate
state()
Returns the value of thestate
record component.boolean
final String
toString()
Returns a string representation of this record class.
-
Field Details
-
ALL
Matches all blocks. -
NONE
Matches no blocks.
Works based on the property that an exact property will never match a property which doesnt exist on any block.
-
NETWORK_TYPE
-
NBT_TYPE
-
-
Constructor Details
-
BlockPredicate
-
BlockPredicate
-
BlockPredicate
-
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 aBlockPredicate
record class.
-
-
Method Details
-
test
-
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. -
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. -
equals
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 withObjects::equals(Object,Object)
. -
blocks
Returns the value of theblocks
record component.- Returns:
- the value of the
blocks
record component
-
state
Returns the value of thestate
record component.- Returns:
- the value of the
state
record component
-
nbt
@Nullable public @Nullable net.kyori.adventure.nbt.CompoundBinaryTag nbt()Returns the value of thenbt
record component.- Returns:
- the value of the
nbt
record component
-