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/08 20:31] – Added some helpful redundancy to titles 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:// | ||
- | 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 packets (which [[https:// | + | The client |
- | In Minecraft, in order to reduce code, the logical | + | In Fabric, you can often see annotations like '' |
- | net.minecraft.world.World | + | |
- | net.minecraft.entity.Entity | + | |
- | net.minecraft.block.entity.BlockEntity | + | |
- | </ | + | |
- | and a few more. These shared classes allow logical clients to shadow some common game logic from the logical server for easy rendering. (block entities are shadowed to the logical client optionally) | + | |
- | Usually, to identify the shadowed objects on the logical clients from the real ones on the logical server, vanilla and mod code access the World referenced in these objects | + | In Fabric fabric.mod.json and the mixin config, |
- | ==== Logical Client ==== | + | Each physical side ships classes used by its entry point and the data generator classes with entrypoint '' |
- | The logical client is where most displays to the player is done. Rendering (LWJGL), resource pack, player input handling, sounds, etc. all happen on the logical client. | + | |
- | The logical client runs on the main thread of the physical client exclusively. It is not present on the physical server. It is a singleton and always exists. | + | ===== Logical Sides ===== |
- | In yarn, the C2S packets | + | The logical sides are responsible for the actual game logic. |
+ | The logical client | ||
- | ==== Logical Server ==== | + | The client maintains a partial replica |
- | The logical server is where most of the game logic is going on. Data packs, world updates, block entity | + | net.minecraft.class_1937 |
+ | net.minecraft.class_1297 | ||
+ | net.minecraft.class_2586 | ||
+ | </ | ||
+ | These replicated objects allow clients and servers to perform some common | ||
+ | ===== Detailed look into all sides ===== | ||
- | The logical server on the physical client is called the " | + | With an understanding |
- | The logical server never runs on the thread which went through | + | ==== Physical Client ==== |
+ | The physical client is the minecraft jar downloaded by the vanilla launcher. It contains | ||
- | Most universal mods target the logical server | + | A physical client can load several different worlds, each within a separate |
- | In yarn, the S2C packets are sent from the logical server (which calls write method in a network thread), and the C2S packets are received | + | Compared to the logical |
- | ===== Physical Sides (EnvType) ===== | + | All the logical client content is exclusive to the physical client, therefore you see many environment annotations on rendering, sound, and other logical client code. |
- | The physical | + | Some mods target |
- | In Fabric, you can often see annotations like < | + | ==== Physical Server ==== |
- | In Fabric fabric.mod.json and the mixin config, the client/server | + | The physical server is the java dedicated server. Compared to a physical client, it only has a logical server (dedicated server). Its entrypoint is '' |
- | Each physical | + | Its logical server differs slightly from that of a physical |
- | ==== Physical Client ==== | + | Despite these differences, |
- | The physical client is the minecraft jar downloaded by the vanilla launcher. It contains a logical client and a logical | + | |
- | As a physical client can load worlds | + | 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 |
- | 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 | + | Some mods target |
- | All the logical client | + | ==== Logical Client ==== |
+ | The logical client | ||
- | Some mods target physical clients exclusively. For instance, Liteloader, Optifine, Minecraft PvP clients (Badlion, Hyperium, etc.) only run on the physical client. | + | ==== 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/ | ||
- | ==== Physical Server ==== | + | The logical |
- | The physical | + | |
- | Compared to the physical | + | The logical server runs in its own main thread, even on physical |
- | Its logical server | + | Most universal mods target the logical server |
+ | ===== Communication===== | ||
- | Despite these differences, | + | The only correct way to exchange data between |
- | 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 | + | Logical clients send C2S (Client-To-Server) packets |
+ | 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. | ||
- | Some mods target | + | 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 | ||
+ | |||
+ | However, modders for physical servers usually have assumptions which do not apply to integrated servers, including but not limited to: | ||
+ | * Only one logical server instance exists on one game run | ||
+ | * 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 ===== | ||
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.1557347466.txt.gz · Last modified: 2019/05/08 20:31 by jamieswhiteshirt