Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "io.github.dayyeeet.solid"
version = "1.0.0"
version = "1.0.1"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AdvancedResourcePack(
}

fun variantModel(target: Key, texture: Key): Key {
return apply<ModelVariantConfig, Key, ModelVariantFeature>(ModelVariantConfig(target, texture, null))
return apply<ModelVariantConfig, Key, ModelVariantFeature>(ModelVariantConfig(target, texture, ModelVariantConfig.Textures.simple(texture), mapOf()))
}

fun linkModel(config: PredicateConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ModelModifierFeature : ResourcePackFeature<ModelModifierConfig, Unit> {

private val gson = Gson()
override fun apply(config: ModelModifierConfig, pack: ResourcePack) {
if(pack.model(config.key) != null) return
val model = gson.fromJson(config.data.toUTF8String(), JsonObject::class.java)
val obj = model.get("textures").asJsonObject
val map = obj.asMap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,26 @@ import team.unnamed.creative.texture.Texture

class ModelVariantFeature : ResourcePackFeature<ModelVariantConfig, Key> {
override fun apply(config: ModelVariantConfig, pack: ResourcePack): Key {
config.textureData?.let { data ->
pack.texture(Texture.texture(config.texture, data))
config.textureData.forEach { data ->
if(pack.texture(data.key) == null)
pack.texture(Texture.texture(data.key, data.value))
}
val model = Model.model().key(config.texture).parent(config.target)
.textures(ModelTextures.builder().layers(ModelTexture.ofKey(config.texture)).build())
val model = Model.model().key(config.key).parent(config.target)
.textures(ModelTextures.builder().variables(config.textures).build())
pack.model(model.build())
return config.texture
return config.key
}
}

data class ModelVariantConfig(
val target: Key,
val texture: Key,
val textureData: Writable?
)
val key: Key,
val textures: Map<String, ModelTexture>,
val textureData: Map<Key, Writable>
) {
object Textures {
fun simple(texture: Key): Map<String, ModelTexture> {
return mapOf("layer0" to ModelTexture.ofKey(texture))
}
}
}
18 changes: 2 additions & 16 deletions src/test/kotlin/PredicateTest.kt
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
import io.github.dayyeeet.solid.builder.AdvancedResourcePack
import net.kyori.adventure.key.Key
import team.unnamed.creative.ResourcePack
import team.unnamed.creative.serialize.minecraft.MinecraftResourcePackReader
import java.io.File
import java.io.FileOutputStream

val BOOST_ARROW = Key.key("test", "item/boost_arrow")
fun main() {
val pack = AdvancedResourcePack(MinecraftResourcePackReader.minecraft().readFromZipFile(File("test.zip")))
val pack = AdvancedResourcePack(ResourcePack.resourcePack())
val mapper = TestMapper()
val fogVariant = pack.variantModel(Key.key("test", "item/fog"), Key.key("test", "item/fog1"))
pack.linkItemModel(
target = Key.key("minecraft", "item/paper"),
parent = Key.key("minecraft", "item/generated"),
BOOST_ARROW,
Key.key("test", "boost/fog"),
Key.key("test", "boost/fog_alt"),
fogVariant
)
pack.map(
mapper,
AdvancedResourcePack.Filters.MINECRAFT_FILTER,
{ model -> model.key().value().startsWith("item/") })
val build = pack.build()
val stream = FileOutputStream(File("test.zip"))
build.data().write(stream)
stream.close()

println(mapper.get(BOOST_ARROW))
println(mapper.get(fogVariant))
}