Merge branch 'kotlin-1.8' into kotlin-1.8.8

This commit is contained in:
octarine-noise
2016-02-21 10:39:14 +01:00
13 changed files with 22 additions and 15 deletions

View File

@@ -91,7 +91,7 @@ data class Quad(val v1: Vertex, val v2: Vertex, val v3: Vertex, val v4: Vertex)
*/
class Model() {
constructor(other: List<Quad>) : this() { quads.addAll(other) }
val quads = linkedListOf<Quad>()
val quads = mutableListOf<Quad>()
fun Quad.add() = quads.add(this)
fun Iterable<Quad>.addAll() = forEach { quads.add(it) }

View File

@@ -74,8 +74,15 @@ open class ShadingContext {
var aoEnabled = Minecraft.isAmbientOcclusionEnabled()
val aoFaces = Array(6) { AoFaceData(forgeDirs[it]) }
val EnumFacing.aoMultiplier: Float get() = when(this) {
UP -> 1.0f
DOWN -> 0.5f
NORTH, SOUTH -> 0.8f
EAST, WEST -> 0.6f
}
fun updateShading(offset: Int3, predicate: (EnumFacing) -> Boolean = { true }) {
forgeDirs.forEach { if (predicate(it)) aoFaces[it.ordinal].update(offset) }
forgeDirs.forEach { if (predicate(it)) aoFaces[it.ordinal].update(offset, multiplier = it.aoMultiplier) }
}
fun aoShading(face: EnumFacing, corner1: EnumFacing, corner2: EnumFacing) =

View File

@@ -57,14 +57,14 @@ class AoFaceData(val face: EnumFacing) {
EAST -> listOf(topRight, topLeft, bottomLeft, bottomRight)
}
fun update(offset: Int3, useBounds: Boolean = false) {
fun update(offset: Int3, useBounds: Boolean = false, multiplier: Float = 1.0f) {
val ctx = blockContext
val blockState = ctx.blockState(offset)
val quadBounds: FloatArray = FloatArray(12)
val flags = BitSet(3).apply { set(0) }
ao.updateVertexBrightness(ctx.world, blockState.block, ctx.pos + offset, face, quadBounds, flags)
ordered.forEachIndexed { idx, aoData -> aoData.set(ao.vertexBrightness[idx], ao.vertexColorMultiplier[idx]) }
ordered.forEachIndexed { idx, aoData -> aoData.set(ao.vertexBrightness[idx], ao.vertexColorMultiplier[idx] * multiplier) }
}
operator fun get(dir1: EnumFacing, dir2: EnumFacing): AoData {

View File

@@ -53,7 +53,7 @@ abstract class ModelDataInspector {
abstract class BlockTextureInspector<T> : ModelDataInspector() {
val state2Names = hashMapOf<IBlockState, Iterable<String>>()
val modelMappings = linkedListOf<Pair<(IBlockState, IModel)->Boolean, Iterable<String>>>()
val modelMappings = mutableListOf<Pair<(IBlockState, IModel)->Boolean, Iterable<String>>>()
val stateMap = hashMapOf<IBlockState, T>()
fun match(textureNames: Iterable<String>, predicate: (IBlockState, IModel)->Boolean) =

View File

@@ -34,7 +34,7 @@ interface IWorldLoadListener { fun onWorldLoad(world: World) }
*/
open class ResourceHandler(val modId: String) {
val resources = linkedListOf<Any>()
val resources = mutableListOf<Any>()
open fun afterStitch() {}
// ============================

View File

@@ -79,7 +79,7 @@ abstract class TextureGenerator(domain: String) : ParameterBasedGenerator(domain
*/
fun getMultisizeTexture(maxSize: Int, maskPath: (Int)->ResourceLocation): IResource? {
var size = maxSize
val sizes = linkedListOf<Int>()
val sizes = mutableListOf<Int>()
while(size > 2) { sizes.add(size); size /= 2 }
return sizes.map { resourceManager[maskPath(it)] }.filterNotNull().firstOrNull()
}

View File

@@ -38,7 +38,7 @@ abstract class DelegatingConfig(val modId: String, val langPrefix: String) {
/** The [Configuration] backing this config object. */
var config: Configuration? = null
val rootGuiElements = linkedListOf<IConfigElement>()
val rootGuiElements = mutableListOf<IConfigElement>()
/** Attach this config object to the given [Configuration] and update all properties. */
fun attach(config: Configuration) {