[WIP] start 1.15 port

reorganize packages to match Fabric version
use util classes from Fabric version
This commit is contained in:
octarine-noise
2021-05-01 13:52:21 +02:00
parent 9566ae8341
commit 09ccb83e8b
81 changed files with 1220 additions and 1011 deletions

View File

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