Package net.neoforged.neoforge.event
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
FieldsModifier and TypeFieldDescriptionprivate 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
ConstructorsConstructorDescriptionOnDatapackSyncEvent
(net.minecraft.server.players.PlayerList playerList, @Nullable net.minecraft.server.level.ServerPlayer player) -
Method Summary
Modifier and TypeMethodDescription@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.
-
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
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
Requests that all recipes of the given types should be sent to the players.- See Also:
-
getRecipeTypesToSend
- Returns:
- The recipe types that have already been requested to be sent to the players.
-