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 Summary

    Fields
    Modifier and Type
    Field
    Description
    private final @Nullable net.minecraft.server.level.ServerPlayer
     
    private final net.minecraft.server.players.PlayerList
     
    private final it.unimi.dsi.fastutil.objects.ReferenceSet<net.minecraft.world.item.crafting.RecipeType<?>>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    OnDatapackSyncEvent(net.minecraft.server.players.PlayerList playerList, @Nullable net.minecraft.server.level.ServerPlayer player)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable net.minecraft.server.level.ServerPlayer
    Gets the player that is joining the server, or null when syncing for all players, such as when the reload command runs.
    net.minecraft.server.players.PlayerList
    Gets the server's player list, containing all players, when the event fires.
    Set<net.minecraft.world.item.crafting.RecipeType<?>>
     
    Stream<net.minecraft.server.level.ServerPlayer>
    Creates a stream of players that need to receive data during this event, which is the specified player (if present) or all players.
    void
    sendRecipes(Iterable<net.minecraft.world.item.crafting.RecipeType<?>> recipeTypes)
    Requests that all recipes of the given types should be sent to the players.
    void
    sendRecipes(net.minecraft.world.item.crafting.RecipeType<?>... recipeTypes)
    Requests that all recipes of the given types should be sent to the players.

    Methods inherited from class java.lang.Object

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

    • playerList

      private final net.minecraft.server.players.PlayerList playerList
    • player

      @Nullable private final @Nullable net.minecraft.server.level.ServerPlayer player
    • recipeTypesToSend

      private final it.unimi.dsi.fastutil.objects.ReferenceSet<net.minecraft.world.item.crafting.RecipeType<?>> recipeTypesToSend
  • Constructor Details

    • OnDatapackSyncEvent

      public OnDatapackSyncEvent(net.minecraft.server.players.PlayerList playerList, @Nullable @Nullable net.minecraft.server.level.ServerPlayer player)
  • Method Details

    • getPlayerList

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

      public Stream<net.minecraft.server.level.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 net.minecraft.server.level.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(net.minecraft.world.item.crafting.RecipeType<?>... recipeTypes)
      Requests that all recipes of the given types should be sent to the players.
      See Also:
    • sendRecipes

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

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