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 RegistryTag<Block> blocks, @Nullable PropertiesPredicate state, @Nullable CompoundBinaryTag nbt, DataComponentPredicates components)
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
FieldsModifier and TypeFieldDescriptionstatic final BlockPredicateMatches all blocks.static final StructCodec<BlockPredicate> static final NetworkBuffer.Type<BlockPredicate> static final BlockPredicateMatches no blocks. -
Constructor Summary
ConstructorsConstructorDescriptionBlockPredicate(Block... blocks) BlockPredicate(@Nullable RegistryTag<Block> blocks, @Nullable PropertiesPredicate state, @Nullable CompoundBinaryTag nbt) BlockPredicate(@Nullable RegistryTag<Block> blocks, @Nullable PropertiesPredicate state, @Nullable CompoundBinaryTag nbt, DataComponentPredicates components) Creates an instance of aBlockPredicaterecord class.BlockPredicate(RegistryTag<Block> blocks) -
Method Summary
Modifier and TypeMethodDescriptionblocks()Returns the value of theblocksrecord component.Returns the value of thecomponentsrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.nbt()Returns the value of thenbtrecord component.state()Returns the value of thestaterecord component.booleanfinal StringtoString()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
-
CODEC
-
-
Constructor Details
-
BlockPredicate
-
BlockPredicate
-
BlockPredicate
-
BlockPredicate
-
BlockPredicate
public BlockPredicate(@Nullable @Nullable RegistryTag<Block> blocks, @Nullable @Nullable PropertiesPredicate state, @Nullable @Nullable CompoundBinaryTag nbt) -
BlockPredicate
public BlockPredicate(@Nullable @Nullable RegistryTag<Block> blocks, @Nullable @Nullable PropertiesPredicate state, @Nullable @Nullable CompoundBinaryTag nbt, DataComponentPredicates components) Creates an instance of aBlockPredicaterecord class.
-
-
Method Details
-
test
-
toString
-
hashCode
-
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
-
state
-
nbt
-
components
Returns the value of thecomponentsrecord component.- Returns:
- the value of the
componentsrecord component
-