Fabric loader 0.12

Название, описание и другие данные мода

Теперь открываем файл в папке ресурсов: fabric.mod.json. В нём текста будет побольше. Это Json, так что надеюсь, что хоть базовое понимание его структуры у вас есть. Следите за запятыми и кавычками.

{
«schemaVersion»: 1,
«id»: «modid»,
«version»: «${version}»,

«name»: «Example Mod»,
«description»: «This is an example description! Tell everyone what your mod is about!»,
«authors»: ,
«contact»: {
«homepage»: «https://fabricmc.net/»,
«sources»: «https://github.com/FabricMC/fabric-example-mod»
},

«license»: «CC0-1.0»,
«icon»: «assets/modid/icon.png»,

«environment»: «*»,
«entrypoints»: {
«main»:
},
«mixins»: ,

«depends»: {
«fabricloader»: «>=0.11.3»,
«fabric»: «*»,
«minecraft»: «1.17.x»,
«java»: «>=16»
},
«suggests»: {
«another-mod»: «*»
}
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

{

«schemaVersion»1,

«id»»modid»,

«version»»${version}»,

«name»»Example Mod»,

«description»»This is an example description! Tell everyone what your mod is about!»,

«authors»

«Me!»

,

«contact»{

«homepage»»https://fabricmc.net/»,

«sources»»https://github.com/FabricMC/fabric-example-mod»

},

«license»»CC0-1.0»,

«icon»»assets/modid/icon.png»,

«environment»»*»,

«entrypoints»{

«main»

«net.fabricmc.example.ExampleMod»

},

«mixins»

«modid.mixins.json»

,

«depends»{

«fabricloader»»>=0.11.3″,

«fabric»»*»,

«minecraft»»1.17.x»,

«java»»>=16″

},

«suggests»{

«another-mod»»*»

}

}

Некоторые данные будут подтянуты из предыдущего файла, например версия. Но в этом файле помимо отображаемого имени мода мы также можем указать ещё и его id, описание, добавить авторов, указать лицензию и иконку.

Путь к иконке в примере указан в таком формате: «assets/modid/icon.png». Но вместо modid вы должны указать id мода, которое был выше (у меня это first_gs_mod), а саму иконку разместить тогда в папке resources/assets/ first_gs_mod/icon.png.

Замечания по id. Они будут использованы при загрузке модов, а это значит, что должны быть уникальными.  Мы ведь не хотим конфликтов в будущем?

Ещё тут есть зависимости для мода (будь то сама игра или версия java) и ссылки для обратной связи, которые лучше оставить пустыми, если у вас нет сайта/странички мода на github.

А ещё внимание нужно уделить полю entrypoints, своего рода точки входа, загрузки мода. Там нужно указать путь к нашему ново созданному классу ModMain:. «entrypoints»: {
«main»:
}

«entrypoints»: {
«main»:
}

1
2
3
4
5

«entrypoints»{

«main»

«dev.gs.first.ModMain»

}

Package и путь в json совпадают

На поле mixins пока мы не смотрим и оставляем его пустым. О нём в другой раз.

Вот что я получил в конечном итоге:

{
«schemaVersion»: 1,
«id»: «first_gs_mod»,
«version»: «${version}»,

«name»: «GS First Mod»,
«description»: «This is an example MOD for GS Guide!!»,
«authors»: ,
«contact»: {
«homepage»: «»,
«sources»: «»
},

«license»: «CC0-1.0»,
«icon»: «assets/first_gs_mod/icon.png»,

«environment»: «*»,
«entrypoints»: {
«main»:
},
«mixins»: [],

«depends»: {
«fabricloader»: «>=0.11.3»,
«fabric»: «*»,
«minecraft»: «1.17.x»,
«java»: «>=16»
},
«suggests»: {
«another-mod»: «*»
}
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

{

«schemaVersion»1,

«id»»first_gs_mod»,

«version»»${version}»,

«name»»GS First Mod»,

«description»»This is an example MOD for GS Guide!!»,

«authors»

«Astler»

,

«contact»{

«homepage»»»,

«sources»»»

},

«license»»CC0-1.0»,

«icon»»assets/first_gs_mod/icon.png»,

«environment»»*»,

«entrypoints»{

«main»

«dev.gs.first.ModMain»

},

«mixins»,

«depends»{

«fabricloader»»>=0.11.3″,

«fabric»»*»,

«minecraft»»1.17.x»,

«java»»>=16″

},

«suggests»{

«another-mod»»*»

}

}

Уже почти всё.

Продолжаем настройку

На очереди gradle.properties. А именно часть после # Mod Properties. Это вроде настройки проекта в целом.

mod_version = 1.0.0 это версия нашего мода, maven_group – имя пакета проекта, своего рода идентификатор. Все слова пишем через точки, у меня это dev.gs.first.

archives_base_name это имя проекта. Все слова должны быть написаны через дефиз. Пусть будет: gs-first-mod.

Остальные поля зависят от версии, для которой и будет сделан мод. Полный список можно найти тут. Выбираем свою версию заменяем эти строки на предложенные сайтом:

minecraft_version=1.17
yarn_mappings=1.17+build.13
loader_version=0.11.6

fabric_version=0.36.0+1.17

1
2
3
4
5

minecraft_version=1.17

yarn_mappings=1.17+build.13

loader_version=0.11.6

fabric_version=0.36.0+1.17

Хорошо, тут готово.

Теперь удалим всё из папки java и добавим туда соответствующие указанному ранее имени пакета: maven_group. Т.е. создаём папки: dev, в ней gs, а в ней first. В последнюю папку добавляем файл ModMain.java (или ваше имя, не принципиально). И пишем там такой текст:

package dev.gs.first;

import net.fabricmc.api.ModInitializer;

public class ModMain implements ModInitializer {
@Override
public void onInitialize() {

}
}

1
2
3
4
5
6
7
8
9
10

packagedev.gs.first;

import net.fabricmc.api.ModInitializer;

publicclassModMainimplementsModInitializer{

@Override

publicvoidonInitialize(){

}

}

Этот главный класс мода, который и будет отвечать за инициализацию компонентов. Мы уже добавили свою реализацию функции onInitiliaze, которая пока ничего не делает. Но это временно. Родителем нашего ModMain класса указан ModInitiliazer. Это класс из API Fabric.

В результате вы должны были получить что-то вроде этого:

Только с вашими именами!

CLI installation

The fabric installer has full support from installing the client and the server from the command line. This could be used to automate the installation. The installer has a number of commands that can be used for a headless install.

Available options

  • -snapshot Enables the usage of snapshot versions of Minecraft.
  • -dir Used to select the installation dir, defaults to the current working directory.
  • -mcversion Used to select the minecraft version, defaults to the latest stable version.
  • -loader Used to select the loader version, defaults to the latest.
  • -downloadMinecraft Used to automatically download the Minecraft server jar
  • -noprofile Skip creating client profile
  • -mavenurl (advanced) Use a custom maven url when installing
  • -metaurl (advanced) Use a custom meta server url

Available commands

  • help Prints out all of the commands available along with the latest mappings and loader versions. Ignores options. Example:

    java -jar fabric-installer.jar help
  • server Used to create the required files for a Fabric server. Accepts all options, none are required. Example:

    java -jar fabric-installer.jar server
  • client Used to create the required files for a Fabric client. Accepts all options, -dir is required. Example:

    java -jar fabric-installer.jar client -dir "~/Games/.minecraft"

fabric.debug.loadLate

Sometimes mods make false assumptions about the load order of mods, which limits their compatibility unintentionally. Mod load order is not specified and depends on implementation details that may change with a Fabric Loader release. Version 0.12 is one of these and it is impractical to emulate the old behavior.

We have added a workaround for load order bugs in the form of the system property, which will delay the specified mods to load later than all other mods. For example, if required a block from another mod that’s being created in the same startup phase, adding moves behind all other mods, including the one supplying the block it needs.

How to test

Due to the size of the changes we are releasing this version in stages, once we are happy everything is working we will release it to everyone. If you do find an issue please make sure to report it on our Github Repository.

Initially the installer won’t offer Loader 0.12 by itself, it has to be installed as follows:

  1. Go to https://fabricmc.net/use/.
  2. Click “Show other versions” and select , download the installer
  3. Download Fabric Loader 0.12.0 from here: fabric-loader-0.12.0.jar
  4. Run the installer and go to the Client or Server tab as desired
  5. Select the desired Minecraft version as usual
  6. Select at the very bottom of the Loader Version list
  7. Configure anything else as desired and start the install as usual by using the Install button
  8. The installer will now ask for the Fabric Loader JAR, provide it with the one downloaded in step 3

A Fabric Installer version older than 0.8.0 will not support this procedure.

Mod Developers

  1. Ensure you are using Loom 0.7 or higher. Loom 0.10 is required to use transitive access wideners and develop on 1.18 snapshots.
  2. Change your loader version in to be and reload your gradle project.

fabric.addMods

Fabric Loader normally loads mods from the mods directory, the system property or game argument allows specifying more. It takes a list of paths separated by the operation system specific path separator ( on Windows, elsewhere).

Supported options for the paths are:

  • mod jar location
  • directory location containing mod jars (searched recursively)
  • directory location containing an unpacked mod (for development purposes, detected by the presence of fabric.mod.json)
  • mod list file location prefixed by , e.g.

A mod list file contains any of the above supported paths except another mod list file, one per line.

Paths can be absolute or relative to the working directory.

Mixin compatibility

Mixin has been changing its implementation in such a way that mixins that are correct and working on one version may no longer work correctly or at all in a newer version. This was necessary to fix bugs in its local variable detection logic.

Fabric adds a mechanism to emulate the Mixin behavior bundled with the least Loader version a mod depends upon. If the mod requires an old Loader version (or none at all), its Mixins will be processed in line with the old Mixin behavior. If it however depends on Loader 0.12.0, which comes with Fabric Mixin 0.10.2+mixin.0.8.4, it’ll use the native behavior that comes with that release and currently represents the latest&greatest.

Mods are highly encouraged to declare the minimum Fabric Loader dependency to reflect the minimum version they were tested against. If they need the latest Mixin behavior and fixes, they also need to depend on the latest fabricloader version explicitly.

For Fabric Loader 0.12.0 this can be done as follows:

  1. In the add the following dependency

The lack of suitable dependency declaration will always force-enable legacy behavior for the respective mod! This is undesirable for newly developed mods, but keeps older mods working.

Developing with Fabric

If you’d like to start developing with Fabric, here are some articles which might interest you.

Tutorials

Setup

  • Setting up a Development Environment

  • Publishing Mods on Modrinth with Minotaur

  • Publishing Mods on Curseforge with CurseGradle

Basics

  • Introduction to Modding with Fabric

  • Reading the Minecraft source

  • Conventions and Terminology

    • Basic Conventions and Terminology

    • Server and Client Side Terminology

  • Registries

    • Intro to Registries

    • Standard Registries

  • Development Tools

    • Third-party Library Mods

    • Applying Changes without Restarting Minecraft

  • Creating a lang file

  • Using Mappings

Advanced

  • Using CrowdinTranslate to provide live community translations

  • Using GitHub Actions to find errors in your commits

  • Modding Tips

  • Updating from Loader 0.3.x to 0.4.x

  • Updating Yarn mappings in a Java codebase

  • DataFixers

  • Access Wideners

  • Reflection

  • Adding to Enums

Items

  • Item Documentation

  • Practical Example: Adding an Item

    • Creating an ItemGroup for your items

    • Adding a custom tooltip to your item

  • Adding a Crafting Recipe

  • Adding Armor

  • Adding Tools

  • Adding a Shield

  • Adding Custom Enchantments

  • Adding Model Predicate Providers

  • Adding a Block

  • Giving a Block State

  • Making a Directional Block

  • Adding a BlockEntity

  • Storing Items in a Block as an Inventory

  • Dynamically Change the Color of a Block or Item

  • Manipulating a Block’s Appearance

  • Rendering Blocks and Items Dynamically

    • Rendering Blocks and Items Dynamically using a custom Model

    • Rendering Blocks and Items Dynamically using Block Entity Renderers

  • Creating a Container Block

    • Syncing Custom Data with Extended ScreenHandlers

    • Syncing Integers with PropertyDelegates

  • Adding a Custom Crop

World Generation

  • Dimension Concepts

  • Generating Custom Ores

  • Adding Features

  • Adding Trees (Advanced)

  • Adding Structure Features

  • Adding Biomes

  • Adding Generator Types

  • Adding Dimensions

    Creating a Custom Portal

Miscellaneous

  • Mining Levels

  • Raycasting

  • Custom Keybindings

  • Creating Commands

  • Networking

  • Status Effects

  • Adding a Particle

  • Playing Sounds

  • Custom Gamerule

  • Custom Data/Resource Pack Resources

  • Tag Conventions

  • List of Useful Tutorials

  • Adding Player Statistics

Mixins

  • Introduction

  • Injects

  • Accessors and Invokers

  • Redirectors

    Method redirectors

  • Examples

  • Hotswapping Mixins

  • Exporting Mixin Classes

Tutorials for Minecraft 1.14

  • Rendering blocks and items dynamically using block entity renderers

  • Manipulating a Block’s appearance

  • Adding a Cookie Creeper Entity

Documentation

  • Structure of fabric.mod.json

  • fabric.mod.json specification

  • Entrypoints

  • Rendering in Fabric (DRAFT)

  • Fabric build pipelines (DRAFT)

  • Fabric Loader

  • Fabric Loom

Regular installation

MultiMC

NOTE MultiMC is a modding-friendly alternate launcher for Minecraft, which is recommended for working with Fabric and can be found here. If you don’t wish to use MultiMC or don’t know or care what launcher you’re using, follow through to the instructions.

  1. Create a new game instance.
  2. Select “Edit Instance” in the instance context menu or on the right side of the window.
  3. On the Version tab of the configuration window, click “Install Fabric” to bring up a dialog with all the available Fabric Loader versions. Pick one and click OK to add it to the instance.

    • Generally using the latest available Loader version is recommended.
    • The loader should be mostly game version-independent. If this situation changes, it will be pointed out, so don’t worry!
  4. Press OK. Your Fabric instance is ready to go — feel free to add mods to it!

For more detailed instructions visit this guide: Install Fabric — MultiMC (Windows) for Windows or this guide: Install Fabric — MultiMC (macOS) for macOS

Mojang’s Minecraft Launcher

  1. Open the installer. In the window you need to configure the mapping and loader version (as per advice in the ) and the install location (the default should be fine on most platforms).NOTE You need to enable snapshots in order to make the installer show mapping options for Minecraft snapshots.
  2. Press Install. A new game version and profile will be created in the launcher’s menu, which you can now use to launch Fabric.

For more detailed instructions visit this guide: Install using the Minecraft Launcher

Server (simple method)

The new server installation uses a single jar file as a launcher. This launcher first downloads any missing Fabric Loader or Minecraft files, then continues with running the game server. There is no explicit installation and the desired versions as selected on the homepage are already baked into this jar file.

  1. Put the Fabric Server Launcher jar file into a directory of your choice, local or on a remote server
  2. Run the server with , the exact command is provided on the download website in step 1

With Minecraft specific server hosts, admin panels or start scripts the Fabric Launcher jar file can be used as a drop-in replacement for a vanilla server jar. It can be invoked in the same way and behaves similarly.

Server (manual method)

Note: Up-to-date as of Loader 0.4.4+. Older versions choose different techniques. Installer 0.4.0+ required!

  1. Open the installer. Select the “Server” tab at the top of the window.
  2. In the window you need to configure the mapping and loader version and the install location.NOTE You need to enable snapshots in order to make the installer show mapping options for Minecraft snapshots.
  3. Press Install. In the output directory, a will be created. It expects a , which is the vanilla server JAR, generally found on Mojang’s version announcement blog posts, next to it, but will also generate a properties file on first launch where you can change the path.NOTE If you are upgrading your existing server, remember to remove the folder if the installer did not remove that for you! Or you will get classloading errors.
  4. When uploading to a remote host, make sure to include , , and the folder with its contents

For more detailed instructions visit:

  • Installing a Fabric Server (Windows)

  • Installing a Fabric Server without a GUI

ObjectShare

The object share is very similar to a String-indexed Java with arbitrary values. It offers the usual /// operations and additionally to listen for additions in cases without clear ordering.

Its primary purpose is inter-mod communication. One mod can put some data into it, another mod can pull it back out. Active interactions are possible by publishing and using objects with interfaces like or .

Contrary to any regular API the object share allows mod interaction without even a compile time dependency, removing friction for simple purposes. This case requires commonly available types/interfaces like the ones provided by Java, Minecraft or Fabric API (String, Integer, List, Map, Identifier, NbtCompound, Event, …). Custom types are of course still possible, but don’t carry these benefits.

For Mod Developers

Various technical changes have been made in both Minecraft and Fabric that will affect mod development for 1.18.

As always, you can use the versions page to determine the recommended versions of Yarn, Fabric Loader, Fabric API, and Loom for any version of Minecraft.

Java 17

Once again, Minecraft has updated its Java version, this time to Java 17. This means mods can be compiled for Java 17 and use the latest features.

While not as large a step up as the previous move to Java 16 made in 1.17, Java 17 still provides some new features that can be used, such as Sealed Classes.

To set up a development environment you will need to use Java 17, Loom 0.10, and Gradle 7.3 or higher. If you need some help getting set up, please go to on the official Discord server.

See this commit for an example of how the example mod was updated to accomodate this change.

Fabric API

Fabric API has been fully updated to Java 17 and 1.18.

Since 1.17 released, we have added a number of new APIs that can be used:

  • Fluid and Item Transfer API. (Technici4n)
  • Tag Factory API, allows making tags for any registry (deirn)
  • Add sleeping events. (Juuxel)
  • Add flattening, stripping and tilling registries. (Juuxel)
  • Add a Game Test API to allow the use of Mojang’s testing framework. (modmuss50)
  • Add tag-based mining level API, fix and deprecate FabricBlockSetting.breakByTool. (Juuxel)
  • Add event phases to allow ordering between listeners. (Technici4n)
  • Add DimensionRenderingRegistry to register custom renderers for the sky or weather. (Waterpicker)
  • Add custom fluid renderers and enhanced vanilla fluid renderer customisation. (FoxShadew)
  • Add elytra flight API (Technici4n)
  • Add Oxidizable and Waxable Blocks registries (Shnupbups)
  • a variety of smaller or more focused additions and enhancements (see GitHub)

Most of these new features have also been added to the 1.17 version of Fabric API.

World Generation

Minecraft 1.18 overhauls many systems used in world generation. Any mods that include world generation will, as a result, need to adjust to these changes.

If you need some help with these changes, please go to on the official Discord server.

Yarn

Since 1.17.1, there have been almost 200 commits to Yarn from many contributors, all working to improve coverage and quality.

Trying to document the Minecraft codebase is a massive job, especially as it is constantly evolving. Improving the documentation provided by Yarn is an ongoing effort by all of the contributors.

You can view the online Javadoc for 1.18 Release Candidate 4 here or inline with the decompiled and named Minecraft sources directly attached in your IDE.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Adblock
detector