Class AddPackFindersEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.AddPackFindersEvent
All Implemented Interfaces:
net.neoforged.fml.event.IModBusEvent

public class AddPackFindersEvent extends net.neoforged.bus.api.Event implements net.neoforged.fml.event.IModBusEvent
Fired on PackRepository creation to allow mods to add new pack finders.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final net.minecraft.server.packs.PackType
     
    private final Consumer<net.minecraft.server.packs.repository.RepositorySource>
     
    private final boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    AddPackFindersEvent(net.minecraft.server.packs.PackType packType, Consumer<net.minecraft.server.packs.repository.RepositorySource> sources, boolean trusted)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addPackFinders(net.minecraft.resources.ResourceLocation packLocation, net.minecraft.server.packs.PackType packType, net.minecraft.network.chat.Component packNameDisplay, net.minecraft.server.packs.repository.PackSource packSource, boolean alwaysActive, net.minecraft.server.packs.repository.Pack.Position packPosition)
    Helper method to register a pack found under the `resources/` folder.
    void
    addRepositorySource(net.minecraft.server.packs.repository.RepositorySource source)
    Adds a new source to the list of pack finders.
    net.minecraft.server.packs.PackType
     
    boolean
    Returns whether or not the pack repository being assembled is the one used to provide known packs to the client to avoid syncing from the server.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • packType

      private final net.minecraft.server.packs.PackType packType
    • sources

      private final Consumer<net.minecraft.server.packs.repository.RepositorySource> sources
    • trusted

      private final boolean trusted
  • Constructor Details

    • AddPackFindersEvent

      public AddPackFindersEvent(net.minecraft.server.packs.PackType packType, Consumer<net.minecraft.server.packs.repository.RepositorySource> sources, boolean trusted)
  • Method Details

    • addRepositorySource

      public void addRepositorySource(net.minecraft.server.packs.repository.RepositorySource source)
      Adds a new source to the list of pack finders.

      Sources are processed in the order that they are added to the event. Use Pack.Position.TOP to add high priority packs, and Pack.Position.BOTTOM to add low priority packs.

      Parameters:
      source - the pack finder
    • getPackType

      public net.minecraft.server.packs.PackType getPackType()
      Returns:
      the PackType of the pack repository being constructed.
    • addPackFinders

      public void addPackFinders(net.minecraft.resources.ResourceLocation packLocation, net.minecraft.server.packs.PackType packType, net.minecraft.network.chat.Component packNameDisplay, net.minecraft.server.packs.repository.PackSource packSource, boolean alwaysActive, net.minecraft.server.packs.repository.Pack.Position packPosition)
      Helper method to register a pack found under the `resources/` folder.
      Parameters:
      packLocation - Location of the pack to load. Namespace should be the modid of the pack owner and path is the location under `resources/` folder
      packType - Whether pack is a resourcepack or datapack
      packNameDisplay - The text that shows for the pack on the pack selection screen
      packSource - Controls whether the datapack is enabled or disabled by default. Resourcepacks are always disabled by default unless you set alwaysActive to true.
      alwaysActive - Whether the pack is forced active always. If false, players have to manually activate the pack themselves
      packPosition - Where the pack goes for determining pack applying order
    • isTrusted

      public boolean isTrusted()
      Returns whether or not the pack repository being assembled is the one used to provide known packs to the client to avoid syncing from the server.
      Returns:
      whether or not the pack repository being assembled is the one used to provide known packs to the client to avoid syncing from the server