Interface IRegistryFilter<T>


@Experimental @NonExtendable public interface IRegistryFilter<T>
Filters registry object based on set of string rules.

Rule Operators:

  • @namespace - include objects based on their namespace location.
  • #tag - include objects based on data pack tags.
  • /regex/ - include objects based on regular expression.
  • default - include objects with specific ID.

An exclamation mark (!) prefix can be added which negates the pattern. Any entries matching previous rules will be removed from it. Can be combined with other rule to exclude what matches the rule.

Note: Instances of IRegistryFilter should only be obtained once, unless the ruleset is changed.

Example

  • @aether - include all block from the aether namespace
  • #minecraft:planks - include all blocks in the planks tag
  • /.*_ore/ - include all blocks that ends with _ore
  • minecraft:iron_block - include only the iron block
  • !/.*:oak_.*$/ - exclude all blocks that its path start with oak_
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Comment to be used with as a file header.
    Returns read-only collection containing all objects that matches the filter.
    boolean
    matches(T object)
    Returns whether the filter matches the object.
    of(ResourceKey<? extends Registry<T>> registryKey)
     
  • Method Details

    • of

      static <T> IRegistryFilter.Builder<T> of(ResourceKey<? extends Registry<T>> registryKey)
    • getHeader

      static String getHeader()
      Comment to be used with as a file header.

      Not a constant so it won't be inlined as it can change.

    • matches

      boolean matches(T object)
      Returns whether the filter matches the object.

      Note: When not in world, this will always return false.

    • getMatches

      Collection<T> getMatches()
      Returns read-only collection containing all objects that matches the filter.

      Note: When not in world, this will always return empty collection.