Skip to content

Commit

Permalink
feat: add setting to include a resourcepack into Geary's generated one
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Aug 5, 2024
1 parent 67a6b3f commit 9033e07
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,7 @@ data class Integrations(
data class ResourcePack(
val generate: Boolean = true,
@YamlComment("The path to generate the pack to from `plugins/Geary`", "Adding .zip to path will export as a zip instead of directory")
val outputPath: String = "resourcepack.zip"
val outputPath: String = "resourcepack.zip",
@YamlComment("Points to a resourcepack in zip or directory format to merge into Geary's pack")
val includedPackPath: String = ""
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.mineinabyss.geary.papermc.features.items.resourcepacks

import com.mineinabyss.geary.modules.geary
import com.mineinabyss.geary.papermc.gearyPaper
import com.mineinabyss.geary.papermc.tracking.items.components.SetItem
import com.mineinabyss.geary.prefabs.PrefabKey
import com.mineinabyss.geary.prefabs.configuration.components.Prefab
import com.mineinabyss.geary.systems.builders.cache
Expand All @@ -16,8 +15,9 @@ import team.unnamed.creative.model.ModelTextures

class ResourcePackGenerator {

private val resourcePack: ResourcePack = ResourcePack.resourcePack()
private val resourcePackQuery = geary.cache(ResourcePackQuery())
private val includedPackPath = gearyPaper.plugin.dataFolder.resolve(gearyPaper.config.resourcePack.includedPackPath)
private val resourcePack = ResourcePacks.readToResourcePack(includedPackPath) ?: ResourcePack.resourcePack()

fun generateResourcePack() {
if (!gearyPaper.config.resourcePack.generate) return
Expand Down Expand Up @@ -45,15 +45,7 @@ class ResourcePackGenerator {
defaultVanillaModel.build().addTo(resourcePack)
}

when {
resourcePackFile.extension == "zip" -> ResourcePacks.resourcePackWriter.writeToZipFile(resourcePackFile, resourcePack)
resourcePackFile.isDirectory -> ResourcePacks.resourcePackWriter.writeToDirectory(resourcePackFile, resourcePack)
else -> {
gearyPaper.logger.w("Failed to generate resourcepack in ${resourcePackFile.path}")
gearyPaper.logger.w("Outputting to default plugins/Geary/resourcepack directory")
ResourcePacks.resourcePackWriter.writeToDirectory(gearyPaper.plugin.dataFolder.resolve("resourcepack"), resourcePack)
}
}
ResourcePacks.writeToFile(resourcePackFile, resourcePack)
}

private fun generatePredicateModels(resourcePack: ResourcePack, resourcePackContent: ResourcePackContent, prefabKey: PrefabKey) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kotlin.code.style=official
group=com.mineinabyss
version=0.30
idofrontVersion=0.24.17
idofrontVersion=0.24.18

0 comments on commit 9033e07

Please sign in to comment.