your current location:首页 > news>Most of MOD development [MC] My world original (Minecraft) Minecraft Game

Most of MOD development [MC] My world original (Minecraft) Minecraft Game

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 array

var 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.eventhandler

public void doCommon

Gamedata._register

}

1.12.2

 // Methods

@SubscripeEvent

Public Void Registerthings (registryevent.register Event) {

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】

The copyright of the work belongs to the author. If it infringes upon your copyright, please contact us and this site will be deleted within 3 working days.

Warm reminder: Resist bad games, refuse pirated games, pay attention to self-protection, beware of being deceived, moderate games are good for the brain, addiction to games is harmful to the body, arrange your time reasonably, and enjoy a healthy life!

© Copyright © 2025-2035 Myriagame All Rights Reserved