Skip to content

Instantly share code, notes, and snippets.

@flammpfeil
Created March 15, 2016 09:18
Show Gist options
  • Save flammpfeil/55474ddfb45b4b98a855 to your computer and use it in GitHub Desktop.
Save flammpfeil/55474ddfb45b4b98a855 to your computer and use it in GitHub Desktop.
gradle使って、Item用のjson一括生成サンプル
使い方
build.groovyの記述をbuild.gradleの後ろにでも追記する。
gradlew genItemRes
とでもコマンド叩けば実行される
destが生成先
templateがテンプレートファイル
listが生成されるファイル名群
tokens の textureL1 と
テンプレート中の @textureL1@ が対応して置き換えられる
tokens: [
'textureL1': "modid:items/"+replaceName ,
'textureL2': "modid:items/abc"
]
のように複数も指定可能
task genItemRes << {
def list = ["abc", "def", "ghi"]
def dest = 'src/main/resources/assets/modid/models/item'
def template = 'src/main/template/itemTemplate.json'
file(dest).mkdir()
for(replaceName in list){
copy{
from(template){
filter(
org.apache.tools.ant.filters.ReplaceTokens,
tokens: [
'textureL1': "modid:items/"+replaceName
]
)
}
into dest
rename{ fileName -> "${(replaceName)}.js"}
}
}
}
{
"parent": "builtin/generated",
"textures": {
"layer0": "@textureL1@"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment