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 net.kyori.adventure.nbt.CompoundBinaryTag nbt, @NotNull 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 BlockPredicate
Matches all blocks.static final StructCodec
<BlockPredicate> static final NetworkBuffer.Type
<BlockPredicate> static final BlockPredicate
Matches no blocks. -
Constructor Summary
ConstructorsConstructorDescriptionBlockPredicate
(@NotNull net.kyori.adventure.nbt.CompoundBinaryTag nbt) BlockPredicate
(@NotNull Block... blocks) BlockPredicate
(@NotNull PropertiesPredicate state) BlockPredicate
(@NotNull RegistryTag<Block> blocks) BlockPredicate
(@Nullable RegistryTag<Block> blocks, @Nullable PropertiesPredicate state, @Nullable net.kyori.adventure.nbt.CompoundBinaryTag nbt) BlockPredicate
(@Nullable RegistryTag<Block> blocks, @Nullable PropertiesPredicate state, @Nullable net.kyori.adventure.nbt.CompoundBinaryTag nbt, @NotNull DataComponentPredicates components) Creates an instance of aBlockPredicate
record class. -
Method Summary
Modifier and TypeMethodDescription@Nullable RegistryTag
<Block> blocks()
Returns the value of theblocks
record component.@NotNull DataComponentPredicates
Returns the value of thecomponents
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
-
CODEC
-
-
Constructor Details
-
BlockPredicate
-
BlockPredicate
-
BlockPredicate
-
BlockPredicate
public BlockPredicate(@NotNull @NotNull net.kyori.adventure.nbt.CompoundBinaryTag nbt) -
BlockPredicate
public BlockPredicate(@Nullable @Nullable RegistryTag<Block> blocks, @Nullable @Nullable PropertiesPredicate state, @Nullable @Nullable net.kyori.adventure.nbt.CompoundBinaryTag nbt) -
BlockPredicate
public BlockPredicate(@Nullable @Nullable RegistryTag<Block> blocks, @Nullable @Nullable PropertiesPredicate state, @Nullable @Nullable net.kyori.adventure.nbt.CompoundBinaryTag nbt, @NotNull @NotNull DataComponentPredicates components) Creates an instance of aBlockPredicate
record 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 thecomponents
record component.- Returns:
- the value of the
components
record component
-