rosebudmods / rainglow

make your glow squids gorgeous!
MIT License
9 stars 3 forks source link

Colours not syncing at first. #8

Closed A5ho9999 closed 1 year ago

A5ho9999 commented 1 year ago

The colours of squids don't seem to stay at first spawn, not sure if it's something I'm doing wrong or not.

Reproduce:

Only checked on SP world, not sure if same with MP

Colour will change on first exit, but will stay that 2nd colour from there on.

ix0rai commented 1 year ago

thank you for reporting! I'm about 90% this is due to mojang doing some backend changes between 1.19.2 and 1.19.3, I'll look into it

ix0rai commented 1 year ago

ok so I've been looking into this, and it's actually really strange! somehow the colour is being saved as something other than what's displayed

ix0rai commented 1 year ago

can confirm this doesn't happen on 1.18!

ix0rai commented 1 year ago

ok so I made the world's worst fix for this

ix0rai commented 1 year ago

here's the comment explaining it:

        // so.
        // huge hack here
        // in single player, when you spawn an entity, it will create TWO SEPARATE ENTITIES
        // one on the server and one on the client
        // this means that they will have separate data trackers, which means that the client data tracker can generate a different colour from the server
        // this is bad, because the client squid will appear the wrong colour
        // we hack around this by generating the colour on one side, and then using that colour on the other side

the reason that the issue didn't appear on the second time opening the world is that the colour, saved from the server side, was read by both sides without issue

A5ho9999 commented 1 year ago

I see, that makes some sense I guess. I'll be sure to confirm when update is released thanks

ix0rai commented 1 year ago

being released right now!

ix0rai commented 1 year ago

@A5ho9999 https://modrinth.com/mod/rainglow/version/1.0.2+mc1.19.3

A5ho9999 commented 1 year ago

Yup, already grabbed. Just booting up the game now

A5ho9999 commented 1 year ago

Hmm, that doesn't seem to of fixed it. Still spawning and changing colours when logging. Though I did find when punching the newly spawned one the ink effect is correct to the server sided spawned.

ix0rai commented 1 year ago

ok, I'll investigate a better fix tomorrow. thanks!

A5ho9999 commented 1 year ago

So I had a look and tried a couple things, no success. It is very strange that it's generating 2 trackers for the same entity. Also with the current additions they don't actually change. Both trackers are being generated on the Client Environment Type apparently and the last colour also doesn't work because of it because it's locked to whatever the first colour generated is due to not being reset.

Edit: So after a break and another attempt, I believe I've narrowed the issue down to the GetColour any work around I attempted the game didn't like

Edit Edit: Seemed to of worked out a fix, but internet decided to die so can't share yet. I did something, I sure wish I knew how GitHub worked lmao

A5ho9999 commented 1 year ago

Okay so recap. I did a commit (I have no idea what that actually means or does). It seems to mostly fix the issue and didn't run into errors with it. But I would double check converting say a 1.18 world/ver to it to make that all is synced and not causing problems.

Some squids still don't sync correctly but this may be due to the fact it couldn't load all the data quick enough for the colours to apply correctly or whatever.

Something else to work out still, it seems the way the data is saved that the correct appearance on server sync won't stay/sync until the server is saved. Only seeing the writeNbtData fired on saves, so if auto-save is on they will still change colour until that save but if it doesn't save. The colours keep changing (and some just change anyway even with a save)

ix0rai commented 1 year ago

thank you for all your help, I'm interested to see your changes (you can just send a patch if github's whole system isn't your preferred workflow)

A5ho9999 commented 1 year ago

I managed to work it out lol, I forgot to do the push bit lmao

ix0rai commented 1 year ago

fixed this for real. mojang added a bunch of new stuff that entities with different visual variants have to implement in 1.19.3, and after injecting all that into glow squids it seems to work fine. let me know if it's still broken!

A5ho9999 commented 1 year ago

Cool, I'll check it out in a couple hours

ix0rai commented 1 year ago

fix is in https://modrinth.com/mod/rainglow/version/1.0.3+mc1.19.3!

A5ho9999 commented 1 year ago

fixed this for real. mojang added a bunch of new stuff that entities with different visual variants have to implement in 1.19.3, and after injecting all that into glow squids it seems to work fine. let me know if it's still broken!

Yup, seems to be working on both SP and MP. Thanks :D

ix0rai commented 1 year ago

I'm glad it works for you :)