tutorial:side
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:side [2019/05/26 14:51] – [Logical Sides] Made logical sides more about the world state and the replication jamieswhiteshirt | tutorial:side [2022/04/13 04:32] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Side ====== | ====== Side ====== | ||
- | Minecraft uses the [[https:// | + | Minecraft uses the [[https:// |
- | In the past, there used to be a simple division into the client and the server, but with the switch | + | The concept of client/server in Minecraft is ambiguous |
- | For both types of sides, there are client and server. However, a logical client is not equivalent to a physical client, and a logical server is not equivalent to a physical server either. A logical client is instead **hosted by** a physical client, and a logical server is hosted by either a physical server or a physical client. | + | For both types of sides, there is a 'client' |
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. | 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. | ||
Line 10: | Line 10: | ||
===== Physical Sides ===== | ===== Physical Sides ===== | ||
- | The physical sides or the environment refer to the two distributions (jars) of Minecraft | + | 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 and server environment are minified distributions of the same program, containing only the required parts of the code. | The client and server environment are minified distributions of the same program, containing only the required parts of the code. | ||
Line 22: | Line 22: | ||
===== Logical Sides ===== | ===== Logical Sides ===== | ||
- | Logical | + | The logical |
- | The logical client does rendering, sends player inputs to the server, handles resource packs and partially simulates the game world. The server handles the core game logic, data packs and maintains the true state of the game world. | + | The logical client does rendering, sends player inputs to the server, handles resource packs, and partially simulates the game world. The server handles the core game logic, data packs, and maintains the true state of the game world. |
- | The client maintains a partial replica of the server' | + | The client maintains a partial replica of the server' |
- | net.minecraft.world.World | + | net.minecraft.class_1937 |
- | net.minecraft.entity.Entity | + | net.minecraft.class_1297 |
- | net.minecraft.block.entity.BlockEntity | + | net.minecraft.class_2586 |
- | </code> | + | </yarncode> |
- | 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, access the world of the object and check its ' | + | 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 |
===== Detailed look into all sides ===== | ===== Detailed look into all sides ===== | ||
- | With an understanding of which sides there are and how to distingish | + | With an understanding of which sides there are and how to distinguish |
==== Physical Client ==== | ==== Physical Client ==== | ||
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 client is the minecraft jar downloaded by the vanilla launcher. It contains a logical client and a logical server (integrated server). Its entrypoint is '' | ||
- | As a physical client can load several different worlds each within a separate logical server, but only one at a time. | + | A physical client can load several different worlds, each within a separate logical server, but only one at a time. |
Compared to the logical server of the physical server (dedicated server), the logical server of the physical client (integrated server) can be controlled by the logical client on the physical client (e.g., F3+T reloads data packs and shutting down the client also shuts down the integrated server). It can also load resource packs bundled in a world to the logical client on the physical client. | Compared to the logical server of the physical server (dedicated server), the logical server of the physical client (integrated server) can be controlled by the logical client on the physical client (e.g., F3+T reloads data packs and shutting down the client also shuts down the integrated server). It can also load resource packs bundled in a world to the logical client on the physical client. | ||
- | All the logical client | + | All the logical client |
Some mods target physical clients exclusively, | Some mods target physical clients exclusively, | ||
Line 52: | Line 52: | ||
Its logical server differs slightly from that of a physical client as only one logical server instance is ever present when the physical server is running. Moreover, the logical server of the physical server can be controlled remotely via Rcon, has a config file called server.properties, | Its logical server differs slightly from that of a physical client as only one logical server instance is ever present when the physical server is running. Moreover, the logical server of the physical server can be controlled remotely via Rcon, has a config file called server.properties, | ||
- | Despite these differences, | + | Despite these differences, |
Its features of single world and resource pack sending, however, make vanilla mod (data pack and resource pack combination) installation much easier compared to on clients, as vanilla physical clients set up when connecting to the server automatically. | Its features of single world and resource pack sending, however, make vanilla mod (data pack and resource pack combination) installation much easier compared to on clients, as vanilla physical clients set up when connecting to the server automatically. | ||
Line 59: | Line 59: | ||
==== Logical Client ==== | ==== Logical Client ==== | ||
- | The logical client is the interface to the player. Rendering (LWJGL), resource pack, player input handling, and sounds, happen on the logical client. It is not present on the physical server. | + | The logical client is the interface to the player. Rendering (LWJGL), resource pack, player input handling, and sounds happen on the logical client. It is not present on the physical server. |
==== Logical Server ==== | ==== Logical Server ==== | ||
- | The logical server is where most of the game logic is going on. Data packs, world updates, block entity and entity ticks, mob AI, game/world saving, | + | The logical server is where most of the game logic is executed. Data packs, world updates, block entity and entity ticks, mob AI, game/world-saving, |
The logical server on the physical client is called the " | The logical server on the physical client is called the " | ||
- | The logical server | + | The logical server runs in its own main thread, even on physical servers, |
- | + | ||
- | Most universal mods target the logical server so that they can work on physical sides. | + | |
+ | Most universal mods target the logical server so that they can work both in single player and multi player scenarios. | ||
===== Communication===== | ===== Communication===== | ||
- | The only correct way to exchange data between | + | The only correct way to exchange data between |
Logical clients send C2S (Client-To-Server) packets to the logical server. | Logical clients send C2S (Client-To-Server) packets to the logical server. | ||
The logical server sends S2C (Server-To-Client) packets the logical clients. | The logical server sends S2C (Server-To-Client) packets the logical clients. | ||
- | Packets are sent be a write method in a network thread and received by a call to a read method in a network thread. | + | 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: | For more details on how to handle networking, see [[tutorial: |
tutorial/side.1558882288.txt.gz · Last modified: 2019/05/26 14:51 by jamieswhiteshirt