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 BlockPredicateMatches all blocks.static final StructCodec<BlockPredicate> static final NetworkBuffer.Type<BlockPredicate> static final BlockPredicateMatches 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 aBlockPredicaterecord class. -
Method Summary
Modifier and TypeMethodDescription@Nullable RegistryTag<Block> blocks()Returns the value of theblocksrecord component.@NotNull DataComponentPredicatesReturns 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.@Nullable net.kyori.adventure.nbt.CompoundBinaryTagnbt()Returns the value of thenbtrecord component.@Nullable PropertiesPredicatestate()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
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 aBlockPredicaterecord 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 theblocksrecord component.- Returns:
- the value of the
blocksrecord component
-
state
Returns the value of thestaterecord component.- Returns:
- the value of the
staterecord component
-
nbt
@Nullable public @Nullable net.kyori.adventure.nbt.CompoundBinaryTag nbt()Returns the value of thenbtrecord component.- Returns:
- the value of the
nbtrecord component
-
components
Returns the value of thecomponentsrecord component.- Returns:
- the value of the
componentsrecord component
-