Начните вводить название — например, MoreHead, Sodium или PEAK

PacketHelper — иконка
Обложка MuckМод для Muck

PacketHelper

от iiVeil

Packet Helper is a helper mod designed to easily create client and server packets as well as attaching them to your mod's custom methods.

  • Легендарный
  • 182 тыс. скачиваний
  • Версия 1.0.3
  • Обновлён 17 июня 2021
  • Не обновлялся больше года
  • Дополнения

О моде PacketHelper

PacketHelper — мод для Muck (Мак) от автора iiVeil. Packet Helper is a helper mod designed to easily create client and server packets as well as attaching them to your mod's custom methods.

Его скачали 182 тыс. раз: это 9-е место среди модов Muck в нашем каталоге, редкость — «легендарный» (топ-5% по скачиваниям). Мод давно не обновлялся — проверьте совместимость с текущей версией игры, актуальная версия — 1.0.3.

Это библиотека: сама по себе ничего не добавляет, но нужна другим модам.

Полное описание PacketHelper

Текст автора на языке оригинала

Packet Helper

Packet Helper is a helper mod designed to easily create client and server packets as well as attaching them to your mod's custom methods.

An example of implementing this library can be found at https://github.com/iiVeil/ShareEm

Initializing

Packet Helper uses a class called Session to store data for your packets

Session session = new Session("YOUR.MOD.GUID") Session uses your mod GUID to create a unique packet offset to ensure that you don't overwrite packets on the game or other mods.

Creating a packet

Creating packets with Packet Helper is insanely easy first we will be creating a client packet.

It is important to remember that you must only add your packet once. Be sure to patch a method that gets called once.

public static Session session = new Session("YOUR.MOD.GUID"); public void MyClientPacketMethod(Packet packet) { // do some stuff with the packet }

// This is my go-to method to create client packets [HarmonyPatch(typeof(LocalClient), "InitializeClientData")] [HarmonyPostfix] static void CreateNewClientPackets() { session.CreateNewClientPacket("A Unique Packet Name", MyPacketMethod); }

The packet name will be used later to identify which packet to send. The unique packet name does not have to correspond to the method name in any way.

Next, we will create a server packet.

public static Session session = new Session("YOUR.MOD.GUID"); public void MyServerPacketMethod(int fromClient, Packet packet) { // do some stuff with the packet }

// This is my go-to method to create server packets [HarmonyPatch(typeof(Server), "InitializeServerPackets")] [HarmonyPostfix] static void CreateNewServerPackets() { session.CreateNewServerPacket("A Unique Packet Name", MyPacketMethod); } It is important to note that server packet methods differ from client packet methods. They include a fromClient parameter that indicates the client.id that the packet came from.

When creating a packet it's vital to understand that the method you attach to a packet will be handling how that packet is interacted with when received.

Sending packets

Sending a packet is slightly more complicated as it uses the class Data shown below

public class Data { public int[] ints = null; public string[] strings = null; public bool[] bools = null; public float[] floats = null; public short[] shorts = null; public long[] longs = null; public Vector3[] vector3s = null; public Quaternion[] quaternions = null; } Data is an important class as it allows us to send any amount of data through the packet.

Here we will be sending a packet to the server.

public static Session session = new Session("YOUR.MOD.GUID"); public void MyServerPacketMethod(int fromClient, Packet packet) { itemId = packet.ReadInt(); Debug.Log($"{fromClient}, {itemId}"); }

[HarmonyPatch(typeof(Server), "InitializeServerPackets")] [HarmonyPostfix] static void CreateNewServerPackets() { session.CreateNewServerPacket("MyServerPacket", MyServerPacketMethod); }

[HarmonyPatch(typeof (ClientSend), "PickupItem")] [HarmonyPrefix] static void ClientSendSharePacket(ClientSend __instance, int itemID) { Item item = ItemManager.Instance.list[itemID].GetComponent (); if (item.powerup) { // Create new data object Data data = new Data();

// Add the powerup id to the data data.ints = new int[] { item.powerup.id };

// Send packet to the server and call subsequent method MyServerPacketMethod() session.SendPacketToServer("MyServerPacket", data); } }

Next is sending a packet to the client.

Remember, when sending a packet to the client, fromClient is not accessible. If you need that value in the method that handles the packet, put it in the data class.

public static Session session = new Session("YOUR.MOD.GUID"); public void MyClientPacketMethod(Packet packet) { fromClient = packet.ReadInt(); itemId = packet.ReadInt(); Debug.Log($"{fromClient}, {itemId}"); }

public void MyServerPacketMethod(int fromClient, Packet packet) { itemId = packet.ReadInt(); Debug.Log($"{fromClient}, {itemId}"); Data data = new Data(); data.ints = new int[] { fromClient, itemId }; // Send packet to all connected clients, the host is Client(0) session.SendPacketToAllClients("MyClientPacket", data); }

[HarmonyPatch(typeof(Server), "InitializeServerPackets")] [HarmonyPostfix] static void CreateNewServerPackets() { session.CreateNewServerPacket("MyServerPacket", MyServerPacketMethod); }

[HarmonyPatch(typeof(LocalClient), "InitializeClientData")] [HarmonyPostfix] static void CreateNewClientPackets() { session.CreateNewClientPacket("MyClientPacket", MyClientPacketMethod); }

[HarmonyPatch(typeof (ClientSend), "PickupItem")] [HarmonyPrefix] static void ClientSendSharePacket(ClientSend __instance, int itemID) { Item item = ItemManager.Instance.list[itemID].GetComponent (); if (item.powerup) { // Create new data object Data data = new Data();

// Add the powerups id to the data data.ints = new int[] { item.powerup.id };

// Send packet to the server and call subsequent method MyServerPacketMethod() session.SendPacketToServer("MyServerPacket", data); } } If you don't want every client to get the packet use SendPacketToAllClientsExcept instead.

SendPacketToAllClientsExcept(int[] except, Packet packet) where except is an array of client ids th

Описание длинное — здесь его начало. Читать целиком на странице автора

Моды, которым нужен PacketHelper

23 в каталоге · показаны самые популярные

BiggerMap — иконка

BiggerMap

This mod allows you to change the size of the island. Default size: 241

Эпический153,9 тыс.Библиотека

ShareEm — иконка

ShareEm

A muck mod made to share items with other players.

Эпический80,4 тыс.Библиотека

Mucalamity — иконка

Mucalamity

a modpack containing around 30 mods or something, its alright i guess

Редкий23,2 тыс.Сборки

ModValidator — иконка

ModValidator

Mod Validator is a mod to easily create required, blacklisted, or require an entire list of mods.

Редкий18,4 тыс.Библиотека

MuckHarderAndBetter — иконка

MuckHarderAndBetter

Harder Muck Modpack with 33 Mods! Recommend Gamer Difficulty. Added weapons, tools, armor, and food to enhance gameplay. Big thanks to the mod creators! For more info or help, click the website button to view the Read Me on ThunderStore.

Редкий17,9 тыс.Дополнения

MuckQualityOfLife — иконка

MuckQualityOfLife

This mod Is a Quality Of Life modpack this will make muck more enjoyable (SHOUTOUT TO ALL CREATORS THAT MADE THESE MODS THESE ARE NOT MINE)ENJOY!.

Обычный10,8 тыс.Сборки

Как установить PacketHelper

Файл скачивается с официального сервера Thunderstore, без перезаливов и сторонних установщиков

Подробная инструкция для Muck
  1. Скачайте менеджер модов r2modman (или Gale) и выберите в нём игру Muck.
  2. Создайте профиль — так моды не смешаются с чистой версией игры.
  3. Найдите «PacketHelper» во вкладке Online и нажмите Download — BepInEx и все зависимости подтянутся сами.
  4. Нажмите «Start modded» — игра запустится с модами.
  5. Для мультиплеера всем игрокам нужен одинаковый набор модов: в r2modman профиль можно экспортировать кодом и отправить друзьям.
Вы автор мода? Поставьте ссылку на русское описание

Вставьте значок в описание на Thunderstore, в README или в Discord — русскоязычные игроки сразу попадут на страницу с переводом и инструкцией.

Описание на русском — Модка
Markdown[![Описание на русском — Модка](https://modka.app/badge.png)](https://modka.app/muck/iiveil-packethelper/)
HTML<a href="https://modka.app/muck/iiveil-packethelper/"><img src="https://modka.app/badge.png" alt="Описание на русском — Модка" height="44"></a>
Steam (BBCode)[url=https://modka.app/muck/iiveil-packethelper/]Описание на русском — Модка[/url]

Частые вопросы о PacketHelper

Как установить PacketHelper?

Скачайте менеджер модов r2modman (или Gale) и выберите в нём игру Muck. Создайте профиль — так моды не смешаются с чистой версией игры. Найдите «PacketHelper» во вкладке Online и нажмите Download — BepInEx и все зависимости подтянутся сами. Нажмите «Start modded» — игра запустится с модами. Для мультиплеера всем игрокам нужен одинаковый набор модов: в r2modman профиль можно экспортировать кодом и отправить друзьям.

Безопасен ли PacketHelper?

Файл скачивается с официального сервера Thunderstore, куда его загрузил iiVeil. Мы не перезаливаем и не изменяем моды.

Нужно ли друзьям ставить PacketHelper?

Автор не указал, клиентский это мод или серверный. Безопаснее, чтобы одинаковый набор модов был у всех игроков в лобби: проще всего поделиться профилем r2modman.

Когда PacketHelper обновлялся последний раз?

17 июня 2021, актуальная версия — 1.0.3. Это больше года назад: перед установкой проверьте, работает ли мод на текущей версии игры.

Похожие моды

Все моды на Muck
God Powers 2 — иконка

God Powers 2

A Mod Menu For Muck. With Custom Weapons, Flying, Etc. This Is The Second Version Of Muck God Powers

Редкий65,3 тыс.Дополнения

GiveItems — иконка

GiveItems

This mod creates a new command /give 'name or id of the item' 'how much'.

Редкий53,6 тыс.Читы

MuckHarderAndBetter — иконка

MuckHarderAndBetter

Harder Muck Modpack with 33 Mods! Recommend Gamer Difficulty. Added weapons, tools, armor, and food to enhance gameplay. Big thanks to the mod creators! For more info or help, click the website button to view the Read Me on ThunderStore.

Редкий17,9 тыс.Дополнения

DrillsMod — иконка

DrillsMod

This mod adds various Drill Tools to Muck!

Обычный15,5 тыс.Дополнения

MuckSwarm — иконка

MuckSwarm

Muck Swarm is a gamemode for muck where it is always night. Mobs start half as powerfull, but with the added change of the mob cap being set to 100. Can you survive?

Обычный14,6 тыс.Дополнения

Muwuck — иконка

Muwuck

Essential mod for furries.

Обычный10 тыс.Дополнения