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:31] – Added some helpful redundancy to titles 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. |
- | ===== Logical | + | ===== Physical |
- | Logical | + | The physical |
+ | |||
+ | The client and server | ||
+ | |||
+ | In Fabric, you can often see annotations like '' | ||
+ | |||
+ | In Fabric fabric.mod.json | ||
+ | |||
+ | Each physical side ships classes used by its entry point and the data generator classes with entrypoint '' | ||
+ | |||
+ | ===== Logical Sides ===== | ||
- | The packets (which [[https:// | + | The logical |
+ | The logical | ||
- | In Minecraft, in order to reduce code, the logical client and servers share some logic classes, including< | + | The client maintains a partial replica of the server' |
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 | + | 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 |
- | In Fabric, you can often see annotations like < | + | Some mods target physical server exclusively. For instance, Bukkit and its derivatives |
- | In Fabric fabric.mod.json and the mixin config, the client/server refers to the physical | + | ==== Logical Client ==== |
+ | The logical client is the interface to the player. Rendering (LWJGL), resource pack, player input handling, | ||
- | Each physical side ships classes used by its respective entry point and the data generator classes with entrypoint< | + | ==== 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/world-saving, | ||
- | ==== Physical Client ==== | + | The logical server on the physical client is called |
- | The physical client is the minecraft jar downloaded by the vanilla launcher. It contains a logical client and a logical server (integrated | + | |
- | As a physical | + | 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 |
- | Compared to the logical server | + | Most universal mods target |
+ | ===== Communication===== | ||
- | All the logical | + | The only correct way to exchange data between |
- | Some mods target physical clients exclusively. For instance, Liteloader, Optifine, Minecraft PvP clients (Badlion, Hyperium, etc.) only run on the physical client. | + | Logical |
+ | The logical server sends S2C (Server-To-Client) packets | ||
+ | Packets are sent by a write method in a network thread and received by a call to a read method in a network thread. | ||
- | ==== Physical Server ==== | + | For more details on how to handle networking, see [[tutorial: |
- | The physical server is the java dedicated server. Compared | + | |
- | Compared to the physical client, the physical server | + | ===== Common misconceptions about logical servers ===== |
+ | Most of the time, mods exclusively targeting | ||
- | Its logical server differs slightly from that of a physical | + | However, modders for physical |
+ | * Only one logical server instance | ||
+ | * The world and entities should always calculate | ||
+ | * Remote control, resource pack sending, and Favicon are present | ||
- | Despite these differences, | + | These assumptions need to be corrected |
- | + | ||
- | 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 81: | 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