Знакомимся с fabric.js. часть 1-я

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"

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

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.

For more detailed instructions visit:

  • Installing a Fabric Server (Windows)

  • Installing a Fabric Server without a GUI

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

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

На очереди 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.

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

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

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

Теперь открываем файл в папке ресурсов: 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»»*»

}

}

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

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

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

Adblock
detector