From 5a97979d768831ed9a733c44060f72230bb0f58b Mon Sep 17 00:00:00 2001 From: Amarok <snowlyicewolf@outlook.com> Date: Tue, 7 May 2024 23:14:48 +0800 Subject: [PATCH] Generator --- .../club/someoneice/ovo/core/DataProcessor.kt | 3 ++- .../club/someoneice/ovo/data/BiomesData.kt | 4 +-- .../someoneice/ovo/generator/GeneratorMain.kt | 25 ++++++++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/club/someoneice/ovo/core/DataProcessor.kt b/src/main/kotlin/club/someoneice/ovo/core/DataProcessor.kt index b681942..ee00331 100644 --- a/src/main/kotlin/club/someoneice/ovo/core/DataProcessor.kt +++ b/src/main/kotlin/club/someoneice/ovo/core/DataProcessor.kt @@ -26,10 +26,11 @@ class DataProcessor(data: File, private val modid: String) { this.dataDeleteRecipes.forEach { it.toItemStack()?.let(RemoveRecipes::removeAllRecipe) } val itemListCache = HashMap<String, Item>() + val blockListCache = HashMap<String, Block>() + this.dataItem.forEach { itemListCache[it.name] = it.registryItem(modid) } this.dataItemTool.forEach { itemListCache[it.name] = it.registerTool() } - val blockListCache = HashMap<String, Block>() this.dataBlock.forEach { blockListCache[it.name] = it.registerBlock() } this.dataBiomes.forEach(BiomesData::register) diff --git a/src/main/kotlin/club/someoneice/ovo/data/BiomesData.kt b/src/main/kotlin/club/someoneice/ovo/data/BiomesData.kt index 86b3ea3..bb3b3bf 100644 --- a/src/main/kotlin/club/someoneice/ovo/data/BiomesData.kt +++ b/src/main/kotlin/club/someoneice/ovo/data/BiomesData.kt @@ -36,8 +36,8 @@ data class BiomesData ( @SideOnly(Side.CLIENT) override fun getModdedBiomeGrassColor(original: Int): Int = this@BiomesData.grassColor @SideOnly(Side.CLIENT) override fun getWaterColorMultiplier(): Int = this@BiomesData.waterColor - @SideOnly(Side.CLIENT) override fun getBiomeGrassColor(p_150558_1_: Int, p_150558_2_: Int, p_150558_3_: Int): Int = this@BiomesData.grassColor - @SideOnly(Side.CLIENT) override fun getBiomeFoliageColor(p_150571_1_: Int, p_150571_2_: Int, p_150571_3_: Int): Int = this@BiomesData.grassColor + @SideOnly(Side.CLIENT) override fun getBiomeGrassColor(x: Int, y: Int, z: Int): Int = this@BiomesData.grassColor + @SideOnly(Side.CLIENT) override fun getBiomeFoliageColor(x: Int, y: Int, z: Int): Int = this@BiomesData.grassColor } } diff --git a/src/main/kotlin/club/someoneice/ovo/generator/GeneratorMain.kt b/src/main/kotlin/club/someoneice/ovo/generator/GeneratorMain.kt index f68962c..ae34a2c 100644 --- a/src/main/kotlin/club/someoneice/ovo/generator/GeneratorMain.kt +++ b/src/main/kotlin/club/someoneice/ovo/generator/GeneratorMain.kt @@ -1,4 +1,27 @@ package club.someoneice.ovo.generator -class GeneratorMain { +import java.io.File + +object GeneratorMain { + @JvmStatic + fun main(args: Array<String>) { + val path = if (args.size > 1) args[0] else askForPath() + val file = File(path) + if (!file.exists() || !file.isDirectory) throw IllegalArgumentException("Cannot scan a non-directory!") + + file.listFiles()?.forEach(GeneratorMain::scanFile) + } + + private fun scanFile(file: File) { + if (!file.endsWith(".json") && !file.endsWith(".json5")) return + val fileName = file.nameWithoutExtension + + } + + private fun askForPath(): String { + println("请输入路径:") + while (true) { + readln().apply { if (isEmpty()) return@apply else return@askForPath this } + } + } } \ No newline at end of file