![Falling Leaves (Fabric)](https://media.forgecdn.net/avatars/thumbnails/310/942/256/256/637400592017635072_animated.gif)
OptiFine changing color and textures of leaves
Fourmisain opened this issue ยท 6 comments
This image shows an issue with certain resource packs using OptiFine (A Little Taste of Jerm V2.5 on picture).
OptiFine can render leaves with different textures depending on the biome.
The actual block color (from getBlockColors()
) or texture (from getSprite()
) does not seem change.
This probably means the only way to fix this is by reproducing how OptiFine remaps textures.
Maybe looking at Colormatic can help
Colormatic supports loading resource packs with Optifine custom colors files as-is.
Features include: Biome colormaps for water, foliage, underwater, underlava, sky, and fog (...)
though it does not say anything about textures and the colors might not be an issue at all.
Ported the old code with some adjustments onto the ctm2 branch and made a test release.
BetterVanillaBuilding seems like a good pack to test on.
Maybe shipping the code and fixing the errors that pop up will turn it into something usable.
Though probably not over the holidays.
edit: 2nd test release fixing the handling of ids like "DarkForest"
Looking at the documentation, this is ridiculously complex.
There are multiple matching rules: matchTiles
, matchBlocks
and matching through the filename as a fallback.
Multiple .properties file can refer to the same block/tile and they will be processed in alphabetical order by filename.
There are shorthands, e.g. writing oak_leaves
instead of minecraft:oak_leaves
, writing 1-4
for tiles 1 2 3 4
.
matchBlocks
can have attached properties (e.g. minecraft:oak_stairs:facing=east,west:half=bottom
).
tiles
, which specifies the replacement tiles, has 7 different formats just because.
Of course we only need to support a subset of this (full block texture replacements), but it also needs to not fail on all other cases.
The ctm
branch is feeling pretty mature now.
It can detect when OptiFine's Connected Textures are enabled/disabled and it correctly maps biome+block id to the remapped texture - at least for A Little Taste of Jerm V2.5 where I tested Birch Leaves in Jungle biome.
There's still a lot of open questions and it needs more testing on different resource packs.
It's not just Connected Textures, Custom Colors affect leaf colors as well.
The Swamp Colors option also changes the given color if turned off - though that seems to only be an optimization, so no need to support it.
The ConnectedTexturesMod for Fabric has a very helpful description.
Apparently there are two different formats for Connected Textures:
- The OptiFine/MCPatcher format (where "CTM" stands for Connected Texture Map/Mapping)
- The ConnectedTexturesMod format
ConnectedTexturesMod for Fabric is obviously for the latter; for the first, there's Connected Block Textures.
As mentioned previously, there's also Colormatic for OptiFine/MCPatcher's Custom Colors.
I'm not sure if any of those 3 mods are compatible with the way we detect colors (TODO: test), but if they are and it's just OptiFine that's incompatible, it's probably not worth supporting it, seeing all the effort that's being done to replace every aspect of OptiFine.
The mods are all GPL licensed, so it's not as easy as getting inspired by their code, but maybe there is/will be an API we could use.