2024-12-10 17:53:33|Myriagame |source:minecraft skins
This tutorial is set by the author's setting without permission.
sequence
Note: This is not a 0 basic tutorial, it is just one and one -sided reference guidance.
This tutorial will not provide too much practical code fragment ("pseudo code" instead of actual Java code), only design ideas and basic use cases will be provided.
In the more and more versions of Minecraft, even though a considerable number has been modified several times, its kernel and overall logical architecture remain unchanged.
Therefore, the ideas conveyed by this tutorial can basically be common in all versions, but there are differences in some implementation details.
Registration part
Most of the Minecraft content is registered.
Biological groups, blocks, items, entities, and even particles are required to be registered to use normally.
There are many ways to register, and each version has different implementation.
Before checking the interface provided by the modloader, let's look at the original registration method:
Beta 1.7.3
// directly get the registration content from the arrayvar three = new object [
] Things [0] = foo ()
1.7.10
var registry: registry = registry.make ("Things")value = registry.register (1145, "language: foo", foo ())
1.18
Val Foo = Registry.register (registry.objects, Identifier ("Language", "Foo"), foo ())
1.19
Val Foo = registry.register (registries.Objects, Identifier ("Language", "FOO"), FOO ())
Then there is the interface provided by Modloader:
Fabric
Fabric directly calls the simple original registrar, and does not need to consider the load order of the class.
LEGACY FABRIC and the following need to use related APIs. For specific cases, refer to their documents.
Forge
Forge needs to indirectly access the original registrar through the FORGE registrar to complete the registration, and you need to pay attention to the load order of the class, so the implementation will be relatively complicated.
1.7.10
@mod.eventhandlerpublic void doCommon
Gamedata._register
}
1.12.2
// Methods@SubscripeEvent
Public Void Registerthings (registryevent.register
Event.getRegistry (). Register (new foo (). SetRegistryname (
)); Event.getRegistry (). Registerly (new foo [] {new bar1 (). SetregitiveName (
, new bar2 (). SetRegistryname ( });} // Method 2 (not recommended)
@Mod.eventhandler
Public Void Init (FMLINITIALINEENT EOVENT) {
// Register code
}
1.20
See Forge's official or community documentation, I can't repeat it here.
Note that the loading sequence of the class, please make sure the MOM entry point is loaded when loaded with the registration -related code.
Registration events and conventional class are not synchronized. The initialization of registration is first loaded in the conventional class.
The general execution order is as follows (performed from left to right): the MOD entrance point initialization, registration event, and conventional class loading.
If you try to register when the registration event is over, Forge will directly throw an exception.
I really do n’t know how to handle the class loading correctly, please refer to the following code:
Public Class registration items {Public Static void loads this class () {
}
// Exempable registration items
}
public class registration category {
Public Static void loads this class () {
// Please make sure your registration items are also loaded when they are about to be registered!
Registered items. Load this class ();
}
}
@Mod
Public Class Modmain {
Static {
Register. Load this class ();
}
}
"Data" part
"Data", here refers to the data relying on the normal operation of the game.
The data in the data packet and resource package is "data" (data and assets). The content in 1.12.2 Data is stored in Assets, and 1.7.10 is directly created by code.
Please refer to Minecraft Wiki for the part of the data packet "Data", which is not described here.
In 1.12.2, the model of the block will be automatically binded according to the registration key, and the model of the item needs to be specified manually.
Modelloader.setCustomModelresourcelocation (, , New ModelResourceLocation (
, "Inventory");
Fuel thermal value
1.7.10
Implement ifuelhandler.
1.12.2
Ifuelhandler is still available, but you can directly cover the getfuelburnMe method in the base class.
【Unhappy to be continued】
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