Package net.minecraftforge.network
Record Class PacketDistributor<T>
java.lang.Object
java.lang.Record
net.minecraftforge.network.PacketDistributor<T>
- Type Parameters:
T
-
public record PacketDistributor<T>(BiFunction<PacketDistributor<T>,T,Consumer<Packet<?>>> functor, NetworkDirection direction)
extends Record
Means to distribute packets in various ways
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
A Distributor curried with a specific value instance, for actual dispatchstatic final record
-
Field Summary
Modifier and TypeFieldDescriptionstatic final PacketDistributor<Void>
Send to everyone
noArg()
static final PacketDistributor<ResourceKey<Level>>
Send to everyone in the dimension specified in the Supplier
with(T)
DimensionTypeprivate final NetworkDirection
The field for thedirection
record component.private final BiFunction<PacketDistributor<T>,
T, Consumer<Packet<?>>> The field for thefunctor
record component.static final PacketDistributor<PacketDistributor.TargetPoint>
Send to everyone near thePacketDistributor.TargetPoint
specified in the Supplier
with(T)
TargetPointstatic final PacketDistributor<List<Connection>>
Send to the supplied list of NetworkManager instances in the Supplier
with(T)
List of NetworkManagerstatic final PacketDistributor<ServerPlayer>
Send to the player specified in the Supplier
with(T)
Playerstatic final PacketDistributor<Void>
Send to the server (CLIENT to SERVER)
noArg()
static final PacketDistributor<LevelChunk>
Send to all tracking the Chunk in the Supplier
with(T)
Chunkstatic final PacketDistributor<Entity>
Send to all tracking the Entity in the Supplier
with(T)
Entitystatic final PacketDistributor<Entity>
Send to all tracking the Entity and Player in the Supplier
with(T)
Entity -
Constructor Summary
ConstructorDescriptionPacketDistributor
(BiFunction<PacketDistributor<T>, T, Consumer<Packet<?>>> functor) PacketDistributor
(BiFunction<PacketDistributor<T>, T, Consumer<Packet<?>>> functor, NetworkDirection direction) Creates an instance of aPacketDistributor
record class. -
Method Summary
Modifier and TypeMethodDescriptionclientToServer
(Void ignored) Returns the value of thedirection
record component.final boolean
Indicates whether some other object is "equal to" this one.BiFunction<PacketDistributor<T>,
T, Consumer<Packet<?>>> functor()
Returns the value of thefunctor
record component.private MinecraftServer
final int
hashCode()
Returns a hash code value for this object.networkManagerList
(List<Connection> connections) noArg()
Apply a no argument value to a distributor to generate an instance for sending packets to.playerConsumer
(ServerPlayer player) playerListAll
(Void ignored) playerListDimConsumer
(ResourceKey<Level> dimension) final String
toString()
Returns a string representation of this record class.trackingChunk
(LevelChunk chunk) trackingEntity
(Entity entity) trackingEntityAndSelf
(Entity entity) Apply the supplied value to the specific distributor to generate an instance for sending packets to.
-
Field Details
-
functor
The field for thefunctor
record component. -
direction
The field for thedirection
record component. -
PLAYER
Send to the player specified in the Supplier
with(T)
Player -
DIMENSION
Send to everyone in the dimension specified in the Supplier
with(T)
DimensionType -
NEAR
Send to everyone near thePacketDistributor.TargetPoint
specified in the Supplier
with(T)
TargetPoint -
ALL
Send to everyone
noArg()
-
SERVER
Send to the server (CLIENT to SERVER)
noArg()
-
TRACKING_ENTITY
Send to all tracking the Entity in the Supplier
with(T)
Entity -
TRACKING_ENTITY_AND_SELF
Send to all tracking the Entity and Player in the Supplier
with(T)
Entity -
TRACKING_CHUNK
Send to all tracking the Chunk in the Supplier
with(T)
Chunk -
NMLIST
Send to the supplied list of NetworkManager instances in the Supplier
with(T)
List of NetworkManager
-
-
Constructor Details
-
PacketDistributor
-
PacketDistributor
public PacketDistributor(BiFunction<PacketDistributor<T>, T, Consumer<Packet<?>>> functor, NetworkDirection direction) Creates an instance of aPacketDistributor
record class.- Parameters:
functor
- the value for thefunctor
record componentdirection
- the value for thedirection
record component
-
-
Method Details
-
with
Apply the supplied value to the specific distributor to generate an instance for sending packets to.- Parameters:
input
- The input to apply- Returns:
- A curried instance
-
noArg
Apply a no argument value to a distributor to generate an instance for sending packets to. -
playerConsumer
-
playerListDimConsumer
-
playerListAll
-
clientToServer
-
playerListPointConsumer
-
trackingEntity
-
trackingEntityAndSelf
-
trackingChunk
-
networkManagerList
-
getServer
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
functor
Returns the value of thefunctor
record component.- Returns:
- the value of the
functor
record component
-
direction
Returns the value of thedirection
record component.- Returns:
- the value of the
direction
record component
-