mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-30 20:14:23 +00:00
Extractor: Add Tags
This commit is contained in:
10731
assets/tags.json
Normal file
10731
assets/tags.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,7 @@ class Extractor : ModInitializer {
|
||||
SyncedRegistries(),
|
||||
Packets(),
|
||||
Screens(),
|
||||
Tags(),
|
||||
Items(),
|
||||
Blocks(),
|
||||
)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package de.snowii.extractor.extractors
|
||||
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonElement
|
||||
import com.google.gson.JsonObject
|
||||
import de.snowii.extractor.Extractor
|
||||
import net.minecraft.registry.tag.TagPacketSerializer
|
||||
import net.minecraft.server.MinecraftServer
|
||||
|
||||
|
||||
class Tags : Extractor.Extractor {
|
||||
override fun fileName(): String {
|
||||
return "tags.json"
|
||||
}
|
||||
|
||||
override fun extract(server: MinecraftServer): JsonElement {
|
||||
val tagsJson = JsonArray()
|
||||
|
||||
val tags = TagPacketSerializer.serializeTags(server.combinedDynamicRegistries)
|
||||
|
||||
for (tag in tags.entries) {
|
||||
val tagGroupTagsJson = JsonObject()
|
||||
tagGroupTagsJson.addProperty("name", tag.key.value.toString())
|
||||
val tagValues =
|
||||
tag.value.toRegistryTags(server.combinedDynamicRegistries.combinedRegistryManager.getOrThrow(tag.key))
|
||||
for (value in tagValues.tags) {
|
||||
val tagGroupTagsJsonArray = JsonArray()
|
||||
for (tagVal in value.value) {
|
||||
tagGroupTagsJsonArray.add(tagVal.key.orElseThrow().value.toString())
|
||||
}
|
||||
tagGroupTagsJson.add(value.key.id.toString(), tagGroupTagsJsonArray)
|
||||
}
|
||||
tagsJson.add(tagGroupTagsJson)
|
||||
}
|
||||
|
||||
return tagsJson
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user