Class OnDatapackSyncEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.OnDatapackSyncEvent

public class OnDatapackSyncEvent extends net.neoforged.bus.api.Event
Fires when a player joins the server or when the reload command is ran, before tags and crafting recipes are sent to the client. Send datapack data to clients when this event fires.
  • Field Details

    • playerList

      private final PlayerList playerList
    • player

      @Nullable private final @Nullable ServerPlayer player
    • recipeTypesToSend

      private final it.unimi.dsi.fastutil.objects.ReferenceSet<RecipeType<?>> recipeTypesToSend
  • Constructor Details

    • OnDatapackSyncEvent

      public OnDatapackSyncEvent(PlayerList playerList, @Nullable @Nullable ServerPlayer player)
  • Method Details

    • getPlayerList

      public PlayerList getPlayerList()
      Gets the server's player list, containing all players, when the event fires.
      Returns:
      The server's player list.
    • getRelevantPlayers

      public Stream<ServerPlayer> getRelevantPlayers()
      Creates a stream of players that need to receive data during this event, which is the specified player (if present) or all players.
      Returns:
      A stream of players to sync data to.
    • getPlayer

      @Nullable public @Nullable ServerPlayer getPlayer()
      Gets the player that is joining the server, or null when syncing for all players, such as when the reload command runs.
      Returns:
      The player to sync datapacks to. Null when syncing for all players.
    • sendRecipes

      public void sendRecipes(RecipeType<?>... recipeTypes)
      Requests that all recipes of the given types should be sent to the players.
      See Also:
    • sendRecipes

      public void sendRecipes(Iterable<RecipeType<?>> recipeTypes)
      Requests that all recipes of the given types should be sent to the players.
      See Also:
    • getRecipeTypesToSend

      public Set<RecipeType<?>> getRecipeTypesToSend()
      Returns:
      The recipe types that have already been requested to be sent to the players.