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:50] – [Physical Sides (EnvType)] Clarify why physical sides even exist 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 |
- | The physical client and server are minified distributions of the same program, containing only the specific parts of the code that they use. Only the physical client contains the code required to host the logical client. Historically, | + | ==== Physical Server ==== |
- | In Fabric, you can often see annotations like < | + | The physical server is the java dedicated server. Compared to a physical client, it only has a logical server |
- | In Fabric fabric.mod.json and the mixin config, the client/server | + | 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 |
- | Each physical | + | Despite these differences, |
- | ==== Physical Client ==== | + | 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. |
- | The physical client is the minecraft jar downloaded by the vanilla launcher. It contains a logical client | + | |
- | As a physical | + | Some mods target |
- | Compared | + | ==== Logical Client ==== |
+ | The logical client is the interface | ||
- | All the logical | + | ==== Logical Server ==== |
+ | The logical | ||
- | Some mods target | + | The logical server on the physical |
- | ==== Physical Server ==== | + | The logical server runs in its own main thread, even on physical |
- | The physical server | + | |
- | Compared to the physical client, the physical | + | Most universal mods target |
+ | ===== Communication===== | ||
- | Its logical server differs slightly from that of a physical client as only one logical | + | The only correct way to exchange data between |
- | Despite these differences, | + | Logical clients send C2S (Client-To-Server) packets |
+ | The logical server sends S2C (Server-To-Client) packets | ||
+ | Packets are sent by a write method in a network thread | ||
- | Its features of single world and resource pack sending, however, makes vanilla mod (data pack and resource pack combination) installation much easier compared | + | For more details on how to handle networking, see [[tutorial: |
- | Some mods target | + | ===== 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 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.1557348649.txt.gz · Last modified: 2019/05/08 20:50 by jamieswhiteshirt