diff --git a/build.gradle b/build.gradle index c6a046d..18200f9 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ apply plugin: "net.minecraftforge.gradle.forge" apply plugin: 'kotlin' group = 'com.github.octarine-noise' -version = "2.0" +version = "2.0.2" archivesBaseName = rootProject.name + '-MC1.8.8' buildscript { diff --git a/src/main/kotlin/mods/betterfoliage/client/render/AbstractRenderColumn.kt b/src/main/kotlin/mods/betterfoliage/client/render/AbstractRenderColumn.kt index 70a42e6..53789ab 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/AbstractRenderColumn.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/AbstractRenderColumn.kt @@ -147,10 +147,10 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl // set rotation for the current quadrant val rotation = baseRotation + quadrantRotation - // disallow sharp discontinuities in the chamfer radius + // disallow sharp discontinuities in the chamfer radius, or tapering-in where inappropriate if (quadrants[idx] == LARGE_RADIUS && - upType == PARALLEL && quadrantsTop[idx] == SMALL_RADIUS && - downType == PARALLEL && quadrantsBottom[idx] == SMALL_RADIUS) { + upType == PARALLEL && quadrantsTop[idx] != LARGE_RADIUS && + downType == PARALLEL && quadrantsBottom[idx] != LARGE_RADIUS) { quadrants[idx] = SMALL_RADIUS } @@ -179,6 +179,8 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl var downModel: Model? = null var upIcon = upTexture var downIcon = downTexture + var shouldRotateUp = true + var shouldRotateDown = true when (upType) { NONSOLID -> upModel = flatTop(quadrants[idx]) @@ -188,6 +190,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl } else { upIcon = sideTexture upModel = extendTop(quadrants[idx]) + shouldRotateUp = false } } PARALLEL -> { @@ -206,6 +209,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl } else { downIcon = sideTexture downModel = extendBottom(quadrants[idx]) + shouldRotateDown = false } } PARALLEL -> { @@ -222,7 +226,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl rotation, blockContext.blockCenter, icon = upIcon, - rotateUV = { 0 }, + rotateUV = { if (shouldRotateUp) idx else 0 }, postProcess = noPost ) if (downModel != null) modelRenderer.render( @@ -231,7 +235,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl rotation, blockContext.blockCenter, icon = downIcon, - rotateUV = { 0 }, + rotateUV = { if (shouldRotateDown) 3 - idx else 0 }, postProcess = noPost ) } diff --git a/src/main/kotlin/mods/betterfoliage/client/render/RenderLeaves.kt b/src/main/kotlin/mods/betterfoliage/client/render/RenderLeaves.kt index d4f9f72..8c75eed 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/RenderLeaves.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/RenderLeaves.kt @@ -14,8 +14,10 @@ import mods.octarinecore.random import net.minecraft.block.material.Material import net.minecraft.client.renderer.BlockRendererDispatcher import net.minecraft.client.renderer.WorldRenderer +import net.minecraft.util.EnumFacing import net.minecraft.util.EnumFacing.UP import net.minecraft.util.EnumWorldBlockLayer +import net.minecraft.util.EnumFacing.Axis import java.lang.Math.cos import java.lang.Math.sin @@ -23,7 +25,7 @@ class RenderLeaves : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) { val leavesModel = model { verticalRectangle(x1 = -0.5, z1 = 0.5, x2 = 0.5, z2 = -0.5, yBottom = -0.5 * 1.41, yTop = 0.5 * 1.41) - .setAoShader(edgeOrientedAuto(corner = cornerAoMaxGreen)) + .setAoShader(edgeOrientedAuto(corner = cornerAo(Axis.Y))) .setFlatShader(FlatOffset(Int3.zero)) .scale(Config.leaves.size) .toCross(UP).addAll() diff --git a/src/main/kotlin/mods/betterfoliage/client/texture/LeafRegistry.kt b/src/main/kotlin/mods/betterfoliage/client/texture/LeafRegistry.kt index e35f390..526842c 100644 --- a/src/main/kotlin/mods/betterfoliage/client/texture/LeafRegistry.kt +++ b/src/main/kotlin/mods/betterfoliage/client/texture/LeafRegistry.kt @@ -38,12 +38,19 @@ class LeafInfo( object LeafRegistry : BlockTextureInspector() { val particles: MutableMap = hashMapOf() - val typeMappings = TextureMatcher().apply { loadMappings(ResourceLocation("betterfoliage", "leafTypeMappings.cfg")) } + val typeMappings = TextureMatcher() init { matchClassAndModel(Config.blocks.leaves, "minecraft:block/leaves", listOf("all")) } + override fun onAfterModelLoad() { + super.onAfterModelLoad() + Client.log(INFO, "Inspecting leaf textures") + particles.clear() + typeMappings.loadMappings(ResourceLocation("betterfoliage", "leafTextureMappings.cfg")) + } + override fun processTextures(textures: List, atlas: TextureMap): LeafInfo { val texture = textures[0] var leafType = typeMappings.getType(texture) ?: "default" diff --git a/src/main/kotlin/mods/betterfoliage/client/texture/TextureMatcher.kt b/src/main/kotlin/mods/betterfoliage/client/texture/TextureMatcher.kt index 1791f99..7f2ef10 100644 --- a/src/main/kotlin/mods/betterfoliage/client/texture/TextureMatcher.kt +++ b/src/main/kotlin/mods/betterfoliage/client/texture/TextureMatcher.kt @@ -3,6 +3,7 @@ package mods.betterfoliage.client.texture import mods.octarinecore.client.resource.resourceManager import mods.octarinecore.client.resource.get import mods.octarinecore.client.resource.getLines +import mods.octarinecore.stripStart import net.minecraft.client.renderer.texture.TextureAtlasSprite import net.minecraft.util.ResourceLocation @@ -11,7 +12,8 @@ class TextureMatcher() { data class Mapping(val domain: String?, val path: String, val type: String) { fun matches(icon: TextureAtlasSprite): Boolean { val iconLocation = ResourceLocation(icon.iconName) - return (domain == null || domain == iconLocation.resourceDomain) && iconLocation.resourcePath.contains(path) + return (domain == null || domain == iconLocation.resourceDomain) && + iconLocation.resourcePath.stripStart("blocks/").contains(path) } } @@ -27,7 +29,7 @@ class TextureMatcher() { if (line2.size == 2) { val mapping = line2[0].trim().split(':') if (mapping.size == 1) mappings.add(Mapping(null, mapping[0].trim(), line2[1].trim())) - else if (mapping.size == 2) mappings.add(Mapping(mapping[1].trim(), mapping[0].trim(), line2[1].trim())) + else if (mapping.size == 2) mappings.add(Mapping(mapping[0].trim(), mapping[1].trim(), line2[1].trim())) } } } diff --git a/src/main/resources/assets/betterfoliage/leafTextureMappings.cfg b/src/main/resources/assets/betterfoliage/leafTextureMappings.cfg new file mode 100644 index 0000000..99adbdb --- /dev/null +++ b/src/main/resources/assets/betterfoliage/leafTextureMappings.cfg @@ -0,0 +1,6 @@ +// Vanilla +spruce=spruce +jungle=jungle + +// Biomes O' Plenty +fir=spruce \ No newline at end of file