[WIP] algae, reeds, mycelium, coral working
+ lots of cleanup, reorganizing
This commit is contained in:
@@ -3,17 +3,27 @@ package mods.betterfoliage.render.pipeline
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import mods.betterfoliage.chunk.BasicBlockCtx
|
||||
import mods.betterfoliage.chunk.BlockCtx
|
||||
import mods.betterfoliage.render.old.HalfBakedQuad
|
||||
import mods.betterfoliage.model.SpecialRenderModel
|
||||
import mods.betterfoliage.render.lighting.VanillaFullBlockLighting
|
||||
import mods.betterfoliage.render.lighting.VanillaQuadLighting
|
||||
import mods.betterfoliage.render.lighting.VanillaVertexLighter
|
||||
import mods.betterfoliage.model.HalfBakedQuad
|
||||
import mods.betterfoliage.util.Int3
|
||||
import mods.betterfoliage.util.plus
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.renderer.model.IBakedModel
|
||||
import net.minecraft.util.Direction
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.ILightReader
|
||||
import net.minecraftforge.client.model.data.IModelData
|
||||
import java.util.Random
|
||||
|
||||
/**
|
||||
* Rendering context for drawing [SpecialRenderModel] models.
|
||||
*
|
||||
* This class (and others in its constellation) basically form a replacement, highly customizable,
|
||||
* push-based partial rendering pipeline for [SpecialRenderModel] instances.
|
||||
*/
|
||||
abstract class RenderCtxBase(
|
||||
world: ILightReader,
|
||||
pos: BlockPos,
|
||||
@@ -23,12 +33,17 @@ abstract class RenderCtxBase(
|
||||
val modelData: IModelData
|
||||
) : BlockCtx by BasicBlockCtx(world, pos) {
|
||||
|
||||
abstract fun renderQuad(quad: HalfBakedQuad)
|
||||
|
||||
var hasRendered = false
|
||||
val blockModelShapes = Minecraft.getInstance().blockRendererDispatcher.blockModelShapes
|
||||
inline fun Direction?.shouldRender() = this == null || !checkSides || Block.shouldSideBeRendered(state, world, pos, this)
|
||||
var vertexLighter: VanillaVertexLighter = VanillaFullBlockLighting
|
||||
protected val lightingData = RenderCtxBase.lightingData.get().apply {
|
||||
calc.reset(this@RenderCtxBase)
|
||||
blockColors = Minecraft.getInstance().blockColors
|
||||
}
|
||||
|
||||
protected abstract fun renderQuad(quad: HalfBakedQuad)
|
||||
abstract fun renderFallback(model: IBakedModel)
|
||||
inline fun Direction?.shouldRender() = this == null || !checkSides || Block.shouldSideBeRendered(state, world, pos, this)
|
||||
|
||||
fun render(quads: Iterable<HalfBakedQuad>) {
|
||||
quads.forEach { quad ->
|
||||
@@ -39,5 +54,13 @@ abstract class RenderCtxBase(
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun renderMasquerade(offset: Int3, func: ()->Unit)
|
||||
fun renderMasquerade(offset: Int3, func: () -> Unit) {
|
||||
lightingData.calc.blockPos += offset
|
||||
func()
|
||||
lightingData.calc.blockPos = pos
|
||||
}
|
||||
|
||||
companion object {
|
||||
val lightingData = ThreadLocal.withInitial { VanillaQuadLighting() }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user