mirror of
https://gitlab.bixilon.de/bixilon/pixlyzer.git
synced 2025-09-26 21:50:02 -04:00
message type generator
This commit is contained in:
parent
65df3a7973
commit
dd50724796
@ -10,6 +10,7 @@ import de.bixilon.pixlyzer.generator.generators.variants.FrogVariantGenerator
|
||||
|
||||
object Generators {
|
||||
val GENERATORS: List<Generator> = mutableListOf(
|
||||
MessageTypeGenerator,
|
||||
ArgumentTypeGenerator,
|
||||
SoundGroupGenerator,
|
||||
CatVariantGenerator,
|
||||
|
@ -0,0 +1,47 @@
|
||||
package de.bixilon.pixlyzer.generator.generators
|
||||
|
||||
import de.bixilon.pixlyzer.generator.Generator
|
||||
import de.bixilon.pixlyzer.util.Util
|
||||
import de.bixilon.pixlyzer.util.Util.JSON_MAP_TYPE
|
||||
import de.bixilon.pixlyzer.util.Util.compound
|
||||
import net.minecraft.text.Decoration
|
||||
import net.minecraft.text.Decoration.Parameter
|
||||
import net.minecraft.util.registry.BuiltinRegistries
|
||||
|
||||
object MessageTypeGenerator : Generator(
|
||||
"message_types"
|
||||
) {
|
||||
|
||||
override fun generate() {
|
||||
val registry = BuiltinRegistries.MESSAGE_TYPE
|
||||
for (type in registry) {
|
||||
val identifier = registry.getId(type)
|
||||
|
||||
val json = compound()
|
||||
|
||||
json["id"] = registry.getRawId(type)
|
||||
json["chat"] = type.chat.serialize()
|
||||
json["narration"] = type.narration.serialize()
|
||||
|
||||
this.data[identifier.toString()] = json
|
||||
}
|
||||
}
|
||||
|
||||
fun Decoration.serialize(): Map<String, Any> {
|
||||
return mapOf(
|
||||
"translation_key" to translationKey,
|
||||
"parameters" to parameters.serialize(),
|
||||
"style" to Util.MAPPER.convertValue(style, JSON_MAP_TYPE),
|
||||
)
|
||||
}
|
||||
|
||||
fun Collection<Parameter>.serialize(): List<Any> {
|
||||
val output: MutableList<Any> = mutableListOf()
|
||||
|
||||
for (entry in this) {
|
||||
output += entry.name.lowercase()
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
Subproject commit bb23397ad61589e90a61edcffebbe6410af90b45
|
||||
Subproject commit d91f7dfc1bd1578f78ed55db4bb6ba07ccd802b1
|
Loading…
x
Reference in New Issue
Block a user