tutorial:side
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:side [2019/05/08 20:50] – [Physical Sides (EnvType)] Clarify why physical sides even exist jamieswhiteshirt | tutorial:side [2022/02/09 16:56] – [Communication] grammar fix waffel | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Side ====== | ====== Side ====== | ||
+ | Minecraft uses the [[https:// | ||
- | Fabric allows mods to target the Minecraft | + | The concept of client/server in Minecraft is ambiguous and may refer to either physical |
- | For both types of " | + | 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 kind of 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. |
+ | |||
+ | ===== 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 and server environment are minified distributions of the same program, containing only the required parts of the code. | ||
+ | |||
+ | 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 | ||
- | The packets (which [[https:// | + | The client maintains a partial replica of the server' |
- | + | ||
- | In Minecraft, in order to reduce code, the logical client and servers share some logic classes, including< | + | |
net.minecraft.world.World | net.minecraft.world.World | ||
net.minecraft.entity.Entity | net.minecraft.entity.Entity | ||
net.minecraft.block.entity.BlockEntity | net.minecraft.block.entity.BlockEntity | ||
</ | </ | ||
- | and a few more. These shared classes | + | These replicated objects |
+ | ===== Detailed look into all sides ===== | ||
- | Usually, | + | With an understanding of which sides there are and how to distinguish between them, we can now look at each side in detail. |
- | ==== Logical | + | ==== Physical |
- | The logical | + | The physical |
- | The logical client runs on the main thread of the physical client | + | A physical client |
- | In yarn, the C2S packets are sent from the logical | + | Compared to the logical |
- | ==== Logical Server ==== | + | All the logical |
- | The logical | + | |
- | The logical server on the physical | + | Some mods target |
- | The logical server never runs on the thread which went through the entrypoint of a physical side, even on physical servers. Still, it has its own thread, on which it handles its logic. It is a singleton that always exists on physical servers; on the physical client, it exists one instance at a time when the player is playing a local save, and a new instance is created every time the player loads a local save. | + | ==== Physical Server ==== |
- | Most universal mods target | + | The physical server is the java dedicated |
- | In yarn, the S2C packets are sent from the logical server | + | Its logical server |
- | ===== Physical Sides (EnvType) ===== | + | Despite these differences, |
- | The physical sides refer to the two distributions (jars) | + | Its features |
- | The physical | + | Some mods target |
- | In Fabric, you can often see annotations like < | + | ==== Logical Client ==== |
+ | The logical client is the interface to the player. Rendering (LWJGL), resource pack, player input handling, and sounds happen | ||
- | In Fabric fabric.mod.json and the mixin config, the client/server refers to the physical side. | + | ==== Logical Server ==== |
+ | The logical server is where most of the game logic is executed. Data packs, world updates, block entity | ||
- | Each physical | + | The logical server on the physical |
- | ==== Physical Client ==== | + | The logical server runs in its own main thread, even on physical |
- | The physical | + | |
- | As a physical client can load worlds (launch integrated servers/ | + | Most universal mods target the logical server |
+ | ===== Communication===== | ||
- | Compared | + | The only correct way to exchange data between |
- | All the logical | + | Logical clients send C2S (Client-To-Server) packets to the logical |
+ | The logical server sends S2C (Server-To-Client) packets | ||
+ | Packets are sent by a write method in a network thread | ||
- | Some mods target physical clients exclusively. | + | For more details on how to handle networking, see [[tutorial: |
- | ==== Physical Server | + | ===== Common misconceptions about logical servers ===== |
- | The physical server | + | Most of the time, mods exclusively targeting the physical server |
- | Compared to the physical client, the physical | + | However, modders for physical |
+ | * Only one logical server | ||
+ | * 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 | ||
- | Its logical server differs slightly from that of a physical client as only one logical server instance will be ever present when the physical server is ran. Moreover, the logical server of the physical server can be controlled remotely via Rcon, has server.properties, | + | These assumptions need to be corrected |
- | + | ||
- | Despite these differences, | + | |
- | + | ||
- | Its features of single world and resource pack sending, however, makes vanilla mod (data pack and resource pack combination) installation much easier compared to on clients, as vanilla physical clients will be set up when connecting | + | |
- | + | ||
- | Some mods target physical server exclusively. For instance, Bukkit and its derivatives (Spigot, Paper, Cauldron, Xxx-Bukkit hybrids) always | + | |
===== Conclusion ===== | ===== Conclusion ===== | ||
Line 83: | Line 96: | ||
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 ==== | ||
- | Most of the time, mods target physical server exclusively can be applied to logical servers in physical clients in theory. | ||
- | |||
- | However, modders for physical servers usually have incorrect assumptions of all logical servers, including but not limited to: | ||
- | * Only one logical server instance will ever exist on one game run | ||
- | * The world and entities should always calculate the game logic (i.e. the World.isClient field is always false) | ||
- | * Remote control, resource pack sending, and Favicon are present | ||
- | |||
- | These assumptions need to be corrected in order to make plugins that run on both singleplayer and dedicated servers, etc. | ||
tutorial/side.txt · Last modified: 2022/04/13 04:32 by 127.0.0.1