Package org.cyclops.cyclopscore.network
Class PacketHandler
java.lang.Object
org.cyclops.cyclopscore.network.PacketHandler
Advanced packet handler of
PacketBase instances.
An alternative would be SimpleChannel.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidhandlePacketClient(net.minecraftforge.network.NetworkEvent.Context context, PacketBase packet) voidhandlePacketServer(net.minecraftforge.network.NetworkEvent.Context context, PacketBase packet) voidinit()<P extends PacketBase>
voidRegister a new packet.voidsendToAll(PacketBase packet) Send a packet to everything.voidsendToAllAround(PacketBase packet, net.minecraftforge.network.PacketDistributor.TargetPoint point) Send a packet to all in the target range.voidsendToDimension(PacketBase packet, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension) Send a packet to everything in the given dimension.voidsendToPlayer(PacketBase packet, net.minecraft.server.level.ServerPlayer player) Send a packet to the player.voidsendToServer(PacketBase packet) Send a packet to the server.
-
Constructor Details
-
PacketHandler
-
-
Method Details
-
init
public void init() -
register
Register a new packet.- Type Parameters:
P- The packet type.- Parameters:
packetType- The class of the packet.
-
handlePacketClient
public void handlePacketClient(net.minecraftforge.network.NetworkEvent.Context context, PacketBase packet) -
handlePacketServer
public void handlePacketServer(net.minecraftforge.network.NetworkEvent.Context context, PacketBase packet) -
sendToServer
Send a packet to the server.- Parameters:
packet- The packet.
-
sendToPlayer
Send a packet to the player.- Parameters:
packet- The packet.player- The player.
-
sendToAllAround
public void sendToAllAround(PacketBase packet, net.minecraftforge.network.PacketDistributor.TargetPoint point) Send a packet to all in the target range.- Parameters:
packet- The packet.point- The area to send to.
-
sendToDimension
public void sendToDimension(PacketBase packet, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension) Send a packet to everything in the given dimension.- Parameters:
packet- The packet.dimension- The dimension to send to.
-
sendToAll
Send a packet to everything.- Parameters:
packet- The packet.
-