User Tools

Site Tools


zh_cn:documentation:entrypoint

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
zh_cn:documentation:entrypoint [2021/09/01 13:19] – created not completed solidblockzh_cn:documentation:entrypoint [2023/09/23 06:34] – ↷ Links adapted because of a move operation rawdiamondmc
Line 1: Line 1:
 ====== 入口点 ====== ====== 入口点 ======
  
-入口点是在模组的 [[zh_cn:documentation:fabric_mod_json|fabric.mod.json]] 中声明的,以将部分代码用于 Fabric 加载器或者其他模组加载。入口点最初用于使部分代码在游戏初始化过程中运行以初始化模组,虽然入口点系统也有其他用途。入口点由语言接收器(language adapters)加载,这些语言接收器会使用代码对象的名称产生一个指定类型的 Java 对象。+入口点是在模组的 [[zh_cn:documentation:fabric_mod_json_spec|fabric.mod.json]] 中声明的,以将部分代码用于 Fabric 加载器或者其他模组加载。入口点最初用于使部分代码在游戏初始化过程中运行以初始化模组,虽然入口点系统也有其他用途。入口点由语言接收器(language adapters)加载,这些语言接收器会使用代码对象的名称产生一个指定类型的 Java 对象。
  
 An entrypoint is exposed under some name, refers to some code object and must be based on a familiar **entrypoint prototype**. An entrypoint prototype defines the name (such as "main" or "client") and the expected type of object that the entrypoint should refer to (such as the ''ModInitializer'' interface). An **entrypoint prototype provider** declares an entrypoint prototype and is responsible for accessing entrypoints, and can state how the they will be used. Fabric Loader provides some built-in entrypoint prototypes, while mods can also provide their own. An entrypoint is exposed under some name, refers to some code object and must be based on a familiar **entrypoint prototype**. An entrypoint prototype defines the name (such as "main" or "client") and the expected type of object that the entrypoint should refer to (such as the ''ModInitializer'' interface). An **entrypoint prototype provider** declares an entrypoint prototype and is responsible for accessing entrypoints, and can state how the they will be used. Fabric Loader provides some built-in entrypoint prototypes, while mods can also provide their own.
Line 30: Line 30:
 ==== 内置入口点协议类型 ==== ==== 内置入口点协议类型 ====
  
-Fabric Loader provides four built-in entrypoint prototypes for mod initialization, some of which are designed to deal with initialization with respect to physical sides (see [[tutorial:side]]). The mainclient and server entrypoints are loaded and called early during the game's initialization, at a point where **most but not all** game systems are ready for modification. These entrypoints are typically used to bootstrap mods by registering registry objects, event listeners and other callbacks for doing things later.+Fabric 加载器提供四种内置的入口点协议以用于模组初始化,其中一些用于处理与物理端有关的初始化(见 [[tutorial:side]])。mainclientserver入口点在游戏初始化早期就会被加载并调用,此时**大多数但并非全部**的游戏系统都已准备好被修改。这些入口点用于通过注册注册表对象、事件监听器和其他用于后面的事情的回调来启动。
  
-  * **main**: The first normal initialization entrypoint to run. Uses the type ''ModInitializer'' and will call ''onInitialize''. +  * **main**:第一个要运行的正常初始化入口点。使用 ''ModInitializer'' 类并调用 ''onInitialize'' 
-  * **client**: Will run after main only in a physical client. Uses the type ''ClientModInitializer'' and will call ''onInitializeClient''. +  * **client**:仅在物理客户端的 main 后运行。使用 ''ClientModInitializer'' 类并调用 ''onInitializeClient'' 
-  * **server**: Will run after main only in a physical server. Uses the type ''DedicatedServerModInitializer'' and will call ''onInitializeServer''. +  * **server**:仅在物理服务器的 main 后运行。使用 ''DedicatedServerModInitializer'' 类并调用 ''onInitializeServer'' 
-  * **preLaunch (not recommended for general use)**: The earliest possible entrypoint, which is called just before the game launches. Use with caution to not interfere with the game's initialization. Uses the type ''PreLaunchEntryPoint'' and will call ''onPreLaunch''+  * **preLaunch(一般不建议使用)**:可能的最早期的入口点,在游戏启动之前调用。使用时注意不要干预游戏初始化。使用类 ''PreLaunchEntryPoint'' 并调用 ''onPreLaunch''
- +
-All main entrypoints are called before all client/server entrypoints. The exact time these entrypoints are called is unspecified and may vary between different versions of the game.+
  
 +所有的 main 入口点都是在 client/server 入口点之前调用的。调用这些入口点的准确时间是未指定的,可能因游戏版本而异。
 ==== 代码引用类型 ==== ==== 代码引用类型 ====
  
zh_cn/documentation/entrypoint.txt · Last modified: 2024/01/02 10:32 by solidblock