Package com.ldtteam.structurize.network
Class NetworkChannel
java.lang.Object
com.ldtteam.structurize.network.NetworkChannel
Our wrapper for Forge network layer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA class that handles the data wrapping for our inner index codec. -
Constructor Summary
ConstructorsConstructorDescriptionNetworkChannel(String channelName) Creates a new instance of network channel. -
Method Summary
Modifier and TypeMethodDescriptionGives access to the cache of messages that are being received.Gives access to the internal index codec.voidRegisters all common messages.voidsendToDimension(IMessage msg, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Sends to everyone in dimension.voidsendToEveryone(IMessage msg) Sends to everyone.voidsendToOrigin(IMessage msg, net.minecraftforge.network.NetworkEvent.Context ctx) Sends to origin client.voidsendToPlayer(IMessage msg, net.minecraft.server.level.ServerPlayer player) Sends to player.voidsendToPosition(IMessage msg, net.minecraftforge.network.PacketDistributor.TargetPoint pos) Sends to everyone in circle made using given target point.voidsendToServer(IMessage msg) Sends to server.voidsendToTrackingChunk(IMessage msg, net.minecraft.world.level.chunk.LevelChunk chunk) Sends to everyone in given chunk.voidsendToTrackingEntity(IMessage msg, net.minecraft.world.entity.Entity entity) Sends to everyone who is in range from entity's pos using formula below.voidsendToTrackingEntityAndSelf(IMessage msg, net.minecraft.world.entity.Entity entity) Sends to everyone (including given entity) who is in range from entity's pos using formula below.
-
Constructor Details
-
NetworkChannel
Creates a new instance of network channel.- Parameters:
channelName- unique channel name- Throws:
IllegalArgumentException- if channelName already exists
-
-
Method Details
-
registerCommonMessages
public void registerCommonMessages()Registers all common messages. -
sendToServer
Sends to server.- Parameters:
msg- message to send
-
sendToPlayer
Sends to player.- Parameters:
msg- message to sendplayer- target player
-
sendToOrigin
Sends to origin client.- Parameters:
msg- message to sendctx- network context
-
sendToDimension
public void sendToDimension(IMessage msg, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Sends to everyone in dimension.- Parameters:
msg- message to senddim- target dimension
-
sendToPosition
public void sendToPosition(IMessage msg, net.minecraftforge.network.PacketDistributor.TargetPoint pos) Sends to everyone in circle made using given target point.- Parameters:
msg- message to sendpos- target position and radius- See Also:
-
PacketDistributor.TargetPoint
-
sendToEveryone
Sends to everyone.- Parameters:
msg- message to send
-
sendToTrackingEntity
Sends to everyone who is in range from entity's pos using formula below.Math.min(Entity.getType().getTrackingRange(), ChunkManager.this.viewDistance - 1) * 16;
as of 24-06-2019- Parameters:
msg- message to sendentity- target entity to look at
-
sendToTrackingEntityAndSelf
Sends to everyone (including given entity) who is in range from entity's pos using formula below.Math.min(Entity.getType().getTrackingRange(), ChunkManager.this.viewDistance - 1) * 16;
as of 24-06-2019- Parameters:
msg- message to sendentity- target entity to look at
-
sendToTrackingChunk
Sends to everyone in given chunk.- Parameters:
msg- message to sendchunk- target chunk to look at
-
getMessageCache
Gives access to the cache of messages that are being received.- Returns:
- The message cache.
-
getMessagesTypes
Gives access to the internal index codec.- Returns:
- The internal index codec map.
-