
Demon pledges are acting odd
Sunconure11 opened this issue ยท 15 comments
After some deciding, I've decided to make this issue public, solely for anyone else who wants to take a stab at this.
Basically, demon pledging to either baphomet or leonard is acting really weird.
The pledges are not syncing correctly when exiting a world, both in singleplayer and multiplayer.
https://gyazo.com/74a1d4dba964831da0f3e42b7276b76f
A description of the issue, by @cybercat5555
oh I think there might be an issue with pledging in MP
sometimes after relogging or even dying, you'll be unpledged, but the demon is still neutral
tested with baphy with the server that has my modpack
alright a bit of testing:
in creative, you can constantly get new pacts from baphomet, not sure if intended?
in survival, it seems to "flicker" between being pledged and not? Like the next says "you are not pledged to baphomet" but then it rapidly switches to "you have received pact xxx for 7 days"
seems to do the same thing regardless of if its in one session, or if quit then rejoined
in the above gif, I was in survival mode and has about 19 levels
but baphy is still neutral to me, and I'm not wearing the besmirched stuff, so it seems I'm in some weird limbo of being pledged and not pledged
Class possibly at fault:
Relevant forge documentation:
https://mcforge.readthedocs.io/en/1.12.x/datastorage/worldsaveddata/
From a quick check:
- mixing players.getPersistentID() with players.getUniqueID() is prone to fail you one time or another.
- NBTTagCompound already support UUID getter/setter, instead of using string format, and probably much faster.
- adding a dump of the pledges to the logs when they change would help finding the issue since it appears to be reproductible, possibly with a configuration option so it only spams whoever investigate the issue.
Did changes relating to the first thing you noted.
Code probably needs a deeper look, but luckily, GitHub made it easier for people to navigate codebases.
Is the flickering text the only issue? I think that's because ExtendedWorld
isn't being synced to the client - the demon's processInteraction
gets called on client & server but they have different data, and they both call player.sendStatusMessage
causing two different messages to be sent.
You basically have two options there:
- Synchronize the pledges to the client, so the client knows when an interaction should cause a pact to be created. Personally I'd move that info to
ExtendedPlayer
and tag it onto your existing sync logic there. - Add a
!world.isRemote
check and only run the interaction logic on the server, then send a packet to the client to handle the sound effect
Paging @cybercat5555 to explain the issue in greater detail, since she first spotted it.
And as mentioned, here's the codebase of one of the two pledgable entities.
According to one individual at least, the code is probably related to the entity itself.
EntityLeonard is the other pledgable.
Of note is that pledging to one of the entity pledges you to all after reloading a world.
Looks like it worked aside from the fact one can get infinite pacts from Baphomet.
That can be arranged. Should it fail if you have any active contract effect, or only one acquired from Baphomet specifically?
Any active contract
Also as mentioned, check EntityLeonard, to see if there are issues there too
Leonard only gives brewing buffs right? I still get an extra brew after leaving and re-entering my SP world so that seems fine. Would encourage someone to test in MP, I can't at the moment.