MODの情報の登録 (1.16.4)

概要

MOD一覧などに表示される情報を登録します。

動作確認

2020年11月28日

  • Minecraft 1.16.4
  • Forge 35.1.0

解説

実際に自分のMODを作る際は、「TNT Modders」などを置き換えてください。

リソースパックの情報

TitaniumMod/src/main/resources/pack.mcmeta

{
    "pack": {
        "description": "Titanium Mod Resources",
        "pack_format": 6
    }
}

descriptionにはリソースパックとしての説明を記述します。pack_formatは1.16.2~1.16.4に対応する6を指定します。

mods.toml

TitaniumMod/src/main/resources/META-INF/mods.toml

modLoader = "javafml"
loaderVersion = "[35,)"
license = "The Unlicense"
issueTrackerURL = "https://www.tntmodders.com/tutorial/"

[[mods]]
modId = "titaniummod"
version = "${file.jarVersion}"
displayName = "Titanium Mod"
displayURL = "https://www.tntmodders.com/tutorial/"
logoFile = "logo.png"
credits = "TNT Modders"
authors = "Akasata Nahama, Tom Kate"
description = "This mod adds titanium to the Minecraft world.nThis is an example mod to show what you need to change."

[[dependencies.titaniummod]]
modId = "forge"
mandatory = true
versionRange = "[35,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.titaniummod]]
modId = "minecraft"
mandatory = true
versionRange = "[1.16.4,1.17)"
ordering = "NONE"
side = "BOTH"

MODの読み込みや一覧表示に使われる情報を記述します。

licenseはMODの利用条件を指定します。このMODはサンプル用なので「Unlicense」という極めて緩いライセンスを採用しています。デフォルトはAll rights reserved(すべての権利を留保する)で、著作権法上の例外や別途の許諾を除き、複製や再配布などを禁止します。Modpackでの利用や改変、再配布などをどこまで許容するか考え、自分で利用条件を決めたり、既存のライセンスを選んだりしてもよいでしょう。

issueTrackerURLは不具合の報告を受け付けるURL、logoFileはロゴ画像のファイル名、creditsは謝辞をそれぞれ指定します。issueTrackerURLdisplayURLlogoFilecreditsauthorsは無くても問題ありません。

descriptionなどでTOMLの複数行文字列を使うと、改行コードをCRLFにして保存した時にCRが正常に表示されないため、LF(n)だけで改行しています。改行コードをLFにして保存すれば、複数行文字列も問題なく使えます。

ロゴ画像

TitaniumMod/src/main/resources/logo.png

logo.png

表示される際に画面に合わせて自動で拡大・縮小されるため、解像度は制限されていません。

build.gradle

TitaniumMod/build.gradle

buildscript {
    repositories {
        maven { url = 'https://files.minecraftforge.net/maven' }
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
    }
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '1.0'
group = 'com.tntmodders.titaniummod'
archivesBaseName = 'titaniummod'

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'

println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
    mappings channel: 'snapshot', version: '20201028-1.16.3'
    runs {
        client {
            workingDirectory project.file('run')
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
            property 'forge.logging.console.level', 'debug'
            mods {
                titaniummod {
                    source sourceSets.main
                }
            }
        }
        server {
            workingDirectory project.file('run')
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
            property 'forge.logging.console.level', 'debug'
            mods {
                titaniummod {
                    source sourceSets.main
                }
            }
        }
        data {
            workingDirectory project.file('run')
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
            property 'forge.logging.console.level', 'debug'
            args '--mod', 'titaniummod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
            mods {
                titaniummod {
                    source sourceSets.main
                }
            }
        }
    }
}

sourceSets.main.resources { srcDir 'src/generated/resources' }

dependencies {
    minecraft 'net.minecraftforge:forge:1.16.4-35.1.0'
}

jar {
    compileJava {
        options.encoding = 'UTF-8'
    }
    manifest {
        attributes([
                "Specification-Title"     : "Titanium Mod",
                "Specification-Vendor"    : "TNT Modders",
                "Specification-Version"   : "1",
                "Implementation-Title"    : "Titanium Mod",
                "Implementation-Vendor"   : "TNT Modders",
                "Implementation-Version"  : "${version}",
                "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
        ])
    }
}

jar.finalizedBy('reobfJar')

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifact jar
        }
    }
    repositories {
        maven {
            url "file:///${project.projectDir}/mcmodsrepo"
        }
    }
}

以下、元のbuild.gradleからの変更点を述べます。

groupcom.tntmodders.titaniummodに、archivesBaseNametitaniummodに変更しました。ビルド時に出力されるファイルの名前は(archivesBaseName)-(version).jarになります。

minecraft { runs {内の4つのexamplemodtitaniummodに置き換えました。リソースの自動生成を行う時に必要になる設定です。

jar {manifest {との間に行を追加し、compileJava { options.encoding = 'UTF-8' }を挿入しました。コード内コメントに日本語が入っていた時の文字化けを防ぐため、文字コードを指定しています。

jar { manifest { attributes([内のSpecification-TitleImplementation-TitleTitanium Modに、Specification-VendorImplementation-VendorTNT Moddersに変更しました。jarファイル内のMETA-INF/MANIFEST.MFに記載される情報です。

リンク


前:レシピの追加
次:ビルド

コメントはこちらです。(スパム対策の為コメントは手動承認になっています。未承認のコメントは表示されないので連投はお控え下さい。)

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください