Optimizes player heads by adding a cache #2348
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request avoids creating RenderType and getting the skin from the skinmanager every time a player head (inventory, block or placed in the armor slot) was rendered, as they are costly and currently took a similar amount of time as rendering the head itself.
Expected changes
Although, in singleplayer this change should not affect almost anything, in servers or maps where there is a high level of detail and many heads are used it should give a slight improvement, and as you can see in the screenshots below, in general it reduces the micro-stutter.
Spark
These spark tests were run for 30 seconds in the world with a chunk of heads. You can see that where before rendering the heads cost 13396ms it now takes 9000ms
dev branch: https://spark.lucko.me/KDvsr25bBC
this pr: https://spark.lucko.me/Tq8Ek2tpsE
Screenshots
A chunk of heads, worst-case scenario
this prdev branch
Entities with custom player heads
this pr
dev branch
A chest full of custom heads
this pr
dev branch
Hypixel's worst optimized lobby
this pr
dev branch