update to latest recommended Forge
This commit is contained in:
@@ -12,7 +12,7 @@ const val PI2 = 2.0 * PI
|
||||
inline fun String.stripStart(str: String) = if (startsWith(str)) substring(str.length) else this
|
||||
|
||||
/** Strip the given prefix off the start of the resource path, if present */
|
||||
inline fun ResourceLocation.stripStart(str: String) = ResourceLocation(resourceDomain, resourcePath.stripStart(str))
|
||||
inline fun ResourceLocation.stripStart(str: String) = ResourceLocation(namespace, path.stripStart(str))
|
||||
|
||||
/** Mutating version of _map_. Replace each element of the list with the result of the given transformation. */
|
||||
inline fun <reified T> MutableList<T>.replace(transform: (T) -> T) = forEachIndexed { idx, value -> this[idx] = transform(value) }
|
||||
|
||||
@@ -171,7 +171,7 @@ class RenderVertex() {
|
||||
|
||||
fun BufferBuilder.ensureSpaceForQuads(num: Int) {
|
||||
rawIntBuffer.position(bufferSize)
|
||||
growBuffer(num * vertexFormat.nextOffset)
|
||||
growBuffer(num * vertexFormat.size)
|
||||
}
|
||||
|
||||
val allFaces: (EnumFacing) -> Boolean = { true }
|
||||
|
||||
@@ -34,13 +34,13 @@ class GeneratorPack(val name: String, vararg val generators: GeneratorBase) : IR
|
||||
override fun resourceExists(location: ResourceLocation?): Boolean =
|
||||
if (location == null) false
|
||||
else generators.find {
|
||||
it.domain == location.resourceDomain && it.resourceExists(location)
|
||||
it.domain == location.namespace && it.resourceExists(location)
|
||||
} != null
|
||||
|
||||
override fun getInputStream(location: ResourceLocation?): InputStream? =
|
||||
if (location == null) null
|
||||
else generators.filter {
|
||||
it.domain == location.resourceDomain && it.resourceExists(location)
|
||||
it.domain == location.namespace && it.resourceExists(location)
|
||||
}.map { it.getInputStream(location) }
|
||||
.filterNotNull().first()
|
||||
|
||||
@@ -114,7 +114,7 @@ abstract class ParameterBasedGenerator(domain: String) : GeneratorBase(domain) {
|
||||
abstract fun getInputStream(params: ParameterList): InputStream?
|
||||
|
||||
override fun resourceExists(location: ResourceLocation?) =
|
||||
resourceExists(ParameterList.fromString(location?.resourcePath ?: ""))
|
||||
resourceExists(ParameterList.fromString(location?.path ?: ""))
|
||||
override fun getInputStream(location: ResourceLocation?) =
|
||||
getInputStream(ParameterList.fromString(location?.resourcePath ?: ""))
|
||||
getInputStream(ParameterList.fromString(location?.path ?: ""))
|
||||
}
|
||||
@@ -45,9 +45,9 @@ open class ResourceHandler(val modId: String) {
|
||||
// Resource declarations
|
||||
// ============================
|
||||
fun iconStatic(domain: String, path: String) = IconHolder(domain, path).apply { resources.add(this) }
|
||||
fun iconStatic(location: ResourceLocation) = iconStatic(location.resourceDomain, location.resourcePath)
|
||||
fun iconStatic(location: ResourceLocation) = iconStatic(location.namespace, location.path)
|
||||
fun iconSet(domain: String, pathPattern: String) = IconSet(domain, pathPattern).apply { resources.add(this) }
|
||||
fun iconSet(location: ResourceLocation) = iconSet(location.resourceDomain, location.resourcePath)
|
||||
fun iconSet(location: ResourceLocation) = iconSet(location.namespace, location.path)
|
||||
fun model(init: Model.()->Unit) = ModelHolder(init).apply { resources.add(this) }
|
||||
fun modelSet(num: Int, init: Model.(Int)->Unit) = ModelSet(num, init).apply { resources.add(this) }
|
||||
fun vectorSet(num: Int, init: (Int)-> Double3) = VectorSet(num, init).apply { resources.add(this) }
|
||||
|
||||
@@ -32,7 +32,7 @@ abstract class TextureGenerator(domain: String) : ParameterBasedGenerator(domain
|
||||
domain,
|
||||
textureLocation(iconName).let {
|
||||
ParameterList(
|
||||
mapOf("dom" to it.resourceDomain, "path" to it.resourcePath) +
|
||||
mapOf("dom" to it.namespace, "path" to it.path) +
|
||||
extraParams.map { Pair(it.first, it.second.toString()) },
|
||||
"generate"
|
||||
).toString()
|
||||
|
||||
@@ -27,7 +27,7 @@ val resourceManager: SimpleReloadableResourceManager get() =
|
||||
Minecraft.getMinecraft().resourceManager as SimpleReloadableResourceManager
|
||||
|
||||
/** Append a string to the [ResourceLocation]'s path. */
|
||||
operator fun ResourceLocation.plus(str: String) = ResourceLocation(resourceDomain, resourcePath + str)
|
||||
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))
|
||||
@@ -66,7 +66,7 @@ val BufferedImage.asStream: InputStream get() =
|
||||
*/
|
||||
val TextureAtlasSprite.averageColor: Int? get() {
|
||||
val locationNoDirs = ResourceLocation(iconName).stripStart("blocks/")
|
||||
val locationWithDirs = ResourceLocation(locationNoDirs.resourceDomain, "textures/blocks/%s.png".format(locationNoDirs.resourcePath))
|
||||
val locationWithDirs = ResourceLocation(locationNoDirs.namespace, "textures/blocks/%s.png".format(locationNoDirs.path))
|
||||
val image = resourceManager[locationWithDirs]?.loadImage() ?: return null
|
||||
|
||||
var numOpaque = 0
|
||||
@@ -97,8 +97,8 @@ val TextureAtlasSprite.averageColor: Int? get() {
|
||||
* Get the actual location of a texture from the name of its [TextureAtlasSprite].
|
||||
*/
|
||||
fun textureLocation(iconName: String) = ResourceLocation(iconName).let {
|
||||
if (it.resourcePath.startsWith("mcpatcher")) it
|
||||
else ResourceLocation(it.resourceDomain, "textures/${it.resourcePath}")
|
||||
if (it.path.startsWith("mcpatcher")) it
|
||||
else ResourceLocation(it.namespace, "textures/${it.path}")
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
||||
Reference in New Issue
Block a user