Mapwriter 2

Mapwriter 2

2M Downloads

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

Darkhax opened this issue ยท 2 comments

commented

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.

commented

i will look into this. thanks for the information

commented

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.