tutorial:side
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorial:side [2019/05/08 02:17] – created... saving for now, will keep writing liach | tutorial:side [2022/04/13 04:32] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Side ====== | ====== Side ====== | ||
+ | Minecraft uses the [[https:// | ||
- | In Minecraft | + | The concept of client/ |
- | For both types of " | + | For both types of sides, there is a 'client' |
- | Usually, the logical sides have slightly more importance over the physical sides, for they have a bigger impact | + | The logical sides are central in the architecture of both distributions of Minecraft. Therefore, an understanding of logical sides is vital for any mod development with Fabric. |
+ | |||
+ | ===== Physical Sides ===== | ||
+ | |||
+ | The physical sides or the environment refer to the two distributions (jars) of Minecraft, the client (what the vanilla launcher launches), and the server (download available on [[https:// | ||
+ | |||
+ | The client | ||
+ | |||
+ | In Fabric, you can often see annotations like '' | ||
+ | |||
+ | In Fabric fabric.mod.json and the mixin config, the client/ | ||
+ | |||
+ | Each physical side ships classes used by its entry point and the data generator classes with entrypoint '' | ||
===== Logical Sides ===== | ===== Logical Sides ===== | ||
- | Logical | + | The logical |
+ | The logical client | ||
- | ==== Client | + | The client maintains a partial replica of the server' |
+ | net.minecraft.class_1937 | ||
+ | net.minecraft.class_1297 | ||
+ | net.minecraft.class_2586 | ||
+ | </ | ||
+ | These replicated objects allow clients and servers to perform some common game logic. The client can interact with these objects while the server is responsible for keeping them in sync. Usually, to distinguish objects on the logical clients from the ones on the logical server you would access the world of the object and check its '' | ||
+ | ===== Detailed look into all sides ===== | ||
- | ==== Server ==== | + | With an understanding |
- | The logical server is where most of the game logic is going on. Data packs, world updates, block entity | + | |
- | ===== Physical | + | ==== Physical |
+ | The physical client is the minecraft jar downloaded by the vanilla launcher. It contains a logical client and a logical server (integrated server). Its entrypoint is '' | ||
- | The physical | + | A physical client |
- | In Fabric, you can often see annotations like < | + | Compared to the logical server of the physical server (dedicated server), the logical server of the physical client |
- | Each physical | + | All the logical client content is exclusive to the physical |
- | ==== Client ==== | + | Some mods target |
- | The physical | + | |
- | ==== Server ==== | + | ==== Physical |
- | The physical server is the java dedicated server. Compared to a physical client, it only has a logical server. Its entrypoint is < | + | |
- | Compared to the physical client, the physical server can only have one world/save. | + | The physical server is the java dedicated server. |
- | Its logical server differs slightly from that of a physical client as only one logical server instance | + | Its logical server differs slightly from that of a physical client as only one logical server instance |
- | Despite these differences, | + | Despite these differences, |
- | Its features of single world and resource pack sending, however, | + | Its features of single world and resource pack sending, however, |
- | Some mods target physical server exclusively. For instance, Bukkit and its derivatives (Spigot, Paper, Cauldron, Xxx-Bukkit hybrids) always | + | Some mods target physical server exclusively. For instance, Bukkit and its derivatives (Spigot, Paper, Cauldron, Xxx-Bukkit hybrids) always |
+ | |||
+ | ==== Logical Client ==== | ||
+ | The logical client is the interface to the player. Rendering (LWJGL), resource pack, player input handling, and sounds happen | ||
+ | |||
+ | ==== Logical Server ==== | ||
+ | The logical server is where most of the game logic is executed. Data packs, world updates, block entity and entity ticks, mob AI, game/ | ||
+ | |||
+ | The logical server on the physical client is called the " | ||
+ | |||
+ | The logical server runs in its own main thread, even on physical servers, and has a few worker threads. The lifetime of a logical server depends on the physical side it is hosted on. On a physical server, a logical server exists for as long as the process is running. On a physical client, multiple logical servers may be created, but only one logical server may exist at a time. A new logical server is created when the player loads a local save and closed when the player closes the local save. | ||
+ | |||
+ | Most universal mods target the logical server so that they can work both in single | ||
+ | ===== Communication===== | ||
+ | |||
+ | The only correct way to exchange data between logical clients and servers is by exchanging packets. The packets (as documented on [[https:// | ||
+ | |||
+ | Logical clients send C2S (Client-To-Server) packets to the logical server. | ||
+ | The logical server sends S2C (Server-To-Client) packets the logical clients. | ||
+ | Packets are sent by a write method in a network thread and received by a call to a read method in a network thread. | ||
+ | |||
+ | For more details on how to handle networking, see [[tutorial: | ||
+ | |||
+ | ===== Common misconceptions about logical servers ===== | ||
+ | Most of the time, mods exclusively targeting the physical server also work on logical servers inside of physical clients. | ||
+ | |||
+ | However, modders for physical servers usually have assumptions which do not apply to integrated servers, including but not limited to: | ||
+ | * Only one logical | ||
+ | * The world and entities should always calculate the game logic (i.e., the isClient field of the world object is always false) | ||
+ | * Remote control, resource pack sending, and Favicon are present | ||
+ | |||
+ | These assumptions need to be corrected to make mods that run on logical servers. | ||
===== Conclusion ===== | ===== Conclusion ===== | ||
Possible combinations of physical and logical sides: | Possible combinations of physical and logical sides: | ||
| ^ Logical Client ^ Logical Server ^ | | ^ Logical Client ^ Logical Server ^ | ||
- | ^ Physical Client | Exists | + | ^ Physical Client | Singleton Always |
- | ^ Physical Server | Does Not Exist | Exists | + | ^ Physical Server | Does Not Exist | Singleton Always |
Ultimately, the main confusion comes from the fact that logical servers exist on physical clients. | Ultimately, the main confusion comes from the fact that logical servers exist on physical clients. | ||
- | |||
- | ==== Logical Server in Physical Client ==== | ||
- | |||
tutorial/side.1557281860.txt.gz · Last modified: 2019/05/08 02:17 by liach