2024-12-10 17:54:20|Myriagame |source:minecraft skins
This tutorial is set by the author to use the CC by-NC protocol.
annotation
Note category indexing
When the annotation classes require the life cycle to run, there must be @RETENTION (RetentionPolicy.runtime);
Generally, its use range is only for fields, that is, @Target (Elementtype.field);
In order to determine the type of the target field, Anno added a new annotation @Targettype (class <?> [] value)
For example: registered fuel should limit the type to ITEM, then the @Targettype of the registered fuel should be @Targettype ({item.class}).If the field is required to be repeatedly marked (such as @lang), you can Baidu @repeatable annotation.
Note attribute
If you are free, the attributes require specific analysis, please ensure that you will create new annotations in Java.
Example (fuel annotation)
@targettype (item.class)@Target (ElementType.field)
@RETENTION (RetentionPolicy.runtime)
public @Interface Burnable {
Int value ();
}
Parser
The parser is used to handle the field instance and annotation, and the specific implementation is large in different cases.
We take fuel annotations as an example.
Exemplary example
Public Class FuelresolVer IMPLEMEREMENTS Resolver{ @Override
Public
Void Process (target target, class <?> registration) { If (target.Object () Instanceof item item) {{
Int Time = target.field (). Getannotation (burnable.class). Value ();
Fuelregitive.instance.add (item, time);
}
}
@Override
Public class
Annoclass () {{) { Return Burnable.class;
}
@Override
Public string name () {return "fuel";
}
}
illustrate
The implementation of the parser is also very simple. TARGET
PROCESS (ARG ...) is the specific processing process. The process of adding fuel here is as follows:
First judge the type of the instance, and use the new fuel registration of the Fabric API after the conversion.
Annoclass () only needs to return to the annotation class.
In MINECRAFT -.21.1 and its subsequent versions, we also need to implement name (), which should not be the same as other parsers.
register
The annotation does not need to register. The parser should be registered with Annoresolvers.regiter (ARG ...) at the top of the main class of the module.
Exemplary example
Public Class Anno Implements Modinitializer {Public Static Final String Mod_id = "Anno";
@Override
Public void oninitialize () {
Annoresolvers.register (ID ("fuel"), new fuelresolver ());
Annoresolvers.Resolve (annoregistration.class);
}
Public Static Identifier ID (String Path) {{
Return Identifier.of (mod_id, PATH);
}
}
Precautions
If you need the dataGeneration related parser, you can refer to the official implementation of the Anno.
The resolution of the same ID will be registered first.
National Service DNF Dark Ni
2025-01-28 09:19:27The new screenshot of the be
2025-01-28 09:18:57The 15th anniversary wallpap
2025-01-28 09:18:273DM Xuanyuan Sinicization Gr
2025-01-28 09:17:57French magazine is the first
2025-01-28 09:17:27The sneak game "Republic" wi
2025-01-28 09:16:57The story between humans and
2025-01-28 09:16:27Capture "Trinity 3: Artifact
2025-01-28 09:15:27Wind direction change "Myste
2025-01-28 09:14:57DICE's new project "Dream" w
2025-01-28 09:14:27Pirate Minecraft Skins
Minecraft Skins
2024-12-10 04:11:27Pirate Minecraft Skins
Minecraft Skins
2024-12-10 04:11:26Master Minecraft Skins
Minecraft Skins
2024-12-10 04:11:25King Minecraft Skins
Minecraft Skins
2024-12-10 04:11:25Guide Minecraft Skins
Minecraft Skins
2024-12-10 04:11:24Dark Knight Minecraft Skins
Minecraft Skins
2024-12-10 04:11:23Sparta Minecraft Skins
Minecraft Skins
2024-12-10 04:11:23Moncraft Skins of the War
Minecraft Skins
2024-12-10 04:11:22Red Witch Minecraft Skins
Minecraft Skins
2024-12-10 04:11:22Golden Cavaliers Minecraft S
Minecraft Skins
2024-12-10 04:11:22