目次
概要
MOD一覧などに表示される情報を登録します。
動作確認
2021年3月21日
- Minecraft 1.16.5
- Forge 36.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.5に対応する6
を指定します。
mods.toml
TitaniumMod/src/main/resources/META-INF/mods.toml
modLoader = "javafml"
loaderVersion = "[36,)"
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 = "[36,)"
ordering = "NONE"
side = "BOTH"
[[dependencies.titaniummod]]
modId = "minecraft"
mandatory = true
versionRange = "[1.16.5,1.17)"
ordering = "NONE"
side = "BOTH"
MODの読み込みや一覧表示に使われる情報を記述します。
license
はMODの利用条件を指定します。このMODは例なので「Unlicense」という極めて緩いライセンスを採用しています。デフォルトはAll rights reserved
(すべての権利を留保する)で、著作権法上の例外や別途の許諾を除き、複製や再配布などを禁止します。Modpackでの利用や改変、再配布などをどこまで許容するか考え、自分で利用条件を決めたり、既存のライセンスを選んだりしてもよいでしょう。
issueTrackerURL
は不具合の報告を受け付けるURL、logoFile
はロゴ画像のファイル名、credits
は謝辞をそれぞれ指定します。issueTrackerURL
、displayURL
、logoFile
、credits
、authors
は無くても問題ありません。
description
などでTOMLの複数行文字列を使うと、改行コードをCRLFにして保存した時にCRが正常に表示されないため、LF(\n
)だけで改行しています。改行コードをLFにして保存すれば、複数行文字列も問題なく使えます。
ロゴ画像
TitaniumMod/src/main/resources/logo.png
表示される際に画面に合わせて自動で拡大・縮小されるため、解像度は制限されていません。
build.gradle
TitaniumMod/build.gradle
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
version = '1.0'
group = 'com.tntmodders.titaniummod'
archivesBaseName = 'titaniummod'
java.toolchain.languageVersion = JavaLanguageVersion.of(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: 'official', version: '1.16.5'
runs {
client {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
mods {
titaniummod {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
mods {
titaniummod {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
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.5-36.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
からの変更点を述べます。
group
をcom.tntmodders.titaniummod
に、archivesBaseName
をtitaniummod
に変更しました。ビルド時に出力されるファイルの名前は(archivesBaseName)-(version).jar
になります。
minecraft { runs {
内の4つのexamplemod
をtitaniummod
に置き換えました。JSONファイルの自動生成を行う時に必要になる設定です。
jar {
とmanifest {
との間に行を追加し、compileJava { options.encoding = 'UTF-8' }
を挿入しました。コード内に日本語が入っていた時の文字化けを防ぐため、文字コードを指定しています。
jar { manifest { attributes([
内のSpecification-Title
とImplementation-Title
をTitanium Mod
に、Specification-Vendor
とImplementation-Vendor
をTNT Modders
に変更しました。jarファイル内のMETA-INF/MANIFEST.MF
に記載される情報です。
リンク
- Structuring Your Mod - Forge Documentation
- TOML - GitHub
- TOML: Tom's Obvious Minimal Language
- Choose a License
- Gradle
前:レシピの追加
次:ビルド