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
Nested ClassesModifier and TypeClassDescriptionstatic final recordA Distributor curried with a specific value instance, for actual dispatchstatic final record -
Field Summary
FieldsModifier 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 thedirectionrecord component.private final BiFunction<PacketDistributor<T>, T, Consumer<Packet<?>>> The field for thefunctorrecord component.static final PacketDistributor<PacketDistributor.TargetPoint> Send to everyone near thePacketDistributor.TargetPointspecified 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
ConstructorsConstructorDescriptionPacketDistributor(BiFunction<PacketDistributor<T>, T, Consumer<Packet<?>>> functor) PacketDistributor(BiFunction<PacketDistributor<T>, T, Consumer<Packet<?>>> functor, NetworkDirection<?> direction) Creates an instance of aPacketDistributorrecord class. -
Method Summary
Modifier and TypeMethodDescriptionclientToServer(Void ignored) Returns the value of thedirectionrecord component.final booleanIndicates whether some other object is "equal to" this one.BiFunction<PacketDistributor<T>, T, Consumer<Packet<?>>> functor()Returns the value of thefunctorrecord component.private MinecraftServerfinal inthashCode()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 StringtoString()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 thefunctorrecord component. -
direction
The field for thedirectionrecord 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.TargetPointspecified 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 aPacketDistributorrecord class.- Parameters:
functor- the value for thefunctorrecord componentdirection- the value for thedirectionrecord 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.- Returns:
- A curried instance
- See Also:
-
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 thefunctorrecord component.- Returns:
- the value of the
functorrecord component
-
direction
Returns the value of thedirectionrecord component.- Returns:
- the value of the
directionrecord component
-