Skip to content

Commit

Permalink
マッピングテスト
Browse files Browse the repository at this point in the history
  • Loading branch information
MORIMORI0317 committed Feb 23, 2024
1 parent d27814c commit 1c89b5c
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 8 deletions.
Binary file added generate/resources/gui/auto/arrow_down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added generate/resources/gui/auto/arrow_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added generate/resources/gui/auto/arrow_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added generate/resources/gui/auto/arrow_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added generate/resources/gui/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 30 additions & 8 deletions generate/scripts/generator.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import java.util.function.Function
import java.util.zip.ZipInputStream
import javax.imageio.ImageIO
import kotlin.coroutines.EmptyCoroutineContext
import kotlin.streams.toList // <- 消したらActions本番環境で動かなくなる

/*
それぞれのディレクトリの名称
Expand Down Expand Up @@ -156,7 +155,12 @@ val packAssetsDir = File(packFolder, "assets")
/**
* 基本的なアイテムモデルのテンプレート
*/
val basicFlatItemModelTemplate = JsonTemplate<BasicItemApplier>(templateModelFile("basic_flat_item.json"))
val basicFlatItemModelTemplate = JsonTemplate<SimpleItemApplier>(templateModelFile("basic_flat_item.json"))

/**
* 剣やピッケルなど道具のような持ち方をするアイテムモデルのテンプレート
*/
val handHeldItemModelTemplate = JsonTemplate<SimpleItemApplier>(templateModelFile("handheld_item.json"))

/* ------------------------------------------------------------------------------------------------------------ */

Expand Down Expand Up @@ -202,8 +206,6 @@ runBlocking {
zipIn.use {
var entry = it.nextEntry

Thread.sleep(1000)

while (entry != null) {

// 今のところモデルのみ展開
Expand Down Expand Up @@ -324,9 +326,20 @@ fun initTasks() {
// /give @s minecraft:slime_ball{CustomModelData:1}

//
basicFlatItemModelTask("slime_ball", "test", resItemTexFile("test_1.png"))


// basicFlatItemModelTask("slime_ball", 1, resItemTexFile("test.png"))
// basicFlatItemModelTask("slime_ball", 3, slLoc("item/test"))
/*basicFlatItemModelTask("slime_ball", "test", resItemTexFile("test_1.png"))
basicFlatItemModelTask("slime_ball", "test", resItemTexFile("test_1.png"))
basicFlatItemModelTask("slime_ball", "gui/background", resGuiTexFile("background.png"))*/


/* basicFlatItemModelTask("slime_ball", 10, slLoc("item/test"))
basicFlatItemModelTask("slime_ball", 12, slLoc("item/test"))
basicFlatItemModelTask("slime_ball", "", slLoc("item/test"))*/
}

/**
Expand All @@ -341,7 +354,7 @@ fun basicFlatItemModelTask(injectItemModelName: String, mappingId: String, textu
// モデル生成タスクを登録
val modelLocFile = locationFileByModel(slLoc("item/${FNStringUtil.removeExtension(textureFile.name)}"))
val modelLoc = reservationNumberingResourceHolders(modelLocFile).toModelLocation()
regTask(ModelGenTask(basicFlatItemModelTemplate, BasicItemApplier(texLoc), modelLoc))
regTask(ModelGenTask(basicFlatItemModelTemplate, SimpleItemApplier(texLoc), modelLoc))

// モデル注入タスクを登録
regTask(ModelNumberingInjectionTask(injectItemModelName, mappingId, modelLoc))
Expand All @@ -354,7 +367,7 @@ fun basicFlatItemModelTask(injectItemModelName: String, customModelNum: Int, tex
// モデル生成タスクを登録
val modelLocFile = locationFileByModel(textureLocation)
val modelLoc = reservationNumberingResourceHolders(modelLocFile).toModelLocation()
regTask(ModelGenTask(basicFlatItemModelTemplate, BasicItemApplier(textureLocation), modelLoc))
regTask(ModelGenTask(basicFlatItemModelTemplate, SimpleItemApplier(textureLocation), modelLoc))

// 注入先モデルにモデルを登録
val injectModelLocFile = locationFileByModel(ResourceLocation("item/$injectItemModelName"))
Expand All @@ -376,7 +389,7 @@ fun basicFlatItemModelTask(injectItemModelName: String, customModelNum: Int, tex
// モデル生成タスクを登録
val modelLocFile = locationFileByModel(slLoc("item/${FNStringUtil.removeExtension(textureFile.name)}"))
val modelLoc = reservationNumberingResourceHolders(modelLocFile).toModelLocation()
regTask(ModelGenTask(basicFlatItemModelTemplate, BasicItemApplier(texLoc), modelLoc))
regTask(ModelGenTask(basicFlatItemModelTemplate, SimpleItemApplier(texLoc), modelLoc))

// 注入先モデルにモデルを登録
val injectModelLocFile = locationFileByModel(ResourceLocation("item/$injectItemModelName"))
Expand All @@ -385,6 +398,7 @@ fun basicFlatItemModelTask(injectItemModelName: String, customModelNum: Int, tex
injectModelHolder.dirty = true
}


/**
* タスク登録
*/
Expand Down Expand Up @@ -517,6 +531,14 @@ fun resItemTexFile(fileName: String): File {
return File(texItemsFile, fileName)
}

/**
* リソースフォルダ内のGUIテクスチャファイルを取得
*/
fun resGuiTexFile(fileName: String): File {
val texGuiFile = File(resourcesFolder, "gui")
return File(texGuiFile, fileName)
}

/**
* パックフォルダから相対的なファイルを取得
*/
Expand Down Expand Up @@ -893,7 +915,7 @@ data class CustomModelItemEntry(val model: ResourceLocation, val customModelNumb
/**
* 基本的なアイテムモデルのテンプレート適用クラス
*/
class BasicItemApplier(private val textureLocation: ResourceLocation) : TemplateApplier {
class SimpleItemApplier(private val textureLocation: ResourceLocation) : TemplateApplier {
override fun apply(templateJson: JsonObject) {
val texJo = templateJson.getAsJsonObject("textures")
texJo.addProperty("layer0", this.textureLocation.toString())
Expand Down
6 changes: 6 additions & 0 deletions generate/templates/models/handheld_item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": ""
}
}

0 comments on commit 1c89b5c

Please sign in to comment.