2024-12-10 17:45:35|Myriagame |source:minecraft skins
This tutorial is set by the author to use the CC by-NC protocol.
Tutorial background
After the PKTTweaker was released, the author of the integrated package expressed doubts, thinking that its introduction was light and bleak, which was very vague, and its role was also confused.
This tutorial will explain the background and role of PKTtweaker as much as possible.
C/S design mode and network communication
Minecraft is a classic C/S -based game -based game, which consists of two parts: client and server.
When the authors of the integration package are written, they often consider the current game on the "which side" to avoid "bilateral problems" (only the logic that needs to be executed once is executed once on the server and the client) and "heterogeneous issues)"(Executing logic on the wrong side, resulting in an invalid logic or a game collapse).
The logic of the server and client execution is obviously different, so the introduction of network communication is necessary.There are two main purpose of network communication::
Synchronize the client and server;
Ensure that the client can inform the service of the server.
The simplest and reliable implementation method of network communication is to pass the message through the network packet (Packet), and the message is stored in a specific way to facilitate the sending and receiving.After receiving a message from one side, you can make some changes on the receiving side according to the type and data of the message to achieve the synchronization effect.
Several classic examples of manual network communication in MINECRAFT
The original Minecraft version has achieved a variety of network packets. Therefore, most of our operations in the game are two -end synchronization, such as placing / damaging blocks.
However, some data are not automatically synchronized. Below we list several more classic examples.
The use of the button binding
The use of the player's button binding (whether a button is pressed and how long has been pressed) will not be automatically synchronized to the server.
Player speed
Although it may be strange, most of the time trying to get players at the server side will return without success.The player's speed is calculated at the client, and it will be briefly synchronized to the server if the player jumps and is repelled.
Physical NBT
The entity NBT will not be automatically synchronized to the client.
Principle of pkttweaker
In module development, SIMPLEIMPL is usually used to manage custom network packages.
Generally, module developers can easily create multiple different network packages.However, the cost of wanting to make the integration package also fight this wealthy battle is huge.Therefore, the author has only achieved two network packs C2SMESSAGE and S2CMESSAGE, which correspond to the two-type package direction of "client-> server" and "server-> client".
The author introduces two information in these two network packages: the unique identifier (ID) and data (data) of the network package.Correspondingly, the network package processing strategy category registered by the event -also divided into two types: C2S and S2C, including the unique identifier (ID) and the processing strategy.
When receiving the network package defined by PKTTweaker, first look for a network package processing strategy with the same identifier and the unique identifier of the network package, and then use its strategy to process the data provided by the network package.In this way, different use scenarios can be distinguished in the two limited two network packages and achieve different logic.
National Service DNF Dark Ni
2025-01-28 09:19:27The new screenshot of the be
2025-01-28 09:18:57The 15th anniversary wallpap
2025-01-28 09:18:273DM Xuanyuan Sinicization Gr
2025-01-28 09:17:57French magazine is the first
2025-01-28 09:17:27The sneak game "Republic" wi
2025-01-28 09:16:57The story between humans and
2025-01-28 09:16:27Capture "Trinity 3: Artifact
2025-01-28 09:15:27Wind direction change "Myste
2025-01-28 09:14:57DICE's new project "Dream" w
2025-01-28 09:14:27Pirate Minecraft Skins
Minecraft Skins
2024-12-10 04:11:27Pirate Minecraft Skins
Minecraft Skins
2024-12-10 04:11:26Master Minecraft Skins
Minecraft Skins
2024-12-10 04:11:25King Minecraft Skins
Minecraft Skins
2024-12-10 04:11:25Guide Minecraft Skins
Minecraft Skins
2024-12-10 04:11:24Dark Knight Minecraft Skins
Minecraft Skins
2024-12-10 04:11:23Sparta Minecraft Skins
Minecraft Skins
2024-12-10 04:11:23Moncraft Skins of the War
Minecraft Skins
2024-12-10 04:11:22Red Witch Minecraft Skins
Minecraft Skins
2024-12-10 04:11:22Golden Cavaliers Minecraft S
Minecraft Skins
2024-12-10 04:11:22