package mods.betterfoliage.util import net.minecraft.client.MinecraftClient import net.minecraft.resource.ReloadableResourceManager import net.minecraft.resource.Resource import net.minecraft.resource.ResourceManager import net.minecraft.util.Identifier /** Concise getter for the Minecraft resource manager. */ val resourceManager: ReloadableResourceManager get() = MinecraftClient.getInstance().resourceManager as ReloadableResourceManager /** Append a string to the [ResourceLocation]'s path. */ operator fun Identifier.plus(str: String) = Identifier(namespace, path + str) /** Index operator to get a resource. */ operator fun ResourceManager.get(domain: String, path: String): Resource? = get(Identifier(domain, path)) /** Index operator to get a resource. */ operator fun ResourceManager.get(location: Identifier): Resource? = tryDefault(null) { getResource(location) } /** Get the lines of a text resource. */ fun Resource.getLines(): List { val result = arrayListOf() inputStream.bufferedReader().useLines { it.forEach { result.add(it) } } return result }