Capes icon indicating copy to clipboard operation
Capes copied to clipboard

Cache SkinTextures instances & fix toggle menu

Open imthosea opened this issue 1 year ago • 10 comments

In MixinPlayerListEntry, rather than making a new SkinTextures instance each time skin textures are requested, we cache an instance of our modified SkinTextures to supply. This requires us to refresh the list entry when we make a change (e.g. vanilla skin finished loading), which is handled in ListEntryAccessor. Lastly, this also makes the toggle menu and client cape type update instantly in-game, instead of having to leave and rejoin. This also removes the bug fix in CapeFeatureRenderer, as this is now fixed in vanilla.

imthosea avatar Nov 22 '23 02:11 imthosea

yo, i need someone with an animated cape

i have the animated capes purchased but don't have one equipped rn

wants me to equip an animated cape

i do that

🎶We're no strangers to love🎶

image

h3oCharles avatar Nov 22 '23 15:11 h3oCharles

...unfortunately, that was me!

imthosea avatar Nov 22 '23 15:11 imthosea

https://github.com/CaelTheColher/Capes/blob/1d1e3355faf7766686fa2ba9173ff50b706b6c71/common/src/main/kotlin/me/cael/capes/handler/PlayerHandler.kt#L99 this expects the url to be null if the cape type is disabled, so I suggest moving isCapeTypeEnabled into the enum itself and checking if its enabled before getting the url

https://github.com/CaelTheColher/Capes/blob/1d1e3355faf7766686fa2ba9173ff50b706b6c71/common/src/main/java/me/cael/capes/mixins/MixinPlayerListEntry.java#L40 and this sometimes crashes the game if you disable a cape type while in multiplayer due to not checking if cape type is null

CaelTheColher avatar Nov 24 '23 22:11 CaelTheColher

I fixed the possible crash you were talking about. Wouldn't moving isCapeTypeEnabled to the enum make the toggle menu not take effect instantly?

imthosea avatar Nov 24 '23 23:11 imthosea

I fixed the possible crash you were talking about. Wouldn't moving isCapeTypeEnabled to the enum make the toggle menu not take effect instantly?

I don't see why it would. It would be just for convenience so you could call CapeType#isEnabled instead of isCapeTypeEnabled(CapeType), and it would also allow it to be called from anywhere (like on the setCape method) instead of just the one Mixin class

CaelTheColher avatar Nov 24 '23 23:11 CaelTheColher

If we block setCape, doesn't that prevent the cape from ever downloading at all? If that happens, then the toggle menu would have to re-download the capes.

imthosea avatar Nov 25 '23 02:11 imthosea

If we block setCape, doesn't that prevent the cape from ever downloading at all? If that happens, then the toggle menu would have to re-download the capes.

it should only prevent downloading capes that are disabled, like a simple return false at the beginning of the setCape method if the cape type its trying to set is not enabled

CaelTheColher avatar Nov 25 '23 03:11 CaelTheColher

If we block the capes from being downloaded, then the toggle menu would have to redownload them when we re-enable the cape type, as opposed to being instant.

imthosea avatar Nov 25 '23 04:11 imthosea

A little late, but now, capes will no longer be downloaded if the cape type is disabled, and isCapeTypeEnabled was moved to CapeType. Sorry.

(also heres 1.20.4 support)

imthosea avatar Dec 26 '23 22:12 imthosea

I haven't been really able to work on modding recently due to some personal things, but I do plan on merging this eventually so don't worry about that

CaelTheColher avatar Dec 27 '23 01:12 CaelTheColher