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

Improve BlockColourGen by using block.getBlockState().getValidStates() #71

Open
Darkhax opened this issue Mar 5, 2018 · 2 comments
Open

Comments

@Darkhax
Copy link

Darkhax commented Mar 5, 2018

Currently the code tries to get a block state for each of the possible meta combinations. This leads to more lookups than necessary and is a big contributor to the exceptions you have to catch. You can use block.getBlockState().getValidStates() to get an immutable list of all valid states. In the tests I ran, this lead to an increase in load times. This increase was slight in vanilla, but more noticeable in heavily modded environments.

@Vectron
Copy link
Owner

Vectron commented Mar 5, 2018

i will look into this. thanks for the information

@Darkhax
Copy link
Author

Darkhax commented Mar 5, 2018

You could further optimize this code by replacing the code used to check for duplicate sprites. You currently compare all four UV coordinates, however you only need to compare U1 and V2 to get the same results.

If you wanted to further improve this code, you could map TextureAtlasSprite objects to their colour, and then use this result instead. In my basic tests the speed is roughly the same, but results in more sprites being skipped. This would likely have the biggest impact with higher res textures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants