HTTPS
https://git.nageyqma.icu/nageyqma/odin_next.git
SSH
git@git.nageyqma.icu:nageyqma/odin_next.git
HTTPS 链接可直接 git clone;推送代码请使用 SSH。
123456789101112131415161718192021222324
package com.odtheking.odin.utils
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.google.gson.reflect.TypeToken
import com.odtheking.odin.OdinMod.logger
import com.odtheking.odin.OdinMod.mc
import net.minecraft.resources.Identifier
object JsonResourceLoader {
val defaultGson: Gson = GsonBuilder().setPrettyPrinting().create()
inline fun <reified T> loadJson(identifier: Identifier): T? {
return try {
mc.resourceManager.getResource(identifier).get().openAsReader().use { reader -> defaultGson.fromJson(reader, object : TypeToken<T>() {}.type) }
} catch (e: Exception) {
logger.error("Error loading $identifier", e)
null
}
}
}