[WIP] initial Fabric port

major package refactoring
This commit is contained in:
octarine-noise
2020-02-05 13:42:48 +01:00
parent 2252fb3b42
commit df50f61b0d
151 changed files with 5181 additions and 5663 deletions

View File

@@ -0,0 +1,30 @@
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<String> {
val result = arrayListOf<String>()
inputStream.bufferedReader().useLines { it.forEach { result.add(it) } }
return result
}