improved Log block axis detection
This commit is contained in:
@@ -116,7 +116,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
|||||||
inline fun continous(q1: QuadrantType, q2: QuadrantType) =
|
inline fun continous(q1: QuadrantType, q2: QuadrantType) =
|
||||||
q1 == q2 || ((q1 == SQUARE || q1 == INVISIBLE) && (q2 == SQUARE || q2 == INVISIBLE))
|
q1 == q2 || ((q1 == SQUARE || q1 == INVISIBLE) && (q2 == SQUARE || q2 == INVISIBLE))
|
||||||
|
|
||||||
abstract val axisFunc: (IBlockState)->EnumFacing.Axis
|
abstract val axisFunc: (IBlockState)->EnumFacing.Axis?
|
||||||
abstract val blockPredicate: (IBlockState)->Boolean
|
abstract val blockPredicate: (IBlockState)->Boolean
|
||||||
|
|
||||||
abstract val sideTexture: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
abstract val sideTexture: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
||||||
@@ -131,7 +131,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
|||||||
modelRenderer.updateShading(Int3.zero, allFaces)
|
modelRenderer.updateShading(Int3.zero, allFaces)
|
||||||
|
|
||||||
// check log neighborhood
|
// check log neighborhood
|
||||||
val logAxis = ctx.blockAxis
|
val logAxis = ctx.blockAxis ?: return renderWorldBlockBase(ctx, dispatcher, renderer, layer)
|
||||||
val baseRotation = rotationFromUp[(logAxis to AxisDirection.POSITIVE).face.ordinal]
|
val baseRotation = rotationFromUp[(logAxis to AxisDirection.POSITIVE).face.ordinal]
|
||||||
|
|
||||||
val upType = ctx.blockType(baseRotation, logAxis, Int3(0, 1, 0))
|
val upType = ctx.blockType(baseRotation, logAxis, Int3(0, 1, 0))
|
||||||
@@ -314,7 +314,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Get the axis of the block */
|
/** Get the axis of the block */
|
||||||
val BlockContext.blockAxis: Axis get() = axisFunc(blockState(Int3.zero))
|
val BlockContext.blockAxis: Axis? get() = axisFunc(blockState(Int3.zero))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of the block at the given offset in a rotated reference frame.
|
* Get the type of the block at the given offset in a rotated reference frame.
|
||||||
|
|||||||
@@ -22,11 +22,13 @@ class RenderLog : AbstractRenderColumn(BetterFoliageMod.MOD_ID) {
|
|||||||
Config.blocks.logs.matchesID(ctx.block)
|
Config.blocks.logs.matchesID(ctx.block)
|
||||||
|
|
||||||
override var axisFunc = { state: IBlockState ->
|
override var axisFunc = { state: IBlockState ->
|
||||||
val axis = tryDefault("none") { state.getValue(BlockLog.LOG_AXIS).toString() }
|
val axis = tryDefault(null) { state.getValue(BlockLog.LOG_AXIS).toString() } ?:
|
||||||
|
state.properties.entries.find { it.key.getName().toLowerCase() == "axis" }?.let { it.value.toString() }
|
||||||
when (axis) {
|
when (axis) {
|
||||||
"x" -> Axis.X
|
"x" -> Axis.X
|
||||||
|
"y" -> Axis.Y
|
||||||
"z" -> Axis.Z
|
"z" -> Axis.Z
|
||||||
else -> Axis.Y
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user