Merge branch 'kotlin-1.10' into kotlin-1.11.2
This commit is contained in:
@@ -2,7 +2,7 @@ apply plugin: "net.minecraftforge.gradle.forge"
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
group = 'com.github.octarine-noise'
|
||||
version = "2.1.6"
|
||||
version = "2.1.7"
|
||||
archivesBaseName = rootProject.name + '-MC1.11.2'
|
||||
|
||||
buildscript {
|
||||
|
||||
@@ -12,6 +12,7 @@ import mods.octarinecore.common.plus
|
||||
import mods.octarinecore.metaprog.allAvailable
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.state.IBlockState
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher
|
||||
import net.minecraft.client.renderer.VertexBuffer
|
||||
import net.minecraft.init.Blocks
|
||||
@@ -77,26 +78,24 @@ fun renderWorldBlock(dispatcher: BlockRendererDispatcher,
|
||||
worldRenderer: VertexBuffer,
|
||||
layer: BlockRenderLayer
|
||||
): Boolean {
|
||||
val doBaseRender = state.canRenderInLayer(layer) || (layer == targetCutoutLayer && state.canRenderInLayer(otherCutoutLayer))
|
||||
blockContext.let { ctx ->
|
||||
ctx.set(blockAccess, pos)
|
||||
Client.renderers.forEach { renderer ->
|
||||
if (renderer.isEligible(ctx)) {
|
||||
// render on the block's default layer AND CUTOUT_MIPPED if the renderer requires it
|
||||
if (state.canRenderInLayer(layer) || (layer.isCutout && renderer.addToCutout)) {
|
||||
// render on the block's default layer
|
||||
// also render on the cutout layer if the renderer requires it
|
||||
if (doBaseRender || (renderer.addToCutout && layer == targetCutoutLayer)) {
|
||||
return renderer.render(ctx, dispatcher, worldRenderer, layer)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// stuff on the CUTOUT layer must be rendered on CUTOUT_MIPPED instead if OptiFine is present
|
||||
val doBaseRender = state.canRenderInLayer(layer) || (isOptifinePresent && layer == CUTOUT_MIPPED && state.canRenderInLayer(CUTOUT))
|
||||
|
||||
return if (doBaseRender) dispatcher.renderBlock(state, pos, blockAccess, worldRenderer) else false
|
||||
}
|
||||
|
||||
fun canRenderBlockInLayer(block: Block, state: IBlockState, layer: BlockRenderLayer): Boolean {
|
||||
if (layer == CUTOUT_MIPPED && !block.canRenderInLayer(state, CUTOUT)) {
|
||||
return true
|
||||
}
|
||||
return block.canRenderInLayer(state, layer)
|
||||
fun canRenderBlockInLayer(block: Block, state: IBlockState, layer: BlockRenderLayer) = block.canRenderInLayer(state, layer) || layer == targetCutoutLayer
|
||||
|
||||
}
|
||||
val targetCutoutLayer: BlockRenderLayer get() = if (Minecraft.getMinecraft().gameSettings.mipmapLevels > 0) CUTOUT_MIPPED else CUTOUT
|
||||
val otherCutoutLayer: BlockRenderLayer get() = if (Minecraft.getMinecraft().gameSettings.mipmapLevels > 0) CUTOUT else CUTOUT_MIPPED
|
||||
@@ -248,7 +248,6 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
||||
postProcess = { _, _, _, _, _ ->
|
||||
if (isLidUp) {
|
||||
rotateUV(idx + if (logAxis == Axis.X) 1 else 0)
|
||||
if (logAxis == Axis.X) mirrorUV(true, true)
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -260,7 +259,6 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
||||
postProcess = { _, _, _, _, _ ->
|
||||
if (isLidDown) {
|
||||
rotateUV((if (logAxis == Axis.X) 0 else 3) - idx)
|
||||
if (logAxis != Axis.Y) mirrorUV(true, true)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ import mods.octarinecore.client.render.*
|
||||
import mods.octarinecore.common.Double3
|
||||
import mods.octarinecore.exchange
|
||||
import net.minecraft.util.EnumFacing.*
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
/** Weight of the same-side AO values on the outer edges of the 45deg chamfered column faces. */
|
||||
const val chamferAffinity = 0.9f
|
||||
@@ -13,6 +14,9 @@ const val chamferAffinity = 0.9f
|
||||
/** Amount to shrink column extension bits to stop Z-fighting. */
|
||||
val zProtectionScale: Double3 get() = Double3(Config.roundLogs.zProtection, 1.0, Config.roundLogs.zProtection)
|
||||
|
||||
/** nVidia does it different... */
|
||||
val nVidia = GL11.glGetString(GL11.GL_VENDOR).toLowerCase().contains("nvidia")
|
||||
|
||||
fun Model.columnSide(radius: Double, yBottom: Double, yTop: Double, transform: (Quad) -> Quad = { it }) {
|
||||
val halfRadius = radius * 0.5
|
||||
listOf(
|
||||
@@ -92,12 +96,14 @@ fun Model.columnLid(radius: Double, transform: (Quad)->Quad = { it }) {
|
||||
1 -> EdgeInterpolateFallback(UP, SOUTH, 0.0)
|
||||
else -> vertex.aoShader
|
||||
})}
|
||||
.cycleVertices(if (nVidia) 0 else 1)
|
||||
val q2 = Quad(v1, v4, v5, v6).setAoShader(faceOrientedAuto(overrideFace = UP, corner = cornerAo(Axis.Y)))
|
||||
.transformVI { vertex, idx -> vertex.copy(aoShader = when(idx) {
|
||||
0 -> FaceCenter(UP)
|
||||
3 -> EdgeInterpolateFallback(UP, EAST, 0.0)
|
||||
else -> vertex.aoShader
|
||||
})}
|
||||
.cycleVertices(if (nVidia) 0 else 1)
|
||||
listOf(q1, q2).forEach { transform(it.setFlatShader(FaceFlat(UP))).add() }
|
||||
}
|
||||
|
||||
|
||||
@@ -27,13 +27,9 @@ class RenderConnectedGrassLog : AbstractBlockRenderingHandler(BetterFoliageMod.M
|
||||
override fun render(ctx: BlockContext, dispatcher: BlockRendererDispatcher, renderer: VertexBuffer, layer: BlockRenderLayer): Boolean {
|
||||
val grassDir = grassCheckDirs.find {
|
||||
Config.blocks.grassClasses.matchesClass(ctx.block(it.offset))
|
||||
}
|
||||
} ?: return renderWorldBlockBase(ctx, dispatcher, renderer, layer)
|
||||
|
||||
return if (grassDir != null) {
|
||||
ctx.withOffset(Int3.zero, grassDir.offset) {
|
||||
renderWorldBlockBase(ctx, dispatcher, renderer, layer)
|
||||
}
|
||||
} else {
|
||||
return ctx.withOffset(Int3.zero, grassDir.offset) {
|
||||
renderWorldBlockBase(ctx, dispatcher, renderer, layer)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,3 +59,4 @@ fun Model.mix(first: Model, second: Model, predicate: (Int)->Boolean) {
|
||||
val BlockRenderLayer.isCutout: Boolean get() = (this == BlockRenderLayer.CUTOUT) || (this == BlockRenderLayer.CUTOUT_MIPPED)
|
||||
|
||||
fun IBlockState.canRenderInLayer(layer: BlockRenderLayer) = this.block.canRenderInLayer(this, layer)
|
||||
fun IBlockState.canRenderInCutout() = this.block.canRenderInLayer(this, BlockRenderLayer.CUTOUT) || this.block.canRenderInLayer(this, BlockRenderLayer.CUTOUT_MIPPED)
|
||||
@@ -102,6 +102,8 @@ object Refs {
|
||||
val CPmatchesBlock = MethodRef(ConnectedProperties, "matchesBlock", ClassRef.boolean, ClassRef.int, ClassRef.int)
|
||||
val CPmatchesIcon = MethodRef(ConnectedProperties, "matchesIcon", ClassRef.boolean, TextureAtlasSprite)
|
||||
|
||||
val quadSprite = FieldRef(VertexBuffer, "quadSprite", TextureAtlasSprite)
|
||||
|
||||
// ShadersMod
|
||||
val SVertexBuilder = ClassRef("shadersmod.client.SVertexBuilder")
|
||||
val sVertexBuilder = FieldRef(VertexBuffer, "sVertexBuilder", SVertexBuilder)
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
@file:JvmName("RendererHolder")
|
||||
package mods.octarinecore.client.render
|
||||
|
||||
import mods.betterfoliage.client.render.canRenderInCutout
|
||||
import mods.betterfoliage.client.render.canRenderInLayer
|
||||
import mods.betterfoliage.client.render.isCutout
|
||||
import mods.octarinecore.ThreadLocalDelegate
|
||||
import mods.octarinecore.client.resource.ResourceHandler
|
||||
import mods.octarinecore.common.Double3
|
||||
@@ -49,8 +52,11 @@ abstract class AbstractBlockRenderingHandler(modId: String) : ResourceHandler(mo
|
||||
*/
|
||||
fun renderWorldBlockBase(ctx: BlockContext, dispatcher: BlockRendererDispatcher, renderer: VertexBuffer, layer: BlockRenderLayer?): Boolean {
|
||||
ctx.blockState(Int3.zero).let { state ->
|
||||
if (layer == null || state.block.canRenderInLayer(state, layer))
|
||||
if (layer == null ||
|
||||
state.canRenderInLayer(layer) ||
|
||||
(state.canRenderInCutout() && layer.isCutout)) {
|
||||
return dispatcher.renderBlock(state, ctx.pos, ctx.world, renderer)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -63,7 +69,7 @@ data class BlockData(val state: IBlockState, val color: Int, val brightness: Int
|
||||
* Represents the block being rendered. Has properties and methods to query the neighborhood of the block in
|
||||
* block-relative coordinates.
|
||||
*/
|
||||
class BlockContext() {
|
||||
class BlockContext {
|
||||
var world: IBlockAccess? = null
|
||||
var pos = BlockPos.ORIGIN
|
||||
|
||||
|
||||
@@ -81,6 +81,12 @@ data class Quad(val v1: Vertex, val v2: Vertex, val v3: Vertex, val v4: Vertex)
|
||||
fun setFlatShader(shader: Shader) = transformVI { vertex, idx -> vertex.copy(flatShader = shader) }
|
||||
val flipped: Quad get() = Quad(v4, v3, v2, v1)
|
||||
|
||||
fun cycleVertices(n: Int) = when(n % 4) {
|
||||
1 -> Quad(v2, v3, v4, v1)
|
||||
2 -> Quad(v3, v4, v1, v2)
|
||||
3 -> Quad(v4, v1, v2, v3)
|
||||
else -> this.copy()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mods.octarinecore.client.render
|
||||
|
||||
import mods.betterfoliage.loader.Refs
|
||||
import mods.octarinecore.common.*
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.renderer.VertexBuffer
|
||||
@@ -48,6 +49,10 @@ class ModelRenderer : ShadingContext() {
|
||||
if (quadFilter(quadIdx, quad)) {
|
||||
val drawIcon = icon(this, quadIdx, quad)
|
||||
if (drawIcon != null) {
|
||||
// let OptiFine know the texture we're using, so it can
|
||||
// transform UV coordinates to quad-relative
|
||||
Refs.quadSprite.set(worldRenderer, drawIcon)
|
||||
|
||||
quad.verts.forEachIndexed { vertIdx, vert ->
|
||||
temp.init(vert).rotate(rotation).translate(trans)
|
||||
val shader = if (aoEnabled && !forceFlat) vert.aoShader else vert.flatShader
|
||||
|
||||
@@ -164,4 +164,6 @@ class FieldRef(val parentClass: ClassRef,
|
||||
|
||||
/** Get this static field using reflection. */
|
||||
fun getStatic() = get(null)
|
||||
|
||||
fun set(receiver: Any?, obj: Any?) { element?.set(receiver, obj) }
|
||||
}
|
||||
Reference in New Issue
Block a user