your current location:首页 > news>[Anno Note Library] The basic use tutorial Anno Minecraft Game

[Anno Note Library] The basic use tutorial Anno Minecraft Game

2024-12-10 17:54:16|Myriagame |source:minecraft skins

This tutorial is set by the author to use the CC by-NC protocol.

Anno principle

Anno essentially uses the runtime annotation+reflection method to obtain static fields from the registry | registry class, and then perform various operations.

The operation process is integrated to the (resolva | Resolver) interface implementation, and registered at Annoresolvers for calling.


Specific process:

Call the analysis method in Annoresolvers in the module -related loading method, and analyze the specified class->

Get the field, instance, registryClass-> Try the packaging field (this process is judged whether there are annotations and judgments as expected types)

Registered resolvers cycle analysis (the specificization process depends on the corresponding resolver)

Register

Exemplary example

Brief description of example registration form

(Registration | Registry) is also a class (class | class), which stores instances of related elements in the form of static variables.

The registry must be @id (String namespace) as the namespace of the registry, most of the time is Modid.

Core annotation

@Id (String Value) is used to bind ID.(All fields must be @id to be parsed)

General annotation

@Reg (String RegistryName) is used for registration;

@Burnable (int Time) is used to add new fuel.

Genetic annotation annotation

@Parent (String Path) is used to generate a model with a ; (naming space is a registry @id)

@GENRATED is used to generate 1 general model item; (the material path comes from the registry @id and items @ID)

@Handheld is used to generate 1 handheld model; (the material path is the same as @GENERATED)

@Cubeall is used to generate a simple square model with the same six sides and the blockState;

@Lang (String Langcode, String Value) is used to generate language files. is a language code and worth it.(Language code is like zh_cn and the like)

Analyze

Brief description

The analysis process will obtain the field instance and the corresponding annotation,

In this process, other operations can be combined, such as combined with DataGeneration to achieve automatic generation.

And our registry takes effect to analyze, the specific operation is as follows:

The onInitialize () method of the module master calls Annoresolvers.Resolve (Class <?> Registration);

The onInitializedataGERATOR (ARG ...) of the Module DataGENETION class calls annoresolvers.dataGen (ARG ...).

The class <?> Registration is the class of the registry.

Exemplary example