Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix texture issue with 4.10+ models. #235

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

GrandpaScout
Copy link
Contributor

Blockbench pushed a fix in update 4.10.0 that fixed relative paths for textures. It originally treated the bbmodel file itself as a directory, which caused the relative path to contain an extra "../". Since this has been fixed, Figura tries to read textures as if the bbmodel is a directory (which it is not.)

This commit should fix this issue while still keeping compatibility with 4.9- models by doing the old method if a file at the relative path doesn't exist and the path starts with "../".


Gonna be honest. I kinda took the easy approach when making this. There's probably a better way of handling this but I don't wanna mess with Java's file path stuff too much.

The problems this issue caused are:

  • Paths to textures in the Lua runtime were extended with the path of the model file using the texture.
    This would cause scripts that relied on paths being the same to break with a sort-of-vague error depending on how the texture path was used.
  • Textures were duplicated due to not being able to find the common file to use.
  • Avatar size increses caused by the above.
    Unsure if the base64 version of the texture that Blockbench stores and Figura decodes would end up bigger than the external file that Blockbench is using. I didn't really test that.

The following was changed:

  • Resolves relative to the parent of the source file (which is hopefully the directory it is in) rather than the path of the source file itself.
    This fixes the 4.10+ issues.
  • If the file does not exist, checks if the relative path starts with ../ and if so, tries again using the old logic.
    This is done for 4.9- compatiblity.
    If the compatibility is not wanted (1/10 would not recommend as this would break older avatars that still work in 0.1.4) then this code can be simplified to a single line change at L134.

Blockbench pushed a fix in update 4.10.0 that fixed relative paths for textures.
It originally treated the bbmodel file itself as a directory, which caused the relative path to contain an extra "../".
Since this has been fixed, Figura tries to read textures as if the bbmodel is a directory (which it is not.)

This commit should fix this issue while still keeping compatibility with 4.9- models by doing the old method of if a
file at the relative path doesn't exist and the path starts with "../".
@UnlikePaladin UnlikePaladin merged commit f76a025 into FiguraMC:1.20 Jul 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants